GithubHelp home page GithubHelp logo

Comments (9)

daun avatar daun commented on May 27, 2024 1

Sounds like a great topic to explore on a call sometime 🔮

from swup.

daun avatar daun commented on May 27, 2024 1

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.

daun avatar daun commented on May 27, 2024

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.

hirasso avatar hirasso commented on May 27, 2024

That will be one part of the solution for sure – I'm unsure about these two:

  1. how do we cleanly cancel/restart CSS animations? Something like
    1. remove animation classes
    2. wait one tick
    3. initialize the next visit
  2. 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.

daun avatar daun commented on May 27, 2024

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.

hirasso avatar hirasso commented on May 27, 2024

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.

hirasso avatar hirasso commented on May 27, 2024

Or are we listening for the transitionend/animationend event? I'll need to revisit the source code 😅

from swup.

hirasso avatar hirasso commented on May 27, 2024

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.

daun avatar daun commented on May 27, 2024

Solved in #836 and landing soon ☺️

from swup.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.