thecodealer / vue-panzoom

Vue plugin to zoom/pan dom elements
MIT License
89 stars 20 forks source link

Init after loading dynamic data #15

Closed theveloped closed 4 years ago

theveloped commented 4 years ago

Great work on this component! I'm wondering if it is possible to programmatically initialize the components. I have a SVG image that I embed dynamically using v-html and I'm hoping to use your component like so:

<panZoom selector="#container"> -->
    <div v-html="svg_data"></div>
</panZoom>

At the moment however I get this error:

[Vue warn]: Error in mounted hook: "TypeError: screenCTM is null"

Is it possible to programmatically initialize panZoom once I now the DOM has rendered SVG data?

mistabiggx commented 4 years ago

You could use v-if on the component so it's only initialised when your svg is ready. Like so

<panZoom v-if="svg_data" selector="#container"> -->
    <div v-html="svg_data"></div>
</panZoom>
theveloped commented 4 years ago

Thank you for the fast solution! Again thanks for the great project :)