How can I init panzoom globally?
See original GitHub issueHello, how can I init panzoom globally? I’m trying to implement this plugin to work with flickity.js, so I’ve forked this plugin a bit. I have 2 different events on 2 different buttons, and it will work bad(e.g. animations doesn’t work, can’t destroy panzoom on zoomout event, etc) if I init panzoom twice, like I did for now:
proto.inZoom = function() { // This is forked line from flickity-fullscreen.js, line 64
this._changeZoom( true );
this.focus();
const elem = document.querySelector('.is-selected')
const panzoom = Panzoom(elem, {
maxScale: 3,
minScale: 1,
panOnlyWhenZoomed: true,
overflow: 'visible',
contain: 'outside',
})
panzoom.pan(0, 0)
panzoom.zoom(3, { animate: true})
this.element.addEventListener('click', panzoom.zoomIn)
};
proto.outZoom = function() {
this._changeZoom( false );
const elem = document.querySelector('.is-selected')
const panzoom = Panzoom(elem, {
maxScale: 3,
minScale: 1,
panOnlyWhenZoomed: true,
overflow: 'visible',
})
panzoom.pan(0, 0)
this.element.addEventListener('click', panzoom.zoomOut)
};
Related issue: #480
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
panzoom/README.md at main - GitHub
One exception is force , which can only be passed to methods like pan() or zoom() , but not Panzoom() or setOptions() as...
Read more >How to set Jquery panzoom default zoom? - Stack Overflow
Either call zoom() right after initialization $elem.panzoom("zoom", 1.1, {silent: true}) // +10%. Or set a value for startTransform in the ...
Read more >@panzoom/panzoom - npm
Start using @panzoom/panzoom in your project by running `npm i @panzoom/panzoom`. ... or setOptions (to avoid setting this option globally).
Read more >Add Data, Pan, Zoom, Identify - CGA Web Maps
Add Data, Pan, Zoom, Identify. We must first add a layer of data to use the map navigation controls in QGIS. Go to...
Read more >Pan/Zoom to selected features in Python Add-in
Pan/Zoom to selected features in Python Add-in ... """Implementation for MRPAssistant_addin.panbutton (Button)""" def __init__(self): ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Panzoom seemed to already be available globally in your fiddle. However, since you are using UMD, I suggest adding Panzoom as one of your dependencies.
https://jsfiddle.net/timmywil/1jxgak02/9/
I went ahead and edited your zoom functions as well to fit what I think you’re going for.
Thanks for the help! I managed to fix this problem by creating function which initializes panzoom. See this fiddle.