jQuery实现360°全景拖动展示
js
drag.js
unitStep){
if(mmx-mdx>0){
current=current+1;
}else{
current=current-1;
}
mdx=mmx;
if(current<0)current=length-1;
if(current>length-1)current=0;
that.attr("src",images[current]);
}
}
}).on('touchend',function(e){
isDrag=false;
});
//拖动
that.on('mousedown',function(e){
mdx=e.pageX;
isDrag=true;
}).on('mousemove',function(e){
mmx=e.pageX;
if(isDrag){
if(Math.abs(mmx-mdx)>unitStep){
current=current+(mmx-mdx>0?1:-1);
mdx=mmx;
if(current<0)current=length-1;
if(current>length-1)current=0;
that.attr("src",images[current]);
}
}
return false;
})
$(document).on('mouseup',function(e){
isDrag=false;
});
$(document).on('mouseleave',function(e){
isDrag=false;
});
return this;
};
})(jQuery);
以上所述就是本文的全部内容了,希望大家能够喜欢。