如何使用JQuery平移div

时间:2012-11-22 17:44:42

标签: javascript jquery html

我已经尝试了一段时间来让一个简单的div工作,但是我似乎无法达到100%。它部分适用于错误。

$("#view_point").mousedown(function(e) {
    start_x = e.pageX;
    start_y = e.pageY;
    e.preventDefault()
    //On Click set start x and y vars
}).mousemove(function(e) {
    temp_x = e.pageX;
    temp_y = e.pageY;
    e.preventDefault();
}).mouseup(function(e) {
    temp_x = Math.abs(temp_x - start_x);
    temp_x = Math.abs(temp_y - start_y);

    console.log(temp_x + " - " + temp_y);

    //Animate the map
    $("#tiles").animate({
        marginTop: '-' + temp_x,
        marginLeft: '-' + temp_y
    }, 50);
});​

如何制作一个pan脚本,该脚本将在溢出属性设置为隐藏的div内平移。

0 个答案:

没有答案