public class TouchScroller
extends java.lang.Object
Touch based scrolling is only supported on devices that support touch events and do not implement native touch based scrolling.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
TouchScroller.TemporalPoint
A point associated with a time.
|
Modifier | Constructor and Description |
---|---|
protected |
TouchScroller()
Construct a new
TouchScroller . |
Modifier and Type | Method and Description |
---|---|
(package private) Point |
calculateEndVelocity(TouchScroller.TemporalPoint from,
TouchScroller.TemporalPoint to)
Calculate the end velocity.
|
static TouchScroller |
createIfSupported()
Return a new
TouchScroller . |
static TouchScroller |
createIfSupported(HasScrolling widget)
Return a new
TouchScroller that augments the specified scrollable
widget if supported, and null otherwise. |
(package private) TouchScroller.TemporalPoint |
getLastTouchPosition()
Visible for testing.
|
Momentum |
getMomentum()
Get the
Momentum that controls scrolling after the user completes a
gesture. |
(package private) TouchScroller.TemporalPoint |
getRecentTouchPosition()
Visible for testing.
|
HasScrolling |
getTargetWidget()
Get the target
HasScrolling widget that this scroller affects. |
protected Touch |
getTouchFromEvent(TouchEvent<?> event)
Get touch from event.
|
(package private) boolean |
isDragging()
Visible for testing.
|
(package private) boolean |
isMomentumActive()
Check if momentum is currently active.
|
static boolean |
isSupported()
Runtime check for whether touch scrolling is supported in this browser.
|
(package private) boolean |
isTouching()
Visible for testing.
|
protected void |
onDragEnd(TouchEvent<?> event)
Called when the object's drag sequence is complete.
|
protected void |
onDragMove(TouchEvent<?> event)
Called when the object has been dragged to a new position.
|
protected void |
onDragStart(TouchEvent<?> event)
Called when the object has started dragging.
|
protected void |
onTouchCancel(TouchEvent<?> event)
Called when the user cancels a touch.
|
protected void |
onTouchEnd(TouchEvent<?> event)
Called when the user releases a touch.
|
protected void |
onTouchMove(TouchEvent<?> event)
Called when the user moves a touch.
|
protected void |
onTouchStart(TouchEvent<?> event)
Called when the user starts a touch.
|
(package private) void |
removeAttachHandler()
Removes the attach handler.
|
(package private) void |
removeBustClickHandler()
Removes the bust click handler.
|
void |
setMomentum(Momentum momentum)
Set the
Momentum that controls scrolling after the user completes a
gesture. |
void |
setTargetWidget(HasScrolling widget)
Set the target
HasScrolling widget that this scroller affects. |
(package private) void |
setupBustClickHandler()
Sets up the bust click handler.
|
protected TouchScroller()
TouchScroller
. This constructor should be called
using the static method createIfSupported()
.createIfSupported()
public static TouchScroller createIfSupported()
TouchScroller
.TouchScroller
if supported, and null otherwisepublic static TouchScroller createIfSupported(HasScrolling widget)
TouchScroller
that augments the specified scrollable
widget if supported, and null otherwise.widget
- the scrollable widgetTouchScroller
if supported, and null otherwisepublic static boolean isSupported()
public Momentum getMomentum()
Momentum
that controls scrolling after the user completes a
gesture.Momentum
, or null if disabledpublic HasScrolling getTargetWidget()
HasScrolling
widget that this scroller affects.public void setMomentum(Momentum momentum)
Momentum
that controls scrolling after the user completes a
gesture.momentum
- the scrolling Momentum
, or null to disablepublic void setTargetWidget(HasScrolling widget)
HasScrolling
widget that this scroller affects.widget
- the target widget, or null to disbaleprotected Touch getTouchFromEvent(TouchEvent<?> event)
event
- the eventprotected void onDragEnd(TouchEvent<?> event)
event
- the touch eventprotected void onDragMove(TouchEvent<?> event)
event
- the touch eventprotected void onDragStart(TouchEvent<?> event)
event
- the touch eventprotected void onTouchCancel(TouchEvent<?> event)
event
- the touch eventprotected void onTouchEnd(TouchEvent<?> event)
event
- the touch eventprotected void onTouchMove(TouchEvent<?> event)
event
- the touch eventprotected void onTouchStart(TouchEvent<?> event)
event
- the touch eventPoint calculateEndVelocity(TouchScroller.TemporalPoint from, TouchScroller.TemporalPoint to)
from
- the starting pointto
- the ending pointTouchScroller.TemporalPoint getLastTouchPosition()
TouchScroller.TemporalPoint getRecentTouchPosition()
boolean isDragging()
boolean isMomentumActive()
boolean isTouching()
void removeAttachHandler()
void removeBustClickHandler()
void setupBustClickHandler()