2011-10-30 4 views
0

draggable jquery UI 플러그인 (http://jqueryui.com/demos/draggable/)을 사용하여 내 페이지에 드래그 가능한 요소를 추가하려고합니다. 내가 필요로 무엇jquery animate vertical up

$("#makeMeDraggable").draggable({ axis: "y", limit: {top: 10, bottom: 550}}); 

수직으로 드래그 할 수 있도록 단지입니다 -하지만 위쪽 (아래쪽으로 드래그 불허) :

$("#makeMeDraggable").draggable({ axis: "y"}); 

이미 시도 : 순간 나는이 있습니다. 작업 예제

$("#makeMeDraggable").draggable({ axis: "y"}); 

var lastYPosition = null; 

$("#makeMeDraggable").draggable({ 
    drag: function(event, ui) { 

     // set with the initial y position 
     if(lastYPosition === null) { 
      lastYPosition = ui.originalPosition.top;   
     } 

     // don't do the drag if the new y position is larger than the old one 
     if(ui.position.top > lastYPosition) { 
      return false; 
     } 

     // update the last y position with current value 
     // so we can check against it next time 
     lastYPosition = ui.position.top; 
    } 
}); 

그리고 여기에 있습니다 : : (크롬과 사파리에서 테스트)를 당신이 여기서 뭘하려고 무엇

+0

제임스가 게시 한 효과를 JamWaffles가 시도했습니다. 즉, "수직 위로"끌기 만 허용했습니다. – Snapper

답변

1

이 코드를 시도? 요소를 현재 창 공간 내에서만 드래그 할 수있게 하시겠습니까? 아니면 무엇입니까? 나는 이것이 플러그인이라고 가정한다. 어떤 페이지인지 알 수 있도록 플러그인 페이지에 연결할 수 있습니까?
+0

완벽한 제임스. 고마워요 :) – Snapper