Answer the question
In order to leave comments, you need to log in
How to check scroll position in javascript correctly?
There is a fancybox, with a scroll at the bottom.
Added left and right buttons. The right one is always "shown", the left one - only after pressing the right one; and the left one disappears if you return to the very beginning. If you press at the very end, then there is a return to the beginning and the left button disappears.
I want to make the left button appear after scrolling.
I added a function to javascript that "catches" the scroll position and changes the properties of the element (Left button).
function leftbut() {
var slbox = document.getElementsByClassName('single-screens')[0]; // блок с картинками
var prev_el = document.getElementById('prev'); // Левая кнопка
if (slbox.scrollLeft > 50) {
prev_el.style.opacity='1'; // "показываем"
prev_el.className = "det-pic-control go"; // Меняем стиль; + для обработки jquery
} else if (slbox.scrollLeft <= 50) {
prev_el.style.opacity='0';
prev_el.className = "det-pic-control";
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question