raphael js, calculate setViewBox width height to fix window

后端 未结 1 1418
逝去的感伤
逝去的感伤 2021-01-26 11:49

My div content canvas in first width : 1300, height = 500

Then I resize div to width = 800, height = 500

相关标签:
1条回答
  • 2021-01-26 12:15

    try this code (you have to include jquery + raphael js 2.x) :

    var original_width = 777;
    var original_height = 667;
    var zoom_width = map_width*100/original_width/100;
    var zoom_height = map_height*100/original_height/100;
    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));
    
    0 讨论(0)
提交回复
热议问题