From b74aba6e80d59d8bff1ac5bde6ff0ef8f2e4ac50 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Fri, 22 Feb 2013 10:54:03 +0900 Subject: [PATCH] scrollview: adds support x axis gesture scroll Change-Id: Icf6c3d5a2199d998b8cdb29f3ddcda36055f676c --- src/js/jquery.mobile.tizen.scrollview.js | 34 ++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) 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; } -- 2.7.4