Skip to content

Commit

Permalink
added reset method to gallery component
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisniu committed Apr 12, 2019
1 parent c52d4e2 commit ab0be92
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions demo/gallery/app.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template>
<div style="padding: 0px;">
<v-zoomer-gallery
style="width: 100vw; height: calc(100vh - 29px);"
ref="gallery"
style="width: 100vw; height: calc(100vh - 32px);"
:list="urlImageList"
v-model="selIndex"
></v-zoomer-gallery>
<div style="padding: 4px;">
<div style="box-sizing: border-box; height: 32px; padding: 4px;">
<button @click="$refs.gallery.reset()">reset</button>
<button
:disabled="selIndex === 0"
@click="selIndex -= 1"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-zoomer",
"version": "0.2.8",
"version": "0.2.9",
"description": "Zoom the image or other thing with mouse or touch",
"main": "dist/vue-zoomer.js",
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions src/vue-zoomer-gallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
>
<v-zoomer
v-for="(n, i) in 3"
ref="zoomers"
:key="i + selIndex"
:class="['left', 'middle', 'right'][i]"
class="slide"
Expand Down Expand Up @@ -100,6 +101,12 @@ export default {
window.removeEventListener('resize', this.onWindowResize)
},
methods: {
// api
reset () {
this.$refs.zoomers.forEach(zoomer => {
zoomer.reset()
})
},
// reactive
onWindowResize () {
let styles = window.getComputedStyle(this.$el)
Expand Down

0 comments on commit ab0be92

Please sign in to comment.