我在使用panzoom缩放所有内容的页面。问题是,当我在页面中拖动某些内容时,拖动项目的位置会变差。
答案 0 :(得分:1)
我不确定,但也许我找到了回答。
这里有两点:
在我的代码下方缩放背景并在其上移动对象。 根据{{3}}
缩放光标HTML
<script src = "/js/vendors/jquery-ui.min.js"></script>
<script src = "/js/vendors/jquery.panzoom.min.js"></script>
<div id = "map-viewport">
<div id = "map">
<div class = "draggable">1</div>
<div class = "draggable">2</div>
</div>
</div>
JS
var map = $('#map');
var viewport = $('#map-viewport');
map.panzoom({
increment: 0.1,
minScale: 1,
contain: 'invert'
});
viewport.on('wheel', function( e ) {
e.preventDefault();
var delta = e.delta || e.originalEvent.wheelDelta;
var zoomOut = delta ? delta < 0 : e.originalEvent.deltaY > 0;
map.panzoom('zoom', zoomOut, {
increment: 0.2,
animate: false,
focal: e.originalEvent
});
});
var click = { x: 0, y: 0};
$('.draggable')
.draggable({
containment: 'parent',
start: function(e) {
click.x = e.clientX;
click.y = e.clientY;
},
drag: function(e, ui) {
var m = map.panzoom('getMatrix');
var zoom = Math.sqrt(m[0] * m[3]); // zoom don't change proportion and scale
var original = ui.originalPosition;
ui.position = {
left: (e.clientX - click.x + original.left) / zoom,
top: (e.clientY - click.y + original.top ) / zoom
};
}
})
.on('mousedown', function(e){
e.stopImmediatePropagation();
return false;
});
答案 1 :(得分:0)
在这里。我正在使用浏览器js。 jQuery UI和Panzoom的可拖动
CREATE TABLE T1 (
id INTEGER PRIMARY KEY,
[Other columns]
);
CREATE TABLE T2 (
carId INTEGER REFERENCES T1(id),
imperfection INTEGER
);