com.google.gwt.touch.client

## Class TouchScroller

- java.lang.Object
- - com.google.gwt.touch.client.TouchScroller

-     public class TouchScroller
      extends java.lang.Object

  Adds touch based scrolling to a scroll panel.

  Touch based scrolling is only supported on devices that support touch events and do not implement native touch based scrolling.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) static class` | `TouchScroller.TemporalPoint` A point associated with a time.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `TouchScroller()` Construct a new `TouchScroller`.

  - ### Method Summary

    Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TouchScroller

          protected TouchScroller()

      Construct a new `TouchScroller`. This constructor should be called using the static method `createIfSupported()`.
      See Also:
        `createIfSupported()`

  - ### Method Detail

    - #### createIfSupported

          public static TouchScroller createIfSupported()

      Return a new `TouchScroller`.
      Returns:
        a new `TouchScroller` if supported, and null otherwise

    - #### createIfSupported

          public static TouchScroller createIfSupported(HasScrolling widget)

      Return a new `TouchScroller` that augments the specified scrollable widget if supported, and null otherwise.
      Parameters:
        `widget` - the scrollable widget
      Returns:
        a new `TouchScroller` if supported, and null otherwise

    - #### isSupported

          public static boolean isSupported()

      Runtime check for whether touch scrolling is supported in this browser. Returns true if touch events are supported but touch based scrolling is not natively supported.
      Returns:
        true if touch scrolling is supported, false if not

    - #### getMomentum

          public Momentum getMomentum()

      Get the `Momentum` that controls scrolling after the user completes a gesture.
      Returns:
        the scrolling `Momentum`, or null if disabled

    - #### getTargetWidget

          public HasScrolling getTargetWidget()

      Get the target `HasScrolling` widget that this scroller affects.
      Returns:
        the target widget

    - #### setMomentum

          public void setMomentum(Momentum momentum)

      Set the `Momentum` that controls scrolling after the user completes a gesture.
      Parameters:
        `momentum` - the scrolling `Momentum`, or null to disable

    - #### setTargetWidget

          public void setTargetWidget(HasScrolling widget)

      Set the target `HasScrolling` widget that this scroller affects.
      Parameters:
        `widget` - the target widget, or null to disbale

    - #### getTouchFromEvent

          protected Touch getTouchFromEvent(TouchEvent<?> event)

      Get touch from event.
      Parameters:
        `event` - the event
      Returns:
        the touch object

    - #### onDragEnd

          protected void onDragEnd(TouchEvent<?> event)

      Called when the object's drag sequence is complete.
      Parameters:
        `event` - the touch event

    - #### onDragMove

          protected void onDragMove(TouchEvent<?> event)

      Called when the object has been dragged to a new position.
      Parameters:
        `event` - the touch event

    - #### onDragStart

          protected void onDragStart(TouchEvent<?> event)

      Called when the object has started dragging.
      Parameters:
        `event` - the touch event

    - #### onTouchCancel

          protected void onTouchCancel(TouchEvent<?> event)

      Called when the user cancels a touch. This can happen if the user touches the screen with too many fingers.
      Parameters:
        `event` - the touch event

    - #### onTouchEnd

          protected void onTouchEnd(TouchEvent<?> event)

      Called when the user releases a touch.
      Parameters:
        `event` - the touch event

    - #### onTouchMove

          protected void onTouchMove(TouchEvent<?> event)

      Called when the user moves a touch.
      Parameters:
        `event` - the touch event

    - #### onTouchStart

          protected void onTouchStart(TouchEvent<?> event)

      Called when the user starts a touch.
      Parameters:
        `event` - the touch event

    - #### calculateEndVelocity

          Point calculateEndVelocity(TouchScroller.TemporalPoint from,
                                   TouchScroller.TemporalPoint to)

      Calculate the end velocity. Visible for testing.
      Parameters:
        `from` - the starting point
        `to` - the ending point
      Returns:
        the end velocity, or null if it cannot be calculated

    - #### getLastTouchPosition

          TouchScroller.TemporalPoint getLastTouchPosition()

      Visible for testing.

    - #### getRecentTouchPosition

          TouchScroller.TemporalPoint getRecentTouchPosition()

      Visible for testing.

    - #### isDragging

          boolean isDragging()

      Visible for testing.

    - #### isMomentumActive

          boolean isMomentumActive()

      Check if momentum is currently active. Visible for testing.
      Returns:
        true if active, false if not

    - #### isTouching

          boolean isTouching()

      Visible for testing.

    - #### removeAttachHandler

          void removeAttachHandler()

      Removes the attach handler. Visible for testing.

    - #### removeBustClickHandler

          void removeBustClickHandler()

      Removes the bust click handler. Visible for testing.

    - #### setupBustClickHandler

          void setupBustClickHandler()

      Sets up the bust click handler. Visible for testing.