Jquery plugins Jquery-Safari-won';在插件中注册mousemove

Jquery plugins Jquery-Safari-won';在插件中注册mousemove,jquery-plugins,scroll,mousemove,Jquery Plugins,Scroll,Mousemove,简单地说,在我测试它的前几次,它就工作了,然后它停止了,代码没有任何变化。这里是发布在JSFIDLE上的,它根本不起作用,但这里是链接: 这是代码 (function($) { $.fn.jqScroll = function(options) { var $this = this; var origin, current, difference; var height = this.outerHeight(); var width = this.outerWid

简单地说,在我测试它的前几次,它就工作了,然后它停止了,代码没有任何变化。这里是发布在JSFIDLE上的,它根本不起作用,但这里是链接:

这是代码

(function($) {
$.fn.jqScroll = function(options) {
    var $this = this;
    var origin, current, difference;
    var height = this.outerHeight();
    var width = this.outerWidth();
    var stored = [];
    var elem = [];

    var bounds = $this.offset();
    bounds = [bounds.left,bounds.top,bounds.left + width,bounds.top + height];

    init();

    function init() {
        $(document).bind('mousedown',scrollCheck)
    }

    function scrollCheck(e) {
        data = $.data($(e.target).get(0),'events')
        if (data && (data.click || data.mousedown)) return false

        if (e.clientX < bounds[0] || e.clientX > bounds[2] ||
            e.clientY < bounds[1] || e.clientY > bounds[3]) return false

        origin = e.clientY;

        $(document).bind('mousemove',function(e) { scrollMove(e) });
        $(document).bind('mouseup',stopScroll);
    }

    function scrollMove(e) {
        current = e.clientY;
        difference = origin - current;

        $this.children().each(function(a,b) {
            if (!stored[a]) {
                stored[a] = $(this).offset().top
                elem.push(b);
            }
            var y = stored[a];

            $(this).offset({top:y - difference});
        });
    }

    function stopScroll(e) {
        $(document).unbind('mousemove').unbind('mouseup');

        if ($(elem[0]).offset().top > 0) resetElem(-$(elem[0]).offset().top + 30)
        else if ($(elem[elem.length-1]).offset().top < height) resetElem(-$(elem[elem.length-1]).offset().top - 50 + height)
        else {
            stored = [];
            elem = [];
        }
    }

    function resetElem(dir) {
        var dist = $(elem[0]).offset().top - 20;
        $this.children().each(function(a,b) {
            if (!stored[a]) stored[a] = $(this)
            var y = $(this).offset().top - dist;

            $(this).animate({
                top: '+=' + dir
            },1000,function() {
                stored = [];
                elem = [];
            });
        });
    }

    return this
};
})(jQuery);
(函数($){
$.fn.jqScroll=函数(选项){
var$this=这个;
var来源、电流、差异;
var height=this.outerHeight();
var width=this.outerWidth();
存储的var=[];
var-elem=[];
var bounds=$this.offset();
bounds=[bounds.left,bounds.top,bounds.left+宽度,bounds.top+高度];
init();
函数init(){
$(document).bind('mousedown',scrollCheck)
}
功能滚动检查(e){
data=$.data($(e.target).get(0),'events')
if(data&(data.click | | data.mousedown))返回false
如果(e.clientXbounds[2]||
e、 clientYbounds[3])返回false
来源=e.clientY;
$(document.bind('mousemove',函数(e){scrollMove(e)});
$(document).bind('mouseup',stopScroll);
}
功能滚动移动(e){
当前=e.clientY;
差=原点-电流;
$this.children().each(函数(a,b){
如果(!存储[a]){
存储的[a]=$(此).offset().top
元素推动(b);
}
变量y=存储的[a];
$(this).offset({top:y-difference});
});
}
功能停止滚动(e){
$(文档).unbind('mousemove').unbind('mouseup');
如果($(元素[0]).offset().top>0)重置元素($(元素[0]).offset().top+30)
否则如果($(元素[elem.length-1]).offset().top