Last active
July 10, 2018 16:38
-
-
Save memandip/a49a6c37ad4c9bf0943f1ffe657d43ac to your computer and use it in GitHub Desktop.
svg-pan-zoom zoom to specific element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let options = { | |
panEnabled: true, | |
dragEnabled: true, | |
controlIconsEnabled: false, | |
zoomEnabled: true, | |
zoomScaleSensitivity: 0.2, | |
minZoom: 0.8, | |
maxZoom: 100000 | |
}; | |
let map = svgPanZoom('#svg-id', options); | |
let container = '#map-wrapper-container'; | |
let parentOffset = $(container).offset(); | |
position.top -= parentOffset.top; | |
position.left -= parentOffset.left; | |
let width = $(container).width(); | |
let height = $(container).height(); | |
map.panBy({x: width/2 - position.left, y: height/2 - position.top}); | |
map.zoom(zoomLevel); //zoomLevel can be any positive integer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment