I am looking to implement a feature similar to paragraph sliding, but I am struggling to explain it clearly.
For demonstration purposes, I have added it to my website for you to view. Please note that it may take some time to load.
The paragraphs slide sequentially like this one after another.
I attempted to write the code myself, but did not receive any response after implementing it.
Below is the code I have written:
var mousewheel = (/Firefox/i.test(navigator.userAgent)) ? "DOMMouseScroll" : "mousewheel";
var IDK = 1;
slide.addEventListener(mousewheel,
function (e) {
if (e.wheelDelta > 0 || e.detail < 0) {
IDK + 1
$("html,body").animate({scrollTop: $("#" + IDK ).offset().top}, 1000);
} else {
if(IDK=1){
console.log("NO")
}else{
IDK - 1
$("html,body").animate({scrollTop: $("#" + IDK ).offset().top}, 1000);
}
}
}, false);
If you can provide guidance on how to improve my code, I would greatly appreciate it.
Please excuse any errors in my English, as it is not my first language.