reload scripts or functions
esseifforte opened this issue · 3 comments
esseifforte commented
Hello,
I noticed that using this fantastic script on some pages do not load some of my functions containing animations.
is there a way (other than to call incoming functions for new pages) to force loading?
thank you
gmrchk commented
Hi and sorry for late reply.
To load/run scripts after the page transition, it is best to use the swup events. In particular, the pageView
or contentReplaced
events.
Would that work for your needs?
esseifforte commented
Hi @gmrchk , no problems!
at the moment I have this configuration:
const options = {
LINK_SELECTOR: '.lnk',
FORM_SELECTOR: '.js-form',
elements: ['#swup'],
animations: {
'*': {
out: function(next){
var t4 = new TimelineMax({onComplete: next});
// my animations
},
in: function(next){
var t3 = new TimelineMax({onComplete: next});
// my animations
// my calls at the functions
}
},
cache: true,
pageClassPrefix: '',
scroll: false,
doScrollingRightAway: false,
debugMode: true,
preload: true,
support: false,
skipPopStateHandling: function(event){
if (event.state && event.state.source == "swup") {
return false;
}
return true;
},
animateHistoryBrowsing: true,
}
const swup = new Swupjs(options);
How should I proceed with your suggestions?
gmrchk commented
This was discussed several times already, so please check out this thread. It should help you get started.
As I mentioned, the documentation also includes some general info on the topic.