R
R
rasell2018-11-27 13:12:36
JavaScript
rasell, 2018-11-27 13:12:36

Animation playback?

Hello everyone, please tell me there is a script for horizontal scrolling so that when scrolling, the animation is played for the elements in the parent
, here is the script itself:

if($(window).width() > 992) {
       var left = 0;
        function scrollHorizontally(e) { //включает горизонтальный скрол элемента колесом
           e.preventDefault();
           e = window.event || e;
           var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))); //это шаг колеса для разных браузеров
            console.log(delta);
            left  -= (-delta * 100);
            if(left > 0) left = 0;
            if(left < -8500) left = -8500;
            $('#pagepiling').stop(true,true).animate({'margin-left':left},500); 
           //document.documentElement.scrollLeft -= (delta * 50); //прокручиваем всю страницу
       };
     
       function addMouseWell(elem, callback) { //вешает кроссплатформенный обработчик на колесо мыши над элементом
           if (elem.addEventListener) {
               if ('onwheel' in document) {
                   elem.addEventListener("wheel", callback);
               } else if ('onmousewheel' in document) {
                   elem.addEventListener("mousewheel", callback);
               } else {
                   elem.addEventListener("MozMousePixelScroll", callback);
               }
           } else {
               elem.attachEvent("onmousewheel", callback);
           }
       }

       addMouseWell(window, scrollHorizontally);
       
    }

i.e. so that each div in turn is given a class in #pagepiling

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question