From 654b1965c441860f6be95ae77a8c728d939dd6c2 Mon Sep 17 00:00:00 2001 From: zhoulin Date: Wed, 9 Mar 2016 18:00:37 +0800 Subject: [PATCH 1/2] add VUPBoundary VDOWNboundary options so that pull-refresh is possible when content does not overflow the wrapper --- src/core.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index dcfab624..be229034 100644 --- a/src/core.js +++ b/src/core.js @@ -23,7 +23,10 @@ function IScroll (el, options) { HWCompositing: true, useTransition: true, - useTransform: true + useTransform: true, + + VUPBoundary:true, //true : respect v-boundary when not overflow, false: can scroll when not overflow + VDOWNboundary:true, }; for ( var i in options ) { @@ -213,7 +216,15 @@ IScroll.prototype = { } deltaX = this.hasHorizontalScroll ? deltaX : 0; - deltaY = this.hasVerticalScroll ? deltaY : 0; + + // Still scroll when wrapper is not over-flow by scroller + if(!this.options.VUPBoundary && deltaY < 0) { + deltaY = deltaY; + }else if(!this.options.VDOWNboundary && deltaY > 0) { + deltaY = deltaY; + }else { + deltaY = this.hasVerticalScroll ? deltaY : 0; + } newX = this.x + deltaX; newY = this.y + deltaY; From c8dfeae25ac72a95d1e789110d22191181ed92e9 Mon Sep 17 00:00:00 2001 From: eeandrew Date: Tue, 27 Dec 2016 16:31:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?iscroll=E6=BB=9A=E5=8A=A8=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/iscroll-infinite.js | 23 ++++++++++++++++++++--- build/iscroll-lite.js | 23 ++++++++++++++++++++--- build/iscroll-probe.js | 23 ++++++++++++++++++++--- build/iscroll-zoom.js | 23 ++++++++++++++++++++--- build/iscroll.js | 23 ++++++++++++++++++++--- src/core.js | 6 ++++++ 6 files changed, 106 insertions(+), 15 deletions(-) diff --git a/build/iscroll-infinite.js b/build/iscroll-infinite.js index 10170f69..6720fd67 100644 --- a/build/iscroll-infinite.js +++ b/build/iscroll-infinite.js @@ -1,4 +1,4 @@ -/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ +/*! iScroll v5.1.3 ~ (c) 2008-2016 Matteo Spinelli ~ http://cubiq.org/license */ (function (window, document, Math) { var rAF = window.requestAnimationFrame || window.webkitRequestAnimationFrame || @@ -276,7 +276,10 @@ function IScroll (el, options) { HWCompositing: true, useTransition: true, - useTransform: true + useTransform: true, + + VUPBoundary:true, //true : respect v-boundary when not overflow, false: can scroll when not overflow + VDOWNboundary:true, }; for ( var i in options ) { @@ -392,6 +395,10 @@ IScroll.prototype = { return; } + if (this.isAnimating || this.isInTransition) { + e.preventDefault(); + } + if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) { e.preventDefault(); } @@ -492,7 +499,15 @@ IScroll.prototype = { } deltaX = this.hasHorizontalScroll ? deltaX : 0; - deltaY = this.hasVerticalScroll ? deltaY : 0; + + // Still scroll when wrapper is not over-flow by scroller + if(!this.options.VUPBoundary && deltaY < 0) { + deltaY = deltaY; + }else if(!this.options.VDOWNboundary && deltaY > 0) { + deltaY = deltaY; + }else { + deltaY = this.hasVerticalScroll ? deltaY : 0; + } newX = this.x + deltaX; newY = this.y + deltaY; @@ -543,6 +558,8 @@ IScroll.prototype = { e.preventDefault(); } + this._execEvent('touchEnd'); + var point = e.changedTouches ? e.changedTouches[0] : e, momentumX, momentumY, diff --git a/build/iscroll-lite.js b/build/iscroll-lite.js index bd143b79..b1b924b0 100644 --- a/build/iscroll-lite.js +++ b/build/iscroll-lite.js @@ -1,4 +1,4 @@ -/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ +/*! iScroll v5.1.3 ~ (c) 2008-2016 Matteo Spinelli ~ http://cubiq.org/license */ (function (window, document, Math) { var rAF = window.requestAnimationFrame || window.webkitRequestAnimationFrame || @@ -269,7 +269,10 @@ function IScroll (el, options) { HWCompositing: true, useTransition: true, - useTransform: true + useTransform: true, + + VUPBoundary:true, //true : respect v-boundary when not overflow, false: can scroll when not overflow + VDOWNboundary:true, }; for ( var i in options ) { @@ -359,6 +362,10 @@ IScroll.prototype = { return; } + if (this.isAnimating || this.isInTransition) { + e.preventDefault(); + } + if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) { e.preventDefault(); } @@ -459,7 +466,15 @@ IScroll.prototype = { } deltaX = this.hasHorizontalScroll ? deltaX : 0; - deltaY = this.hasVerticalScroll ? deltaY : 0; + + // Still scroll when wrapper is not over-flow by scroller + if(!this.options.VUPBoundary && deltaY < 0) { + deltaY = deltaY; + }else if(!this.options.VDOWNboundary && deltaY > 0) { + deltaY = deltaY; + }else { + deltaY = this.hasVerticalScroll ? deltaY : 0; + } newX = this.x + deltaX; newY = this.y + deltaY; @@ -504,6 +519,8 @@ IScroll.prototype = { e.preventDefault(); } + this._execEvent('touchEnd'); + var point = e.changedTouches ? e.changedTouches[0] : e, momentumX, momentumY, diff --git a/build/iscroll-probe.js b/build/iscroll-probe.js index 538d0e38..1b2d4353 100644 --- a/build/iscroll-probe.js +++ b/build/iscroll-probe.js @@ -1,4 +1,4 @@ -/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ +/*! iScroll v5.1.3 ~ (c) 2008-2016 Matteo Spinelli ~ http://cubiq.org/license */ (function (window, document, Math) { var rAF = window.requestAnimationFrame || window.webkitRequestAnimationFrame || @@ -275,7 +275,10 @@ function IScroll (el, options) { HWCompositing: true, useTransition: true, - useTransform: true + useTransform: true, + + VUPBoundary:true, //true : respect v-boundary when not overflow, false: can scroll when not overflow + VDOWNboundary:true, }; for ( var i in options ) { @@ -390,6 +393,10 @@ IScroll.prototype = { return; } + if (this.isAnimating || this.isInTransition) { + e.preventDefault(); + } + if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) { e.preventDefault(); } @@ -490,7 +497,15 @@ IScroll.prototype = { } deltaX = this.hasHorizontalScroll ? deltaX : 0; - deltaY = this.hasVerticalScroll ? deltaY : 0; + + // Still scroll when wrapper is not over-flow by scroller + if(!this.options.VUPBoundary && deltaY < 0) { + deltaY = deltaY; + }else if(!this.options.VDOWNboundary && deltaY > 0) { + deltaY = deltaY; + }else { + deltaY = this.hasVerticalScroll ? deltaY : 0; + } newX = this.x + deltaX; newY = this.y + deltaY; @@ -541,6 +556,8 @@ IScroll.prototype = { e.preventDefault(); } + this._execEvent('touchEnd'); + var point = e.changedTouches ? e.changedTouches[0] : e, momentumX, momentumY, diff --git a/build/iscroll-zoom.js b/build/iscroll-zoom.js index 4faccdfc..ea739e46 100644 --- a/build/iscroll-zoom.js +++ b/build/iscroll-zoom.js @@ -1,4 +1,4 @@ -/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ +/*! iScroll v5.1.3 ~ (c) 2008-2016 Matteo Spinelli ~ http://cubiq.org/license */ (function (window, document, Math) { var rAF = window.requestAnimationFrame || window.webkitRequestAnimationFrame || @@ -278,7 +278,10 @@ function IScroll (el, options) { HWCompositing: true, useTransition: true, - useTransform: true + useTransform: true, + + VUPBoundary:true, //true : respect v-boundary when not overflow, false: can scroll when not overflow + VDOWNboundary:true, }; for ( var i in options ) { @@ -396,6 +399,10 @@ IScroll.prototype = { return; } + if (this.isAnimating || this.isInTransition) { + e.preventDefault(); + } + if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) { e.preventDefault(); } @@ -496,7 +503,15 @@ IScroll.prototype = { } deltaX = this.hasHorizontalScroll ? deltaX : 0; - deltaY = this.hasVerticalScroll ? deltaY : 0; + + // Still scroll when wrapper is not over-flow by scroller + if(!this.options.VUPBoundary && deltaY < 0) { + deltaY = deltaY; + }else if(!this.options.VDOWNboundary && deltaY > 0) { + deltaY = deltaY; + }else { + deltaY = this.hasVerticalScroll ? deltaY : 0; + } newX = this.x + deltaX; newY = this.y + deltaY; @@ -541,6 +556,8 @@ IScroll.prototype = { e.preventDefault(); } + this._execEvent('touchEnd'); + var point = e.changedTouches ? e.changedTouches[0] : e, momentumX, momentumY, diff --git a/build/iscroll.js b/build/iscroll.js index 8bd2b8da..909e1f86 100644 --- a/build/iscroll.js +++ b/build/iscroll.js @@ -1,4 +1,4 @@ -/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ +/*! iScroll v5.1.3 ~ (c) 2008-2016 Matteo Spinelli ~ http://cubiq.org/license */ (function (window, document, Math) { var rAF = window.requestAnimationFrame || window.webkitRequestAnimationFrame || @@ -275,7 +275,10 @@ function IScroll (el, options) { HWCompositing: true, useTransition: true, - useTransform: true + useTransform: true, + + VUPBoundary:true, //true : respect v-boundary when not overflow, false: can scroll when not overflow + VDOWNboundary:true, }; for ( var i in options ) { @@ -387,6 +390,10 @@ IScroll.prototype = { return; } + if (this.isAnimating || this.isInTransition) { + e.preventDefault(); + } + if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) { e.preventDefault(); } @@ -487,7 +494,15 @@ IScroll.prototype = { } deltaX = this.hasHorizontalScroll ? deltaX : 0; - deltaY = this.hasVerticalScroll ? deltaY : 0; + + // Still scroll when wrapper is not over-flow by scroller + if(!this.options.VUPBoundary && deltaY < 0) { + deltaY = deltaY; + }else if(!this.options.VDOWNboundary && deltaY > 0) { + deltaY = deltaY; + }else { + deltaY = this.hasVerticalScroll ? deltaY : 0; + } newX = this.x + deltaX; newY = this.y + deltaY; @@ -532,6 +547,8 @@ IScroll.prototype = { e.preventDefault(); } + this._execEvent('touchEnd'); + var point = e.changedTouches ? e.changedTouches[0] : e, momentumX, momentumY, diff --git a/src/core.js b/src/core.js index be229034..6fe5b541 100644 --- a/src/core.js +++ b/src/core.js @@ -116,6 +116,10 @@ IScroll.prototype = { return; } + if (this.isAnimating || this.isInTransition) { + e.preventDefault(); + } + if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) { e.preventDefault(); } @@ -269,6 +273,8 @@ IScroll.prototype = { e.preventDefault(); } + this._execEvent('touchEnd'); + var point = e.changedTouches ? e.changedTouches[0] : e, momentumX, momentumY,