swup/swupjs

Delay action when clicking a link

rcobiella opened this issue · 3 comments

Hi again,

Is there any way of delaying the Swup action when I click a link? I need to do a pre-transition before Swup's transition, so I would need that one to be finished before Swup starts doing it's thing. I could just remove link and have the href in a data attribute and load through loadPage, but can I specify the transition I want there like I do in links with the swup-class attribute?

Thanks!

Specifying a transition through loadPage method has been mentioned here and I will implement it in the nearest future. It could be really handy in some situations.

Another option could be delaying the animation directly in the animation function. You can run anything in that function, including setTimeouts or waiting for some promise to resolve before running the animation. All that matter to swupjs is the next() call. Would that fit your use case?

That would be very cool if you added it to loadPage, but yes, you're right! I'll make it work that way.

Thanks again.

Glad that works for you!

I'm also pleased to tell you, you can now execute your original plan. Please, refer to this.