public class TouchScrollDelegate extends Object implements com.google.gwt.user.client.Event.NativePreviewHandler
This is bit similar as Scroller class in GWT expenses example, but ideas drawn from iscroll.js project:
Scroll event should only happen when the "touch scrolling actually ends". Later we might also tune this so that a scroll event happens if user stalls her finger long enought. TODO static getter for active touch scroll delegate. Components might need to prevent scrolling in some cases. Consider Table with drag and drop, or drag and drop in scrollable area. Optimal implementation might be to start the drag and drop only if user keeps finger down for a moment, otherwise do the scroll. In this case, the draggable component would need to cancel scrolling in a timer after touchstart event and take over from there. TODO support scrolling horizontally TODO cancel if user add second finger to the screen (user expects a gesture). TODO "scrollbars", see e.g. iscroll.js TODO write an email to sjobs ?§t apple dot com and beg for this feature to be built into webkit. Seriously, we should try to lobbying this to webkit folks. This sure ain't our business to implement this with javascript. TODO collect all general touch related constant to better place.
Modifier and Type | Class and Description |
---|---|
static class |
TouchScrollDelegate.TouchScrollHandler
A helper class for making a widget scrollable.
|
Modifier and Type | Field and Description |
---|---|
static int |
SIGNIFICANT_MOVE_THRESHOLD |
Constructor and Description |
---|
TouchScrollDelegate(com.google.gwt.dom.client.Element... elements) |
Modifier and Type | Method and Description |
---|---|
static TouchScrollDelegate.TouchScrollHandler |
enableTouchScrolling(com.google.gwt.user.client.ui.Widget widget,
com.google.gwt.dom.client.Element... scrollables)
Makes the given elements scrollable, either natively or by using a
TouchScrollDelegate, depending on platform capabilities.
|
static TouchScrollDelegate |
getActiveScrollDelegate() |
static ArrayList<com.google.gwt.dom.client.Element> |
getElements(com.google.gwt.dom.client.Element scrolledElement2) |
static double |
getTimeStamp()
Long calculation are not very efficient in GWT, so this helper method
returns timestamp in double.
|
boolean |
isMoved()
Has user moved the touch.
|
void |
onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent event) |
void |
onTouchStart(com.google.gwt.event.dom.client.TouchStartEvent event) |
void |
setElements(com.google.gwt.dom.client.Element[] elements) |
void |
setScrollHandler(com.google.gwt.event.dom.client.ScrollHandler scrollHandler) |
void |
stopScrolling()
Forces the scroll delegate to cancels scrolling process.
|
public static final int SIGNIFICANT_MOVE_THRESHOLD
public TouchScrollDelegate(com.google.gwt.dom.client.Element... elements)
public static TouchScrollDelegate.TouchScrollHandler enableTouchScrolling(com.google.gwt.user.client.ui.Widget widget, com.google.gwt.dom.client.Element... scrollables)
widget
- The widget that contains scrollable elementsscrollables
- The elements inside the widget that should be scrollablepublic void setScrollHandler(com.google.gwt.event.dom.client.ScrollHandler scrollHandler)
public static TouchScrollDelegate getActiveScrollDelegate()
public boolean isMoved()
public void stopScrolling()
public void onTouchStart(com.google.gwt.event.dom.client.TouchStartEvent event)
public static ArrayList<com.google.gwt.dom.client.Element> getElements(com.google.gwt.dom.client.Element scrolledElement2)
public void onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent event)
onPreviewNativeEvent
in interface com.google.gwt.user.client.Event.NativePreviewHandler
public void setElements(com.google.gwt.dom.client.Element[] elements)
public static double getTimeStamp()
Copyright © 2018 Vaadin Ltd. All rights reserved.