feat(Swipe): pause autoplay when page hidden

This commit is contained in:
陈嘉涵
2020-01-16 10:56:45 +08:00
parent 60173dd6bc
commit 11315787ec
2 changed files with 40 additions and 2 deletions
+9
View File
@@ -12,6 +12,7 @@ export default createComponent({
TouchMixin,
BindEventMixin(function(bind, isBind) {
bind(window, 'resize', this.resize, true);
bind(window, 'visibilitychange', this.onVisibilityChange);
if (isBind) {
this.initialize();
@@ -165,6 +166,14 @@ export default createComponent({
this.initialize(this.activeIndicator);
},
onVisibilityChange() {
if (document.hidden) {
this.clear();
} else {
this.autoPlay();
}
},
onTouchStart(event) {
if (!this.touchable) return;