|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vaadin.terminal.gwt.client.ui.TouchScrollDelegate
public class TouchScrollDelegate
Provides one finger touch scrolling for elements with once scrollable elements inside. One widget can have several of these scrollable elements. Scrollable elements are provided in the constructor. Users must pass touchStart events to this delegate, from there on the delegate takes over with an event preview. Other touch events needs to be sunken though.
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.
Nested Class Summary | |
---|---|
static class |
TouchScrollDelegate.TouchScrollHandler
A helper class for making a widget scrollable. |
Field Summary | |
---|---|
static int |
SIGNIFICANT_MOVE_THRESHOLD
|
Constructor Summary | |
---|---|
TouchScrollDelegate(com.google.gwt.dom.client.Element... elements)
|
Method Summary | |
---|---|
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 calcucation 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SIGNIFICANT_MOVE_THRESHOLD
Constructor Detail |
---|
public TouchScrollDelegate(com.google.gwt.dom.client.Element... elements)
Method Detail |
---|
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 scrollable
public 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()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |