Note that there are some explanatory texts on larger screens.

plurals
  1. POSet viewBox(with Raphael) on mouse wheel to zoom in/out
    primarykey
    data
    text
    <p>I have drawn few shapes like rectangle and circle using Raphael. Here: <a href="http://jsfiddle.net/Ta8jQ/65/" rel="nofollow">http://jsfiddle.net/Ta8jQ/65/</a></p> <p>The zoom function is show below: </p> <pre><code>function doZoom(coords, factor) { //transform real coordinates into viewbox coordinates debugger; x = Number(viewbox[0]) + Number(coords.x / zoom); y = Number(viewbox[1]) + Number(coords.y / zoom); if (factor &lt; 0) { factor = 0.95; } else { factor = 1.05; } var z = ((zoom || 1) * factor) || 1; zoom = z; //zoom viewbox dimensions viewbox[2] = bbox.width / zoom; viewbox[3] = bbox.height / zoom; //transform coordinates to new viewbox coordinates viewbox[0] = x - coords.x / zoom; viewbox[1] = y - coords.y / zoom; paper.setViewBox.apply(paper, viewbox,true); } </code></pre> <p>I have a "<strong>Fit to Screen</strong>" button which shows all the shapes if it is drawn beyond the viewport (i.e visible drawing area). The "Fourth Circle" is a circle which has center (-50,-50). So on click "Fit to screen" all the shaped are visible.</p> <p>Also zoom in and out is implemented on mouse wheel, but the problem I faced is: before Fit to Screen" button is clicked the zoom in/out on mouse wheel works fine. But as I click on Fit to screen button, and try to zoom at any point..there is sudden change in the zoom level. Say if you have first zoom out and clicked Fit to Screen and try to zoom First Circle using mouse wheel. The zoom is at the previous state(i.e zoom out state).But i need to zoom first circle as my mouse pointer is poiting First circle from the current zoom level(i.e Stretch Level of zoom).</p> <p>Any help is appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload