Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElshad Seyidmammadov2016-05-04 04:31:01 -0400
committerIvan Furnadjiev2016-05-11 03:55:48 -0400
commit44d31c6f9ea7b7d981d19df67114215bd3b2679c (patch)
tree80b5eb1bec42ed8d9ae499afd2e3e3098b7a0520 /bundles
parentc482d11e474f14a9ac87570719d01673d69a053b (diff)
downloadorg.eclipse.rap-44d31c6f9ea7b7d981d19df67114215bd3b2679c.tar.gz
org.eclipse.rap-44d31c6f9ea7b7d981d19df67114215bd3b2679c.tar.xz
org.eclipse.rap-44d31c6f9ea7b7d981d19df67114215bd3b2679c.zip
Grid scrolling doesn't work correctly in mobile browsers
In Mobile browsers when grid-view scrolling is enabled, the grid-view cannot be scrolled correctly by touch moving. The scrolling position calculated wrongly. Although Grid item position properties work with indexes, MobileWebkitSupport updated them with pixels. Convert pixels to index in MobileWebkitSupport for GridRowContainer. Change some test result variables in MobileWebkitSupportTest, which tested with pixels. Change-Id: I8ec91b59104816d897f38bb659333a1f341a9036 Signed-off-by: Elshad Seyidmammadov <elshad@eclipsesource.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.rap.rwt/js/rwt/runtime/MobileWebkitSupport.js54
1 files changed, 35 insertions, 19 deletions
diff --git a/bundles/org.eclipse.rap.rwt/js/rwt/runtime/MobileWebkitSupport.js b/bundles/org.eclipse.rap.rwt/js/rwt/runtime/MobileWebkitSupport.js
index 24a0cd1cd0..c0fa501ad3 100644
--- a/bundles/org.eclipse.rap.rwt/js/rwt/runtime/MobileWebkitSupport.js
+++ b/bundles/org.eclipse.rap.rwt/js/rwt/runtime/MobileWebkitSupport.js
@@ -327,7 +327,9 @@ rwt.runtime.MobileWebkitSupport = {
result.drag = true;
} else if( this._isGridRowContainer( widgetTarget ) ) {
result.virtualScroll = true;
- result.outerScroll = this._allowNativeScroll && this._isScrollableWidget( widgetTarget );
+ var hasOuterScrollable
+ = this._isScrollableWidget( widgetTarget ) || this._isClientDocumentScrollingEnabled();
+ result.outerScroll = this._allowNativeScroll && hasOuterScrollable;
} else if( this._allowNativeScroll && this._isScrollableWidget( widgetTarget ) ) {
result.scroll = true;
} else if( this._isFocusable( widgetTarget ) ) {
@@ -351,11 +353,9 @@ rwt.runtime.MobileWebkitSupport = {
var scrollBarV = scrollable._vertScrollBar;
var scrollBarH = scrollable._horzScrollBar;
this._touchSession.scrollBarV = scrollBarV;
- this._touchSession.initScrollY = scrollBarV.getValue();
- this._touchSession.maxScrollY = scrollBarV.getMaximum();
+ this._touchSession.initScrollY = this._getScrollYOffset( scrollBarV );
this._touchSession.scrollBarH = scrollBarH;
this._touchSession.initScrollX = scrollBarH.getValue();
- this._touchSession.maxScrollX = scrollBarH.getMaximum();
},
_handleVirtualScroll : function( pos ) {
@@ -364,23 +364,42 @@ rwt.runtime.MobileWebkitSupport = {
var offsetY = oldPos[ 1 ] - pos[ 1 ];
var newX = this._touchSession.initScrollX + offsetX;
var newY = this._touchSession.initScrollY + offsetY;
- var max = this._touchSession.scrollBarV.getMaximum()
- - this._touchSession.scrollBarV._thumbLength;
- var nudged = newY < 0 || newY > max;
+ var max = this._touchSession.scrollBarV.getMaximum() - this._touchSession.scrollBarV.getThumb();
+ var adaptedNewY = this._adaptScrollYOffset( newY );
+ var nudged = newY < 0 || adaptedNewY > max;
if( this._touchSession.type.outerScroll && nudged ) {
var outer = this._findScrollable( this._touchSession.widgetTarget );
- var outerValue = outer._vertScrollBar.getValue();
- var outerMax = outer._vertScrollBar.getMaximum()
- - outer._vertScrollBar._thumbLength;
- if( ( newY < 0 && outerValue > 0 )
- || ( newY > max && outerValue < outerMax ) )
- {
+ if( outer == null ) {
delete this._touchSession.type.virtualScroll;
this._touchSession.type.scroll = true;
+ } else {
+ var outerValue = outer._vertScrollBar.getValue();
+ var outerMax = outer._vertScrollBar.getMaximum() - outer._vertScrollBar.getThumb();
+ if( ( newY < 0 && outerValue > 0 ) || ( adaptedNewY > max && outerValue < outerMax ) ) {
+ delete this._touchSession.type.virtualScroll;
+ this._touchSession.type.scroll = true;
+ }
}
}
this._touchSession.scrollBarH.setValue( newX );
- this._touchSession.scrollBarV.setValue( newY );
+ this._touchSession.scrollBarV.setValue( adaptedNewY );
+ },
+
+ _adaptScrollYOffset : function( scrollY ) {
+ if( this._isGridRowContainer( this._touchSession.widgetTarget ) ) {
+ var grid = this._touchSession.widgetTarget.getParent();
+ var item = grid.getRootItem().findItemByOffset( scrollY );
+ return item ? item.getFlatIndex() : 0;
+ }
+ return scrollY ;
+ },
+
+ _getScrollYOffset : function( scrollBar ) {
+ if( this._isGridRowContainer( this._touchSession.widgetTarget ) ) {
+ var grid = this._touchSession.widgetTarget.getParent();
+ return grid._getTopItem().getOffset();
+ }
+ return scrollBar.getValue();
},
_finishVirtualScroll : function() {
@@ -406,17 +425,14 @@ rwt.runtime.MobileWebkitSupport = {
_isSelectableWidget : function( widgetTarget ) {
var result = false;
- if( widgetTarget instanceof rwt.widgets.ListItem
- || this._isGridRowContainer( widgetTarget ) )
- {
+ if( widgetTarget instanceof rwt.widgets.ListItem || this._isGridRowContainer( widgetTarget ) ) {
result = true;
}
return result;
},
_isClientDocumentScrollingEnabled : function() {
- var doc = rwt.widgets.base.ClientDocument.getInstance();
- var overflow = doc.getOverflow();
+ var overflow = rwt.widgets.base.ClientDocument.getInstance().getOverflow();
return overflow && overflow !== "hidden";
},

Back to the top