com.facebook.react.views.scroll.ScrollEvent Java Examples

The following examples show how to use com.facebook.react.views.scroll.ScrollEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReactAztecManager.java    From react-native-aztec with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onScrollChanged(int horiz, int vert, int oldHoriz, int oldVert) {
    if (mPreviousHoriz != horiz || mPreviousVert != vert) {
        ScrollEvent event = ScrollEvent.obtain(
                mReactAztecText.getId(),
                ScrollEventType.SCROLL,
                horiz,
                vert,
                0f, // can't get x velocity
                0f, // can't get y velocity
                0, // can't get content width
                0, // can't get content height
                mReactAztecText.getWidth(),
                mReactAztecText.getHeight());

        mEventDispatcher.dispatchEvent(event);

        mPreviousHoriz = horiz;
        mPreviousVert = vert;
    }
}
 
Example #2
Source File: Web3WebviewManager.java    From react-native-web3-webview with MIT License 6 votes vote down vote up
protected void onScrollChanged(int x, int y, int oldX, int oldY) {
    super.onScrollChanged(x, y, oldX, oldY);
    if (mOnScrollDispatchHelper.onScrollChanged(x, y)) {
        ScrollEvent event = ScrollEvent.obtain(
        this.getId(),
        ScrollEventType.SCROLL,
        x,
        y,
        mOnScrollDispatchHelper.getXFlingVelocity(),
        mOnScrollDispatchHelper.getYFlingVelocity(),
        this.computeHorizontalScrollRange(),
        this.computeVerticalScrollRange(),
        this.getWidth(),
        this.getHeight());
        dispatchEvent(this, event);
    }
}
 
Example #3
Source File: ReactTextInputManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void onScrollChanged(int horiz, int vert, int oldHoriz, int oldVert) {
  if (mPreviousHoriz != horiz || mPreviousVert != vert) {
    ScrollEvent event = ScrollEvent.obtain(
      mReactEditText.getId(),
      ScrollEventType.SCROLL,
      horiz,
      vert,
      0f, // can't get x velocity
      0f, // can't get y velocity
      0, // can't get content width
      0, // can't get content height
      mReactEditText.getWidth(),
      mReactEditText.getHeight());

    mEventDispatcher.dispatchEvent(event);

    mPreviousHoriz = horiz;
    mPreviousVert = vert;
  }
}
 
Example #4
Source File: DirectedScrollView.java    From react-native-directed-scrollview with MIT License 6 votes vote down vote up
private void emitScrollEvent(
  ScrollEventType scrollEventType,
  float xVelocity,
  float yVelocity) {
  reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
    ScrollEvent.obtain(
      getId(),
      scrollEventType,
      Math.round(scrollX * -1),
      Math.round(scrollY * -1),
      xVelocity,
      yVelocity,
      Math.round(getContentContainerWidth()),
      Math.round(getContentContainerHeight()),
      getWidth(),
      getHeight()));
}
 
Example #5
Source File: ScrollEventListener.java    From react-native-navigation with MIT License 4 votes vote down vote up
@Override
public void onEventDispatch(Event event) {
    if (event instanceof ScrollEvent) {
        handleScrollEvent((ScrollEvent) event);
    }
}