我正在尝试使用 svg-pan-zoom 库,当放大/缩小和鼠标拖动鼠标 x,y 位置出错时,想要更新它但不知道该怎么做。这就是我创建 svgPanZoom 的方式:
panZoom(x,y){
this.panZoomResizer = svgPanZoom('svg',{
viewportSelector: '.svg-pan-zoom_viewport'
, panEnabled: true
, controlIconsEnabled: false
, zoomEnabled: true
, dblClickZoomEnabled: false
, mouseWheelZoomEnabled: true
, controlIconsEnabled: false
, preventMouseEventsDefault: true
, zoomScaleSensitivity: 0.4
, minZoom: 0.5
, maxZoom: 10
, fit: true
, contain: false
, center: true
, eventsListenerElement: document.querySelector('svg .svg-pan-zoom_viewport')
});
}
并想发送值来更新视图框,但不知道如何设置它。
const distX = (snap.xMouse - this.fp.posX);
const distY = (snap.yMouse - this.fp.posY);
this.panZoom(distX, distY);