2011-02-14 81 views
0

我意識到我在Chrome中存在jQuery Draggable的bug,這在Firefox和Internet Explorer中不存在。裏面有div#drag-container/450x80 /​​和3個可拖動的對象。/150x0 /當我將它們移動到最低點時,讓它們再次拖動LOWER,它們會獲得位置0,80 + 14 = 0.94 px。我讓他們拖動,他們再次降低了14倍。jQuery Draggable - 走出遏制 - Chrome Bug

是否有修復?

工作演示:http://jsfiddle.net/ucmqq/ 這裏是代碼:

<style> 
    .draggable { width: 150px; height: 0px; cursor:move; } 
    <?PHP if($userinfo->use_colors != '0'): ?> 
    #drag-container { width: 450px; height:80px; background-color:<?=$userinfo->background?>; } 
    <?PHP else: ?> 
    #drag-container { width: 450px; height:80px; background:url(/backgrounds/<?=$userinfo->image?>); } 
    <?PHP endif; ?> 
    </style> 

    <script language="javascript"> 

    $(function() { 
     $("#draggable").draggable({ cursor: "move",containment: 'parent', scroll: false, 
     stop: function() { 
     document.settings.np_x.value = $(this).css('left'); 
     document.settings.np_y.value = $(this).css('top'); 
     } 
            }); 
     $("#draggable2").draggable({ cursor: "move",containment: 'parent', scroll: false , 
     stop: function() { 
     document.settings.artist_x.value = $(this).css('left'); 
     document.settings.artist_y.value = $(this).css('top'); 
     } 
            }); 
     $("#draggable3").draggable({ cursor: "move",containment: 'parent', scroll: false , 
     stop: function() { 
     document.settings.other_x.value = $(this).css('left'); 
     document.settings.other_y.value = $(this).css('top'); 
     } 
            }); 
    }); 

    </script> 


<div id="drag-container"> 
    <div id="draggable" class="draggable" style="position:relative;top:5px;left:80px;"> 
     .::[ NowPlaying SIGnature ]::. 
    </div> 
    <div id="draggable2" class="draggable" style="position:relative;top:25px;left:80px;"> 
     Artist - title 
    </div> 
    <div id="draggable3" class="draggable" style="position:relative;top:45px;left:80px;"> 
     Album: (Year) 
     <br> 
     Genre: 
    </div> 

</div> 

回答

1

的問題是,拖動對象的高度爲0。身高1再次它的馬車,但沒有身高在所有它的確定。

0

我有同樣的錯誤,但在我的情況下沒有可拖動元素的高度。在我的例子中,我使用了bootstrap,並試圖將元素拖動到不同的div上。問題在於col-md-3的css float屬性。所以我不得不刪除它,並使用display: inline-block; vertical-align: top;

也許它會幫助別人。