From 5f0a1703f7773ba3c9ff05342b82d39bc512380b Mon Sep 17 00:00:00 2001 From: rguanghui Date: Fri, 29 Jan 2016 17:16:42 +0800 Subject: [PATCH] not animate when single --- example/index.html | 30 +++++++++++++++++++++--------- src/swipe.vue | 11 +++++++++-- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/example/index.html b/example/index.html index 3376b16..de76a3e 100644 --- a/example/index.html +++ b/example/index.html @@ -10,30 +10,42 @@ .swipe { height: 200px; color: #fff; + font-size: 30px; + text-align: center; } .page1 { - background-color: blue; + background-color: #0089dc; + color: #fff; } .page2 { - background-color: yellow; + background-color: #ffd705; color: #000; } .page3 { - background-color: red; + background-color: #ff2d4b; + color: #fff; } - SUPER BLUE!! - SUPER YELLOW!! - SUPER RED!! + 饿了么 + 美团 + 百度 + +
+ - SUPER BLUE!! - SUPER YELLOW!! - SUPER RED!! + SINGLE PAGE + + +
+ + + SINGLE PAGE + diff --git a/src/swipe.vue b/src/swipe.vue index e783ec9..ff65c70 100644 --- a/src/swipe.vue +++ b/src/swipe.vue @@ -125,6 +125,11 @@ default: true }, + noDragWhenSingle: { + type: Boolean, + default: true + }, + prevent: { type: Boolean, default: false @@ -414,6 +419,10 @@ }, this.auto); } + this.reInitPages(); + + if (this.$children.length === 1 && this.noDragWhenSingle) return; + var element = this.$el; element.addEventListener('touchstart', (event) => { @@ -435,8 +444,6 @@ this.doOnTouchEnd(event); this.dragging = false; }); - - this.reInitPages(); } };