[Clearly ask your question.]
This is One-page scrolling code.
$w.onReady(function () {
console.log('onready');
const Slider = function(pages) {
let slides = [],
count = 0,
current = 0,
touchstart = 0,
animation_state = false;
const init = () => {
slides = pages.children;
count = slides.length;
for(let i = 0; i < count; i++) {
slides[i].style.bottom = -(i * 100) + '%';
}
}
const gotoNum = (index) => {
if((index != current) && !animation_state) {
animation_state = true;
setTimeout(() => animation_state = false, 500);
current = index;
for(let i = 0; i < count; i++) {
slides[i].style.bottom = (current - i) * 100 + '%';
}
}
}
const gotoNext = () => current < count - 1 ? gotoNum(current + 1) : false;
const gotoPrev = () => current > 0 ? gotoNum(current - 1) : false;
pages.ontouchstart = (e) => touchstart = e.touches[0].screenY;
pages.ontouchend = (e) => touchstart < e.changedTouches[0].screenY ? gotoPrev() : gotoNext();
pages.onmousewheel = pages.onwheel = (e) => e.deltaY < 0 ? gotoPrev() : gotoNext();
init();
}
let pages = $w('.pages');
let slider = new Slider(pages)
});
It’s Not Working. What’s problem?
‘pages’ class is exists.
This url is my test page.
Product:
Wix Editor