Class PanZoomController

Object
org.mozilla.geckoview.PanZoomController

@UiThread public class PanZoomController extends Object
  • Field Details

    • SCROLL_BEHAVIOR_SMOOTH

      public static final int SCROLL_BEHAVIOR_SMOOTH
      Specifies smooth scrolling which animates content to the desired scroll position.
      See Also:
    • SCROLL_BEHAVIOR_AUTO

      public static final int SCROLL_BEHAVIOR_AUTO
      Specifies auto scrolling which jumps content to the desired scroll position.
      See Also:
    • INPUT_RESULT_UNHANDLED

      public static final int INPUT_RESULT_UNHANDLED
      Specifies that an input event was not handled by the PanZoomController for a panning or zooming operation. The event may have been handled by Web content or internally (e.g. text selection).
      See Also:
    • INPUT_RESULT_HANDLED

      public static final int INPUT_RESULT_HANDLED
      Specifies that an input event was handled by the PanZoomController for a panning or zooming operation, but likely not by any touch event listeners in Web content.
      See Also:
    • INPUT_RESULT_HANDLED_CONTENT

      public static final int INPUT_RESULT_HANDLED_CONTENT
      Specifies that an input event was handled by the PanZoomController and passed on to touch event listeners in Web content.
      See Also:
    • INPUT_RESULT_IGNORED

      public static final int INPUT_RESULT_IGNORED
      Specifies that an input event was consumed by a PanZoomController internally and browsers should do nothing in response to the event.
      See Also:
    • SCROLLABLE_FLAG_NONE

      public static final int SCROLLABLE_FLAG_NONE
      Represents which directions can be scrolled in the scroll container where an input event was handled. This value is only useful in the case of INPUT_RESULT_HANDLED.
      See Also:
    • SCROLLABLE_FLAG_TOP

      public static final int SCROLLABLE_FLAG_TOP
      See Also:
    • SCROLLABLE_FLAG_RIGHT

      public static final int SCROLLABLE_FLAG_RIGHT
      See Also:
    • SCROLLABLE_FLAG_BOTTOM

      public static final int SCROLLABLE_FLAG_BOTTOM
      See Also:
    • SCROLLABLE_FLAG_LEFT

      public static final int SCROLLABLE_FLAG_LEFT
      See Also:
    • OVERSCROLL_FLAG_NONE

      public static final int OVERSCROLL_FLAG_NONE
      Represents which directions can be over-scrolled in the scroll container where an input event was handled. This value is only useful in the case of INPUT_RESULT_HANDLED.
      See Also:
    • OVERSCROLL_FLAG_HORIZONTAL

      public static final int OVERSCROLL_FLAG_HORIZONTAL
      See Also:
    • OVERSCROLL_FLAG_VERTICAL

      public static final int OVERSCROLL_FLAG_VERTICAL
      See Also:
  • Constructor Details

    • PanZoomController

      protected PanZoomController(GeckoSession session)
  • Method Details

    • setScrollFactor

      public void setScrollFactor(float factor)
      Set the current scroll factor. The scroll factor is the maximum scroll amount that one scroll event may generate, in device pixels.
      Parameters:
      factor - Scroll factor.
    • getScrollFactor

      public float getScrollFactor()
      Get the current scroll factor.
      Returns:
      Scroll factor.
    • onTouchEvent

      public void onTouchEvent(@NonNull MotionEvent event)
      Process a touch event through the pan-zoom controller. Treat any mouse events as "touch" rather than as "mouse". Pointer coordinates should be relative to the display surface.
      Parameters:
      event - MotionEvent to process.
    • onTouchEventForDetailResult

      @NonNull public GeckoResult<PanZoomController.InputResultDetail> onTouchEventForDetailResult(@NonNull MotionEvent event)
      Process a touch event through the pan-zoom controller. Treat any mouse events as "touch" rather than as "mouse". Pointer coordinates should be relative to the display surface.

      NOTE: It is highly recommended to only call this with ACTION_DOWN or in otherwise limited capacity. Returning a GeckoResult for every touch event will generate a lot of allocations and unnecessary GC pressure. Instead, prefer to call onTouchEvent(MotionEvent).

      Parameters:
      event - MotionEvent to process.
      Returns:
      A GeckoResult resolving to PanZoomController.InputResultDetail).
    • onMouseEvent

      public void onMouseEvent(@NonNull MotionEvent event)
      Process a touch event through the pan-zoom controller. Treat any mouse events as "mouse" rather than as "touch". Pointer coordinates should be relative to the display surface.
      Parameters:
      event - MotionEvent to process.
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • onMotionEvent

      public void onMotionEvent(@NonNull MotionEvent event)
      Process a non-touch motion event through the pan-zoom controller. Currently, hover and scroll events are supported. Pointer coordinates should be relative to the display surface.
      Parameters:
      event - MotionEvent to process.
    • onDragEvent

      public boolean onDragEvent(@NonNull DragEvent event)
      Process a drag event.
      Parameters:
      event - DragEvent to process.
      Returns:
      true if this event is accepted.
    • setIsLongpressEnabled

      public void setIsLongpressEnabled(boolean isLongpressEnabled)
      Set whether Gecko should generate long-press events.
      Parameters:
      isLongpressEnabled - True if Gecko should generate long-press events.
    • scrollBy

      @UiThread public void scrollBy(@NonNull ScreenLength width, @NonNull ScreenLength height)
      Scroll the document body by an offset from the current scroll position. Uses SCROLL_BEHAVIOR_SMOOTH.
      Parameters:
      width - ScreenLength offset to scroll along X axis.
      height - ScreenLength offset to scroll along Y axis.
    • scrollBy

      @UiThread public void scrollBy(@NonNull ScreenLength width, @NonNull ScreenLength height, int behavior)
      Scroll the document body by an offset from the current scroll position.
      Parameters:
      width - ScreenLength offset to scroll along X axis.
      height - ScreenLength offset to scroll along Y axis.
      behavior - ScrollBehaviorType One of SCROLL_BEHAVIOR_SMOOTH, SCROLL_BEHAVIOR_AUTO, that specifies how to scroll the content.
    • scrollTo

      @UiThread public void scrollTo(@NonNull ScreenLength width, @NonNull ScreenLength height)
      Scroll the document body to an absolute position. Uses SCROLL_BEHAVIOR_SMOOTH.
      Parameters:
      width - ScreenLength position to scroll along X axis.
      height - ScreenLength position to scroll along Y axis.
    • scrollTo

      @UiThread public void scrollTo(@NonNull ScreenLength width, @NonNull ScreenLength height, int behavior)
      Scroll the document body to an absolute position.
      Parameters:
      width - ScreenLength position to scroll along X axis.
      height - ScreenLength position to scroll along Y axis.
      behavior - ScrollBehaviorType One of SCROLL_BEHAVIOR_SMOOTH, SCROLL_BEHAVIOR_AUTO, that specifies how to scroll the content.
    • scrollToTop

      @UiThread public void scrollToTop()
      Scroll to the top left corner of the screen. Uses SCROLL_BEHAVIOR_SMOOTH.
    • scrollToBottom

      @UiThread public void scrollToBottom()
      Scroll to the bottom left corner of the screen. Uses SCROLL_BEHAVIOR_SMOOTH.