Skip to content

Commit

Permalink
fix(ui/swipe): the screen size changes, the size of the carousel will…
Browse files Browse the repository at this point in the history
… not change (#112)

affects: @varlet/ui
  • Loading branch information
haoziqaq committed Jul 31, 2021
1 parent 59f5aaa commit 7110457
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/varlet-ui/src/swipe/Swipe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</template>

<script lang="ts">
import { defineComponent, ref, computed, watch, onUnmounted } from 'vue'
import { defineComponent, ref, computed, watch, onMounted, onUnmounted } from 'vue'
import { useSwipeItems } from './provide'
import { nextTickFrame } from '../utils/elements'
import { props } from './props'
Expand Down Expand Up @@ -352,7 +352,14 @@ export default defineComponent({
watch(() => length.value, resize)
onUnmounted(stopAutoplay)
onMounted(() => {
window.addEventListener('resize', resize)
})
onUnmounted(() => {
window.removeEventListener('resize', resize)
stopAutoplay()
})
return {
length,
Expand Down

0 comments on commit 7110457

Please sign in to comment.