-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I get the current zoom level on each onZoom? #8
Comments
I've created an example at https://github.com/yanick/vue-svg-pan-zoom/blob/zoom/src/zoom.stories.vue |
Thanks for the reply! Here's what I tried... <template>
<SvgPanZoom
v-if="provinces.length > 0"
@svgpanzoom="registerSvgPanZoom"
:onZoom="onZoom()"
@onPan="onPan()"
class="h-full w-full"
:zoomEnabled="true"
:mouseWheelZoomEnabled="false"
:controlIconsEnabled="true"
:zoomScaleSensitivity="2"
:minZoom="1"
:maxZoom="5"
>
<svg>blah</svg>
</SvgPanZoom>
</template>
<script>
import SvgPanZoom from 'vue-svg-pan-zoom';
export default {
name: 'TheMap',
components: { SvgPanZoom },
data() {
return {
svgpanzoom: null,
zoomLevel: null,
}
},
methods: {
registerSvgPanZoom(svgpanzoom) {
this.svgpanzoom = svgpanzoom;
},
onZoom(zoomFactor) {
this.zoomLevel = zoomFactor[0];
},
}
}
</script> Changing EDIT I changed |
Unrelated, but if my |
Ah, I have at least one problem with your example:
that should be
I.e., you need to pass the function callback, and what you did was to execute the function (with no arg) as you were creating the component. |
I'm having trouble trying to figure out how I can get a hold of what the current zoom level is.
I tried registering the
svgpanzoom
object and using an@onZoom
event then tried to accessthis.svgpanzoom.getZoom()
. That didn't work. theonZoom
actually returns nothing, not even a dummyconsole.log
.When I create a
zoomLevel
computed property and assign itthis.svgpanzoom.getZoom()
it does start with the minZoom of1
that I gave it. But doesn't update as I zoom, which is why I tried to use theonZoom
event above.Am I going about this the wrong way?
The text was updated successfully, but these errors were encountered: