滚动时不受欢迎的拖动

时间:2011-12-13 10:40:29

标签: javascript jquery html jquery-ui html5

我一直在使用Jquery ui.Draggable。 当我滚动段落时,div与其父元素同时拖延。 任何人都可以帮助我如何在滚动时暂时禁用拖动?

<div class="note">
        <p>
        Lorem Ipsum is simply dummy text of the printing 
        and typesetting industry. Lorem Ipsum has been the 
        industry's standard dummy text ever since the 1500s, 
        when an unknown printer took a galley of type and 
        scrambled it to make a type specimen book. It has 
        survived not only five centuries, but also the leap 
        into electronic typesetting, remaining essentially 
        unchanged. It was popularised in the 1960s with the 
        release of Letraset sheets containing Lorem Ipsum passages, 
        and more recently with desktop publishing software like Aldus 
        PageMaker including versions of Lorem Ipsum.
        </p>
</div>



$(function(){
            var str = "div.note";
            var el = $(str);
            var er = $(str+' p');
            $this = er;

            el.draggable().resizable();

            el.bind('resize', function(){
             var node = $(this);
             var size = Math.pow(node.width(),2) + Math.pow(node.height(),2);
             size = Math.sqrt(size);
             node.css({'font-size':(size/2)+'%', 'padding':(size/24)+'px'});
            });     
});

最好的问候

1 个答案:

答案 0 :(得分:1)

你可以设置句柄:

http://jqueryui.com/demos/draggable/#option-handle

...

    el.draggable({handle: 'p'}).resizable();

...

这里是jsFiddle:http://jsfiddle.net/s65UR/2/