com.vaadin.client.ui.

Class TouchScrollDelegate.TouchScrollHandler

  • All Implemented Interfaces:

    com.google.gwt.event.dom.client.TouchStartHandler, com.google.gwt.event.shared.EventHandler

    Enclosing class:

    TouchScrollDelegate

    public static class TouchScrollDelegate.TouchScrollHandler
    extends Object
    implements com.google.gwt.event.dom.client.TouchStartHandler

    A helper class for making a widget scrollable. Uses native scrolling if supported by the browser, otherwise registers a touch start handler delegating to a TouchScrollDelegate instance.

    • Constructor Summary

      Constructors
      Constructor Description
      TouchScrollHandler()

      Constructs a scroll handler.

      TouchScrollHandler​(com.google.gwt.user.client.ui.Widget widget, com.google.gwt.dom.client.Element... scrollables)

      Deprecated.

      Use GWT.create(Class) and init(Widget, Element...) instead of this constructor to enable overriding.

    • Method Summary

      All Methods
      Modifier and Type Method Description
      void addElement​(com.google.gwt.dom.client.Element scrollable)

      Registers the given element as scrollable.

      void debug​(com.google.gwt.dom.client.Element e)  
      protected com.google.gwt.user.client.ui.Widget getWidget()  
      void init​(com.google.gwt.user.client.ui.Widget widget, com.google.gwt.dom.client.Element... scrollables)

      Attaches the scroll handler to the widget.

      void onTouchStart​(com.google.gwt.event.dom.client.TouchStartEvent event)  
      void removeElement​(com.google.gwt.dom.client.Element scrollable)

      Unregisters the given element as scrollable.

      protected boolean requiresDelegate()

      Checks if a delegate for scrolling is required or if the native scrolling of the device should be used.

      void setElements​(com.google.gwt.dom.client.Element... scrollables)

      Registers the given elements as scrollable, removing previously registered scrollables from this handler.

    • Constructor Detail

      • TouchScrollHandler

        public TouchScrollHandler()

        Constructs a scroll handler. You must call init(Widget, Element...) before using the scroll handler.

      • TouchScrollHandler

        @Deprecated
        public TouchScrollHandler​(com.google.gwt.user.client.ui.Widget widget,
                                  com.google.gwt.dom.client.Element... scrollables)
        Deprecated.
        Use GWT.create(Class) and init(Widget, Element...) instead of this constructor to enable overriding.

        Attaches the scroll handler to the widget. This method must be called before calling any other methods in this class.

        Parameters:

        widget - The widget that contains scrollable elements

        scrollables - The elements of the widget that should be scrollable.

    • Method Detail

      • init

        public void init​(com.google.gwt.user.client.ui.Widget widget,
                         com.google.gwt.dom.client.Element... scrollables)

        Attaches the scroll handler to the widget. This method must be called once before calling any other method in this class.

        Parameters:

        widget - The widget that contains scrollable elements

        scrollables - The elements of the widget that should be scrollable.

      • onTouchStart

        public void onTouchStart​(com.google.gwt.event.dom.client.TouchStartEvent event)

        Specified by:

        onTouchStart in interface com.google.gwt.event.dom.client.TouchStartHandler

      • debug

        public void debug​(com.google.gwt.dom.client.Element e)
      • addElement

        public void addElement​(com.google.gwt.dom.client.Element scrollable)

        Registers the given element as scrollable.

      • removeElement

        public void removeElement​(com.google.gwt.dom.client.Element scrollable)

        Unregisters the given element as scrollable. Should be called when a previously-registered element is removed from the DOM to prevent memory leaks.

      • setElements

        public void setElements​(com.google.gwt.dom.client.Element... scrollables)

        Registers the given elements as scrollable, removing previously registered scrollables from this handler.

        Parameters:

        scrollables - The elements that should be scrollable

      • requiresDelegate

        protected boolean requiresDelegate()

        Checks if a delegate for scrolling is required or if the native scrolling of the device should be used. By default, relies on BrowserInfo.requiresTouchScrollDelegate(), override to change the behavior.

        Returns:

        true if a Javascript delegate should be used for scrolling, false to use the native scrolling of the device