raphael js setViewBox didn't resize my paper

匿名 (未验证) 提交于 2019-12-03 01:46:01

问题:

I have a problem with setViewBox on raphael, The paper isn't resized even if I did myPaper.setViewBox(0, 0, new_map_width, new_map_height,true); (Line 9 on the JS code)

Nb : new_map_width = 400 and new_map_height=300 and the map is at 800*600

this is my code : http://jsfiddle.net/xperali/zdbzJ/

回答1:

I found the solution, I have to execute my setViewBox method after drawing all the paths, and use some math skills :)

var original_width = 777; var original_height = 667; var zoom_width = map_width/original_width; var zoom_height = map_height/original_height; if(zoom_width<=zoom_height)    zoom = zoom_width; else    zoom = zoom_height; rsr.setViewBox($("#"+map_name).offset().left, $("#"+map_name).offset().top, (map_width/zoom), (map_height/zoom)); 


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