Scroll the page on drag with jQuery

后端 未结 7 2086
无人及你
无人及你 2020-12-01 02:26

I have tried using kinetic.js and the code below, however when I try this in IE11 it keeps jumping to the top every time I scroll:

$(\"html\").kinetic();
         


        
7条回答
  •  星月不相逢
    2020-12-01 02:44

    I just like to add. Using Rory's code I made horizontal scrolling.

    var clicked = false, base = 0;
    
    $('#someDiv').on({
        mousemove: function(e) {
            clicked && function(xAxis) {
                var _this = $(this);
                if(base > xAxis) {
                    base = xAxis;
                    _this.css('margin-left', '-=1px');
                }
                if(base < xAxis) {
                    base = xAxis;
                    _this.css('margin-left', '+=1px');
                }
            }.call($(this), e.pageX);
        },
        mousedown: function(e) {
            clicked = true;
            base = e.pageX;
        },
        mouseup: function(e) {
            clicked = false;
            base = 0;
        }
    });
    

提交回复
热议问题