[英]JQUERY - drag and scroll (same photoshop navigator palette)
I have this script http://jsfiddle.net/gphp/ZMmRv/4/ 我有这个脚本http://jsfiddle.net/gphp/ZMmRv/4/
I have two events: 1 - the div is draggable and his movement scrolls the page 2 - Scroll the page moves the div 我有两个事件:1-div是可拖动的,并且他的动作滚动页面2-滚动页面将div移动
there are a crash with these two events together. 这两个事件一起崩溃。 it is possible to apply one at a time.
一次可以申请一次。 start and stop event?
开始和停止事件? how?
怎么样?
thanks 谢谢
Well, i think is not the better solution but your can take this as a start and edit at your will: 好吧,我认为这不是更好的解决方案,但是您可以以此为出发点并随意编辑:
$(document).ready(function(){
$('#drag').css({
'height': ($(document).height()/10),
'width': ($(document).width()/10)
});
$("#drag").draggable({
scrollSensitivity: 50,
scrollSpeed: 10
});
$(window).scroll(function(){
if( $('#drag').offset().top < $(window).scrollTop() )
$("#drag").animate({top: $(window).scrollTop()}, "fast");
if( $('#drag').offset().left < $(window).scrollLeft() )
$("#drag").animate({left: $(window).scrollLeft()}, "fast");
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.