Question:
Can someone help me write a code that detects scrolling up and scrolling down?
Product:
Wix Editor
What are you trying to achieve:
I tried “writing” a code that detects when the user scrolls up and when they scroll down.
The goal is that a slideshow would show the next slide on scrolling down and vise versa.
I tried this code which I thought would change the background of the color of the background of the slideshow.
comlink.ts:265 Uncaught (in promise) ReferenceError: window is not defined
at eval (s38wt.js?analyze-imported-namespaces=true&init-platform-api-provider=true&get-app-def-id-from-packa…:1:436)
at eval (webpack-internal://:1:3191)
at clientWorker.e2e4b6f8.bundle.min.js:6:183345
at Function. (clientWorker.e2e4b6f8.bundle.min.js:6:297120)
at MessagePort.n (clientWorker.e2e4b6f8.bundle.min.js:1:161221)
deserialize @ comlink.ts:265
E @ comlink.ts:519
I don’t know if it would be helpful, but the page I am trying it on is Meinteholl.com/test
Your code won’t work, no matter what you will try.
You must know, that working on wix-sites is different to the way of writing html+js-code like for example on JS-Fiddle, or Code-Pen. You are writing JS-Codes the regular way, but this won’t work on Wix-Sites.
And you maybe will need to generate an Intervall-Function, which will check each second if the scroll-position has been changed and into which direction
I just came across your post as I’m trying to achieve exactly the same with no luck. I can’t believe something that looks so simple is impossible to do.
Did you get a response that helped you or found a way to do this?
I was able to do it with a section below the slideshow and this code
export function section2_viewportEnter(event) {
$w(“#fullWidthSlides1”).next();
$w(“#fullWidthSlides1”).scrollTo();
}
#fullWidthSlides1 is the id of the slideshow #Section2 is the id of the section that is getting detected
The code detects when the section below the slideshow is in view, it will trigger the next slide show and scroll you back to the top. I used buttons to go back to specific slides. I liked the concept, but ended up not using it.
Thanks for your response! I like the effect! It’s a shame that you need to add an extra section as I want to do it for my home age but I think I can work around it. However, the code doesn’t seem to work for me! Not sure if the section is too small? Is that the entire code? Thanks again!!
I don’t think measuring the position of the scroll will help in my case as I’m trying to set this up on my homepage with a slideshow that is 100vh, so the scroll position should not change but trigger the action when trying to scroll up/down.
It’s probably not available on wix. However I found this one onMouseIn - Velo API Reference - Wix.com that could be interesting. Instead of the scrolling action maybe I can create an action using this where the slideshow goes to the next slide when the mouse is on the slide? Would this work?