简体   繁体   English

CSS Zoom不影响Javascript添加的SVG元素

[英]CSS Zoom not affecting SVG elements added by Javascript

We have an issue which appears to happen on old versions of WebKit (iOS5 for example) where adding svg + svgText elements using javascript, like so: 我们遇到了一个问题,该问题似乎发生在旧版本的WebKit(例如iOS5)上,其中使用javascript添加svg + svgText元素,如下所示:

var box =  document.createElementNS("http://www.w3.org/2000/svg","svg");
var text = document.createElementNS("http://www.w3.org/2000/svg","text");

which is then inside a div with zoom set, the svgTexts are not scaled down or up by the zoom like every other element (including svg graphics etc). 然后在具有缩放设置的div内,svgTexts不会像其他所有元素一样(包括svg图形等)被缩放缩放或放大。

I've confirmed that simply taking the generated html from the DOM and adding that directly results in the zoom being correctly applied, so its a problem in the way text elements are added by javascript not being affected by the zoom for some reason. 我已经确认,简单地从DOM中获取生成的html并添加直接导致正确应用缩放,因此这是javascript添加文本元素的方式由于某种原因而不受缩放影响的问题。

Has anyone encountered a similar problem & has any ideas? 有没有人遇到过类似的问题并且有什么想法?

Thanks for any thoughts! 感谢您的任何想法!

I've come across the same problem. 我遇到了同样的问题。 Simply updating the view box worked for me. 只需更新视图框就对我有用。 My tests with different tablets have shown that this issue was fixed with WebKit version 535 or 536. 我对不同平板电脑的测试表明,此问题已通过WebKit 535或536版修复。

I'm using the following in Raphael: pPaper.setViewBox( 0, 0, pPaper.width, pPaper.height ); 我在Raphael中使用以下内容:pPaper.setViewBox(0,0,pPaper.width,pPaper.height);

Since I'm using a slider for zooming and resetting the viewbox takes a lot of time, I'm checking the browser version and only apply it if necessary. 由于我使用滑块缩放和重置视图框需要花费大量时间,因此我正在检查浏览器版本,并仅在必要时应用它。 You might want to write a feature check instead if you have the time. 如果有时间,您可能想编写功能检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM