Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
How to retrieve senna.js app object in theme's script?
Hi all,
I am still getting to grips with how Senna.js works. Since its mostly transparent when developing a theme its difficult to find examples when its needs to be specifically invoked. I am not sure if I even need to do this for the issue I want to resolve. Let me set the scene:
I have customised the navigation menu with some css animations. On link click I have a custom function to change the class for the animation. The animation is terminated when this function returns. I would like the animation to finish and then display the results of the page fetch.
I am thinking as follows:
Do an "e.preventDefault()" call at the end of my function. Then in a "onanimationend" event listener fire the senna "app.navigate()" method. Three questions:
I am still getting to grips with how Senna.js works. Since its mostly transparent when developing a theme its difficult to find examples when its needs to be specifically invoked. I am not sure if I even need to do this for the issue I want to resolve. Let me set the scene:
I have customised the navigation menu with some css animations. On link click I have a custom function to change the class for the animation. The animation is terminated when this function returns. I would like the animation to finish and then display the results of the page fetch.
I am thinking as follows:
Do an "e.preventDefault()" call at the end of my function. Then in a "onanimationend" event listener fire the senna "app.navigate()" method. Three questions:
- Is this the best way to go? (It would be great if the fetch can start while the animation is playing out.)
- The page fetches are to different sites with own domains but on the same liferay instance - will this impact how senna works?
- How do I get a reference to the senna app in a freemarker theme?
So I found out there exists "Liferay.spa.app" and and "Liferay.on" which can be used to override some senna functionality. There appears to be very little documentation on the Liferay.spa javascript object. Transitions still happen too quickly, at least on localhost testing and I would like to specify a minimum delay to allow the transition to complete before swapping out. Any ideas how to do this?
thanks
thanks
Liferay.spa.app.setLoadingCssClass("xyz-nav-hide");
Liferay.on('beforeNavigate', function(event) {
if(visible) {
nav.removeClass("xyz-nav-show");
visible=false;
}
});
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™