-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
Is there an alternative to scrollToProgress()? #178
Comments
Hi @EntropyReversed, Thank you for your question. It seems like you removed the following part when you created your feature request: It's important to not remove this, because I don't know if I should demonstrate how to achieve what you want with VanillaJs or ReactJs. I'm going to show you how to achieve what you want with VanillaJs, and if you're using ReactJs you'll have to refactor my code into the "React way" of doing it. Take a look at this CodeSandbox. Let me know if it helps. Best, |
Hi @davidcetinkaya! |
Glad to hear that @EntropyReversed. Try it out and let me know if it's working as intended. Best, |
Have one question. What is n in withinBounds()? |
@EntropyReversed, it should be |
When I call scrollToProgress(-0.5) on the load it scrolls to the middle (as it should), but when I call it from inputs eventListener and I pass its values (that range from 0 to -1) it doesn't work. It goes from start to end by the time input is about 20% scrolled input.addEventListener('input', () => {
let inputValue = input.value / 100;
scrollToProgress(-inputValue);
console.log(-inputValue) // this returns numbers from 0 to -1;
}) |
@EntropyReversed I’m not sure why you’re passing a negative number to This is because On a side note |
@davidcetinkaya I tried to pass only values from 0 to 1 to scrollToProgress but it doesn't work here is a codesandbox link. Maybe I'm doing something wrong? |
Hi again @EntropyReversed, I must have rushed it when copy pasting the code snippet. I've created a working CodeSandbox for you now. I took the liberty to sync the input when the user scrolls the carousel directly by dragging or clicking the previous and next buttons too. If you don't need it you can just remove that code. Sorry for the inconvenience and let me know if it's working as intended now. Best, |
Hey @davidcetinkaya, it works. And it is more than I asked for but it's everything that I need (i didn't want to bother you with syncing the input when the user scrolls the carousel, was planning to do it myself). So thank you very much and I really appreciate what you did! Btw, love Embla Carousel! |
Thanks @EntropyReversed, I’m glad to hear that. Closing this issue as resolved then. Enjoy! |
Currently working on project that has a slider that should be moved with input. I can get progress with scrollProgress() and if I plug it into input value input is updated on Embla scroll, how can I invert it so that Embla is updated with input? scrollToProgress() and scrollBy() were good for this use case but they were deprecated in v3.0.0. Are there any alternatives?
The text was updated successfully, but these errors were encountered: