Hello there,Is there a way to move an image vertically on scroll (i.e. the image would move to right when you scroll down)?Or a simple code?
1Jonathan TsodikovitchDash · Mar 03, 2021Hey @shirilipinsky, It's currently possible with some Velo. Example website: https://jonathant99.editorx.io/mysite-48 Code:import { timeline } from 'wix-animations'; import wixWindow from 'wix-window'; $w.onReady(function () { txtScroll() function txtScroll() { wixWindow.getBoundingRect() .then((windowSizeInfo) => { let scrollY = windowSizeInfo.scroll.y; timeline().add($w('#mytxt'), { x: scrollY, duration: 100 }).play(); }); setTimeout(txtScroll, 10); } });Also, in order to maintain good performance on your website, it's recommended to disable animations when scrolling past element's viewport. So I would suggest adding export function section4_viewportEnter(event) as trigger.
Hey @shirilipinsky, It's currently possible with some Velo. Example website: https://jonathant99.editorx.io/mysite-48 Code:
import { timeline } from 'wix-animations'; import wixWindow from 'wix-window'; $w.onReady(function () { txtScroll() function txtScroll() { wixWindow.getBoundingRect() .then((windowSizeInfo) => { let scrollY = windowSizeInfo.scroll.y; timeline().add($w('#mytxt'), { x: scrollY, duration: 100 }).play(); }); setTimeout(txtScroll, 10); } });
Also, in order to maintain good performance on your website, it's recommended to disable animations when scrolling past element's viewport. So I would suggest adding export function section4_viewportEnter(event) as trigger.