2012-11-28 38 views
0

你好!jquery拖放pep:我怎樣才能找到我的對象座標

Im使用jquery pep拖放。

我可以把它拖動,但我不知道如何來獲取對象的當前位置..

這裏是我的代碼:

var options = { 
      cssEaseDuration: 1000 
      start:   function(ev,obj){ $('#title').text('Start!'); }, 
      drag:   function(ev,obj){ 
      console.log("we're dragging!"); 
      // **I have to know here the coordinates** 
      }, 
      rest:   function(ev,obj){ 
console.log("stopped!"); 

} 
      }; 


     rectangle.pep(options); 

這裏是演示頁: http://pep.briangonzalez.org/demo

(你可以在這個頁面看到,在調試模式下,你可以看到座標 - 右下角 - 但我不能使用它)

全部信息: http://www.wwvalue.com/web-design/jquery/kinetic-drag-with-jquery-css3-and-html5.html

非常感謝您的幫助!

回答

0

好吧,我找到了解決辦法,很簡單:

var Drag1 = sym.$("Drag1"); 
var drag = $(Drag1).position(); 
console.log('x: ' + drag.left + 'y: ' + drag.top); 

不管怎樣,謝謝:)

0
jQuery(document).ready(function(){ 
    $(document).mousemove(function(e){ 
     console.log(e.pageX +', '+ e.pageY); 
    }); 
}) 

完整的文檔在這裏:http://docs.jquery.com/Tutorials:Mouse_Position

+0

謝謝!代碼是工作,但我需要的對象的當前位置,而不是隻有鼠標位置... – EranLevi