Skip to content

Commit

Permalink
fix: pi-marquee动画暂停
Browse files Browse the repository at this point in the history
  • Loading branch information
sadais-lwt committed Aug 19, 2021
1 parent 786bcbe commit aa48fd7
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions components/pi-marquee/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
@mouseenter="handlePause"
@mouseleave="handleStart"
>
<div class="inner" :style="animateTime">
<!-- 默认插槽:放置pi-marquee-item -->
<div class="inner" :style="animate">
<slot />
</div>
<div v-if="showCopy" class="inner" :style="animateTime">
<div v-if="showCopy" class="inner" :style="animate">
<slot />
</div>
</div>
Expand All @@ -33,7 +32,7 @@ export default {
// 动画移动速度:每毫秒移动多少像素
speed: {
type: Number,
// 0.2s
// 0.2px
default: marquee.speed
},
// 是否支持鼠标移上去暂停滚动
Expand All @@ -46,7 +45,7 @@ export default {
data() {
return {
children: [],
animateTime: '',
animate: {},
showCopy: false
}
},
Expand Down Expand Up @@ -79,7 +78,7 @@ export default {
if (!this.hoverPause) {
return
}
this.animateTime = 'animation: none'
this.$set(this.animate, 'animationPlayState', 'paused')
},
/**
* @vuese
Expand All @@ -90,7 +89,7 @@ export default {
if (!this.hoverPause) {
return
}
this.updateTime()
this.$set(this.animate, 'animationPlayState', 'running')
},
updateTime() {
this.$nextTick(() => {
Expand All @@ -109,16 +108,16 @@ export default {
this.showCopy = false
} else {
const time = inner.offsetWidth / this.speed / 1000
this.animateTime = `animation-duration: ${time}s`
this.$set(this.animate, 'animationDuration', `${time}s`)
this.showCopy = true
}
} else {
if (inner.offsetHeight <= containerHeight) {
this.animateTime = 'animation: none'
this.$set(this.animate, 'animationPlayState', 'paused')
this.showCopy = false
} else {
const time = inner.offsetHeight / this.speed / 1000
this.animateTime = `animation-duration: ${time}s`
this.$set(this.animate, 'animationDuration', `${time}s`)
this.showCopy = true
}
}
Expand Down

0 comments on commit aa48fd7

Please sign in to comment.