Jump to content
Search Community

How can I reset the animation when the browser resizes (Mobile/Tablet).

aydinvivik test
Moderator Tag

Recommended Posts

Hello, how can I reset the animation responsively on this work? For example, you came by dragging it to slide 3 and after resizing the browser to smaller than 768px, I need to reset the animation and make it start from the beginning.

 

When I add the following code, the animation is reset, but then when I rewiden the browser, the animation and draggable do not work.

const isMobile = window.matchMedia("(max-width: 768px)");

function resize() {
  //...

  if (isMobile.matches) {
    animation.progress(0).kill();
    draggable.startProgress = animation.progress();
  }
}

Codepen demo:

See the Pen YzdmXwd by vivik (@vivik) on CodePen

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...