From: Minkyu Kang Date: Fri, 22 Feb 2013 01:54:03 +0000 (+0900) Subject: scrollview: adds support x axis gesture scroll X-Git-Tag: accepted/tizen_2.1/20130425.023924~7^2~55 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b74aba6e80d59d8bff1ac5bde6ff0ef8f2e4ac50;p=platform%2Fframework%2Fweb%2Fweb-ui-fw.git scrollview: adds support x axis gesture scroll Change-Id: Icf6c3d5a2199d998b8cdb29f3ddcda36055f676c --- diff --git a/src/js/jquery.mobile.tizen.scrollview.js b/src/js/jquery.mobile.tizen.scrollview.js index 3572c13..cadff6d 100644 --- a/src/js/jquery.mobile.tizen.scrollview.js +++ b/src/js/jquery.mobile.tizen.scrollview.js @@ -813,13 +813,23 @@ define( [ ], function ( ) { self._gesture_dir = 0; self._gesture_count = 0; self._gesture_timer = undefined; + }, + direction = { + top: 0, + bottom: 1, + left: 2, + right: 3 }; - if ( !sy ) { + if ( !sy && !sx ) { return false; } - dir = sy > 0 ? 1 : -1; + if ( Math.abs( sx ) > Math.abs( sy ) ) { + dir = sx > 0 ? direction.left : direction.right; + } else { + dir = sy > 0 ? direction.top : direction.bottom; + } if ( !this._gesture_timer ) { this._gesture_count = 1; @@ -840,13 +850,25 @@ define( [ ], function ( ) { this._gesture_count++; if ( this._gesture_count === 3 ) { - if ( dir > 0 ) { - this.scrollTo( 0, 0, this.options.overshootDuration ); - } else { - this.scrollTo( 0, -( this._getViewHeight() - this._$clip.height() ), + switch ( dir ) { + case direction.top: + this.scrollTo( this._sx, 0, this.options.overshootDuration ); + break; + case direction.bottom: + this.scrollTo( this._sx, -( this._getViewHeight() - this._$clip.height() ), this.options.overshootDuration ); + break; + case direction.left: + this.scrollTo( 0, this._sy, this.options.overshootDuration ); + break; + case direction.right: + this.scrollTo( -( this._$view.width() - this._$clip.width() ), this._sy, + this.options.overshootDuration ); + break; } + reset(); + this._didDrag = true; return true; }