I’d like to set a picture follow the screen(pin to screen) when scrolling, and limit the minY&maxY. How could I do it by velo code?
I tryed the code below but it didn’t work.
$w.onReady(function () {
const $image = $w("#floatingImage");
const minY = 100;
const maxY = 500;
$w.onViewportScroll(() => {
const scrollY = $w("#page").scrollY;
let newY = scrollY + 50;
if (newY < minY) newY = minY;
if (newY > maxY) newY = maxY;
$image.style.top = `${newY}px`;
});
});