-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathReactNestedScrollViewHelper.java
More file actions
51 lines (47 loc) · 1.74 KB
/
ReactNestedScrollViewHelper.java
File metadata and controls
51 lines (47 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.reactnativeandroiddesignsupport;
/**
* This file is copied from https://goo.gl/cP1YU3, only replacing ScrollView to
* NestedScrollView.
*/
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// EDITED: 1. Import additional classes
import android.os.SystemClock;
import android.view.View;
import android.view.ViewGroup;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.views.scroll.ReactHorizontalScrollView;
import com.facebook.react.views.scroll.ReactScrollView;
import com.facebook.react.views.scroll.ScrollEvent;
import com.facebook.react.views.scroll.ScrollEventType;
/**
* Helper class that deals with emitting Scroll Events.
*/
// EDITED: 1. Rename the class
public class ReactNestedScrollViewHelper {
/**
* Shared by {@link ReactScrollView} and {@link ReactHorizontalScrollView}.
*/
public static void emitScrollEvent(ViewGroup scrollView, int scrollX, int scrollY) {
View contentView = scrollView.getChildAt(0);
ReactContext reactContext = (ReactContext) scrollView.getContext();
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
ScrollEvent.obtain(
scrollView.getId(),
SystemClock.uptimeMillis(),
ScrollEventType.SCROLL,
scrollX,
scrollY,
contentView.getWidth(),
contentView.getHeight(),
scrollView.getWidth(),
scrollView.getHeight()));
}
}