-
I am trying to achieve something similar to Prezi presentation software. Basically having a number of bookmarks to objects on the canvas. When the user goes/jumps between the bookmarks the viewport will 1) pan smoothly to the next object 2) meantime scale the viewport so that the object fits (horizontally or vertically whichever makes the object fit) Is this possible and does anyone already have an example of this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
Is for sure possible, you have 2 tasks, calculating the destination viewport and then animating it. you can use fabric.util.calcScaleToFit to get the zoom level, passing as destination the canvas and source the object.getBoundingRect. I m not entirely sure but a combination of those things will do the trick. |
Beta Was this translation helpful? Give feedback.
Is for sure possible, you have 2 tasks, calculating the destination viewport and then animating it.
To animate a viewport is sufficient to animate the 6 numbers that are part of it.
To calculate the destination viewport, that may be a little effort on your side to understand positioning and geometries.
you can use fabric.util.calcScaleToFit to get the zoom level, passing as destination the canvas and source the object.getBoundingRect.
For the panning, i think the final panning will be something like the object.getCenterPoint() to which you have to subtract half of the canvas dimensions.
I m not entirely sure but a combination of those things will do the trick.