Comments (9)
Sounds like a great topic to explore on a call sometime 🔮
from swup.
We‘re listening for transitionend
so I think we‘re covered. There’s a timeout there too, but that‘s a fallback if there‘s more or less properties transitioning than expected.
from swup.
I guess we could always expand the current checks we're doing to identify and ignore visits that have been superseded by a new one in the meantime.
// Abort if another visit was started in the meantime
if (visit.id !== this.visit.id) {
return false;
}
from swup.
That will be one part of the solution for sure – I'm unsure about these two:
- how do we cleanly cancel/restart CSS animations? Something like
- remove animation classes
- wait one tick
- initialize the next visit
- how would we go about it if the user clicks another link during the out-animation?
Does animating still make sense in this scenario at all, if we think about special animations for routes (Route Name Plugin, JS Plugin)? My initial thought was that the cleanest approach would be to cancel eventually running animations altogether.
from swup.
Regarding 1, that sounds perfectly reasonable.
On point 2, that's already solved, at least when using CSS class-based transitions. The above check visit.id !== this.visit.id
will effectively just drop any visits if during the out-animation another visit was requested. Adding the css class for the out-animation again will not really do anything. For clicks during the in-animation, this will not yet work, as well as for JS animations, as these do get repeated, I think.
I agree that dropping any existing visits and short-circuiting would be best, i.e. cancel running animations. This would probably only work if CSS transitions are bound to html.is-changed
, otherwise we don't have a way of safely removing the transition from the element.
from swup.
Part 2 is not completely solved I think. The animation promise of a new visit during the out animation will retrieve the wrong animation duration, since it will just read the transition/animation duration from the element, ignoring already elapsed animation time. We'd need to somehow detect the current process of the animation somehow and subtract that from the duration, don't we?
from swup.
Or are we listening for the transitionend
/animationend
event? I'll need to revisit the source code 😅
from swup.
While investigating I found that is-leaving
is not part of swupClasses
and thus won't be cleared on classes.clear()
. Seems to me to be unintended. Found out about it by finding that is-leaving
sometimes persists on the html
element upon rapid navigation.
from swup.
Solved in #836 and landing soon
from swup.
Related Issues (20)
- Triggering link:click twice seems to interfere with content:replace and animation:in HOT 3
- Cannot use import outside of modules
- @swup/js-plugin: ^3.1.1 and @swup/scripts-plugin: ^2.0.0 break Astro formatting HOT 6
- Suggest changes to this page links from the Documentation result in a 404 on GitHub HOT 1
- Rethink tests setup for official plugins HOT 5
- pageA goto pageB; but,with diffrent link style; when back to PageA,the links style is losted
- [Bug]: Undefined link href on Safari 13.1 and lower HOT 10
- [Feature Request]: Add way to easily listen to ALL hook events HOT 3
- [Feature Request]: Expose AbortController to be able abort request programmatically HOT 20
- Feature: Allow aborting running visits HOT 1
- Ignore errors in user hooks HOT 1
- Importing helpers from CDN module HOT 2
- History navigation ignored when using custom link selector HOT 5
- [Bug]: URL in `visit:start` inconsistent between normal and history visits HOT 4
- Feature: Store parsed html document in visit object HOT 11
- [Solved]: New values in <head> are not updated HOT 2
- [Bug]: [data-swup-ignore-script] issue with Contact Form 7 in Wordpress HOT 4
- Implement tests for official plugins
- [Feature Request]: Add drop-in attribute to swap/replace content of elements outside the swup container HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swup.