svg path rendering speed

吃可爱长大的小学妹 提交于 2019-12-10 12:18:48

问题


There are about 6000 svg path elements. Each is like:

<path fill="none" d="M -1180.753662,3450.687500 C -1183.848267,3258.348389              
-899.981628, 2965.197998 -707.642639,2962.103516" stroke="#8f87a8"/>

I am using d3 translate and scale events to pan and zoom the whole svg. http://bl.ocks.org/mbostock/3680999 It seems that html page has to re-render all of them with each pan or zoom, and that make the action quite sluggish.

Is there anyway that I can make pan and zoom smoother in theory?


回答1:


Use CSS3 transformations.

Mike Bostock has an example of a zoomable map and uses CSS3 translation and scaling to achieve smooth zooming. This approach has drawbacks: if your zoomed container has text, it will get "zoomed in" as well. But this might not matter to you or you can work around it.



来源:https://stackoverflow.com/questions/17907769/svg-path-rendering-speed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!