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: Enable Animation #77

Open
aapatre opened this issue Apr 18, 2022 · 3 comments
Open

Feature Request: Enable Animation #77

aapatre opened this issue Apr 18, 2022 · 3 comments

Comments

@aapatre
Copy link

aapatre commented Apr 18, 2022

Hi @sneas, hope you are doing well
Is it possible to add a feature to animate the divider? :)

As done in this slider: https://github.com/OnurErtugral/react-image-comparison-slider

Thanks & Regards,
Antariksh

@sneas
Copy link
Owner

sneas commented Apr 18, 2022

Hi Antariksh,

There is no such functionality per-se, but you can build one yourself based on what the component already has. The code example would be:

const slider = document.getElementById('slider');

let direction = 'right';

let move = () => {
    slider.value = slider.value + 0.15 * (direction === 'right' ? 1  : -1);
    if (slider.value >= 100) {
       direction = 'left';
    }

    if (slider.value <= 0) {
        direction = 'right';
    }
}

let animationId;

let animate = () => {
  move();
  animationId = requestAnimationFrame(animate);
}

animationId = requestAnimationFrame(animate);

@aapatre
Copy link
Author

aapatre commented Apr 19, 2022

Thanks a lot, @sneas
I will try this out :)

@Vantadaga
Copy link

Is it possible to make this work with this project?

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

No branches or pull requests

3 participants