2011-10-24 3 views
0

이 코드는 jQuery-1.3.2.min.js와 잘 동작하지만 jQuery-1.6.2.min.js에서는 실행되지 않습니다.jQuery 1.6.2 mouseup not firing

$(function(){ 
    $(document).mousedown(mouseUpAfterDrag); 

function mouseUpAfterDrag(e) { 

    /* You can record the starting position with */ 
    var start_x = e.pageX; 
    var start_y = e.pageY; 

    $().mousemove(function(e) { 
     /* And you can get the distance moved by */ 
     var offset_x = e.pageX - start_x; 
     var offset_y = e.pageY - start_y; 
    }); 

    $().one('mouseup', function() { 
     alert("This will show after mousemove and mouse released."); 
     $().unbind(); 
     $(document).mousedown(mouseUpAfterDrag); 
    }); 

    // Using return false prevents browser's default, 
    // often unwanted mousemove actions (drag & drop) 
    return false; 
    } 
}); 

이 코드를 jQuery-1.6.2.min.js에서 작동시키는 방법은 무엇입니까? 모든 솔루션?

+0

오류 메시지가? 방화범을 사용하여보십시오. –

+0

"실행되지 않음"이란 무엇을 의미합니까? – Blazemonger

+0

@ mblase75 mouseup이 (가) 실행되지 않습니다 – Raju

답변

0

아마도 여기가 원했던 것입니까?

http://jsfiddle.net/mblase75/qtU4H/

var start_x, start_y, offset_x, offset_y; 

$(document).mousedown(function(e) { 
    start_x = e.pageX; 
    start_y = e.pageY; 
    // console.log("start = " + start_x + "," + start_y); 
}).mousemove(function(e) { 
    if (!isNaN(start_x)) { 
     offset_x = e.pageX - start_x; 
     offset_y = e.pageY - start_y; 
     // console.log("offset = " + offset_x + "," + offset_y); 
    } 
}).one('mouseup', function() { 
    alert("This will show after mousemove and mouse released."); 
}); 
+0

mouseup이 (가) 한 번만 작동합니다. 두 번 클릭해도 전혀 작동하지 않습니다. – Raju

+0

@ Raju 그렇습니다. 그게'.one' 방법입니다. 원하지 않는다면 대신'.mouseup (function() ...) '을 사용하십시오. – Blazemonger

+0

매번 mousemove가 실행 중입니다. – Raju