[英]SVG zoom on mouse wheel using svgcanvas in chrome
我正在尝试在鼠标滚轮上缩放svg。 在IE中工作正常,但在chrome中无法响应。 我的svg看起来像..样例..它不是确切的。
<svg width="1188" height="840" zoomAndPan="magnify" style="fill:none;stroke:black; font-size:4.07314px;stroke-width:0.509143" viewBox="0 0 1188 840">
<g id="XMP_1" style="stroke:#000000; stroke-width:0.339429">
<path d="M554 401L641 401" style="stroke:#0000FF; stroke-dasharray: 3.5640 3.5640 3.5640 3.5640"/>
</g>
</svg>
我的缩放功能如下:
var zoomToUserPoint = function (userPoint, zoomFactor) {
// This will usually cause a resize event, so we need to flag that it was caused by
// internal interaction with the SVG document.
currentView.internalResize = true;
// changing the scale will raise a zoom event (immediately)
// which will affect where the centre of the screen will be in user coordinates
if (zoomFactor !== 1) {
var newscale = applyScalingLimits(svgroot.currentScale * zoomFactor);
// THIS currentScale NEVER CHANGES IN CHROME
if (newscale !== svgroot.currentScale) {
svgroot.currentScale = newscale;
}
}
var currentScale = canvas.getScale();
// get the centre of the screen in user coordinates
var screenCentre = svgUtilities.screenCoordinateTransform(canvas.getScreenCentre(), svgroot);
// compute necessary change to current translation to centre screen point
svgroot.currentTranslate.x = svgroot.currentTranslate.x + (screenCentre.x - userPoint.x) / currentScale.x;
svgroot.currentTranslate.y = svgroot.currentTranslate.y + (screenCentre.y - userPoint.y) / currentScale.y;
// Cache the current view centre
//currentView.viewCentre = svgUtilities.screenCoordinateTransform(canvas.getScreenCentre(), svgroot);
// need to resize selector grips etc for any selected mark-up
canvas.resizeSelectors();
// Flag that we have finished with any interaction that may have caused a resize event
currentView.internalResize = false;
};
我试图找出问题所在,发现svg currentScale属性在Google Chrome中没有更改。
如何解决这个问题? 我现在很沮丧..根本没有修复... :(
一段时间以来,这一直是Chrome中的错误。
这是指向已注册的错误的链接, 网址为http://code.google.com/p/chromium/issues/detail?id=174568,但此错误之前已被注册为错误,因此已被忽略
该错误条目包含指向currentScale的SVG规范的链接和指向该问题的Plunker的链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.