Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Fade Transition #94

Closed
jurajkapsz opened this issue Dec 4, 2017 · 2 comments
Closed

Feature request: Fade Transition #94

jurajkapsz opened this issue Dec 4, 2017 · 2 comments

Comments

@jurajkapsz
Copy link

Besides slide's move transition it would be great to have a fade transition option.

@loup-brun
Copy link
Collaborator

loup-brun commented Mar 7, 2019

Hi! I see this is quite old, I'm not sure if it's going to be added to Swipe, since the library is kept very lightweight.

I have a working example here: https://photographie.loupbrun.ca/

It basically involves using an animation library (VelocityJS) to fade the slide on Swipe callback.

Using CSS transitions is tricky, because Swipe itself already uses CSS transitions to fade the library in-out.

My example

window.mySwipe = new Swipe(mySwipeElem, {
callback: function(index, elem, dir) {
  _resetImageOpacity(); // Make all slides fully transparent (`opacity: 0`)
  callback: function(index, elem, dir) {
    elem.querySelector('figure').style.opacity = '0';
    // Indicate that we changed slide
    changedSlide = true;
  },
  transitionEnd: function(index, elem) {
    _resetImageOpacity();
    // Make sure we only run the transition on slide change
    if (changedSlide) {
      velocity(elem.querySelector('figure'), {
        opacity: [1, 0]
      });
    }
    // Reset the `changedSlide` flag once transition is complete
    changedSlide = false;
  }
});

@jurajkapsz
Copy link
Author

Hi, hm, looks great. Thanks for getting back to this and for the example. I'm still using Swipe wherever I can :), it's really great, and using VelocityJS is a nice solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants