Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ constructor(private val config: MainPackageConfig? = null) :
ReactHorizontalScrollViewManager(),
ReactHorizontalScrollContainerViewManager(),
ReactProgressBarViewManager(),
ReactScrollViewManager(),
// ReactScrollViewManager(),
ReactSwitchManager(),
ReactSafeAreaViewManager(),
SwipeRefreshLayoutManager(),
Expand Down Expand Up @@ -172,8 +172,8 @@ constructor(private val config: MainPackageConfig? = null) :
ModuleSpec.viewManagerSpec { ReactProgressBarViewManager() },
ReactSafeAreaViewManager.REACT_CLASS to
ModuleSpec.viewManagerSpec { ReactSafeAreaViewManager() },
ReactScrollViewManager.REACT_CLASS to
ModuleSpec.viewManagerSpec { ReactScrollViewManager() },
// ReactScrollViewManager.REACT_CLASS to
// ModuleSpec.viewManagerSpec { ReactScrollViewManager() },
ReactSwitchManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactSwitchManager() },
SwipeRefreshLayoutManager.REACT_CLASS to
ModuleSpec.viewManagerSpec { SwipeRefreshLayoutManager() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public abstract class Event<T : Event<T>> {
public var viewTag: Int = 0
private set

/** @return whether this event is dispatched during a drawing pass */
public var isDrawing: Boolean = false

/**
* @return the time at which the event happened in the [android.os.SystemClock.uptimeMillis] base.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,24 +463,29 @@ private void scrollToChild(View child) {

@Override
protected void onScrollChanged(int x, int y, int oldX, int oldY) {
Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactScrollView.onScrollChanged");
try {
super.onScrollChanged(x, y, oldX, oldY);
onScrollChanged(x, y, oldX, oldY, false);
}

mActivelyScrolling = true;
protected void onScrollChanged(int x, int y, int oldX, int oldY, boolean isDrawing) {
Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactScrollView.onScrollChanged");
try {
super.onScrollChanged(x, y, oldX, oldY);

if (mOnScrollDispatchHelper.onScrollChanged(x, y)) {
if (mRemoveClippedSubviews) {
updateClippingRect();
}
ReactScrollViewHelper.updateStateOnScrollChanged(
this,
mOnScrollDispatchHelper.getXFlingVelocity(),
mOnScrollDispatchHelper.getYFlingVelocity());
mActivelyScrolling = true;

if (mOnScrollDispatchHelper.onScrollChanged(x, y)) {
if (mRemoveClippedSubviews) {
updateClippingRect();
}
ReactScrollViewHelper.updateStateOnScrollChanged(
this,
mOnScrollDispatchHelper.getXFlingVelocity(),
mOnScrollDispatchHelper.getYFlingVelocity(),
isDrawing);
}
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT);
}
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public object ReactScrollViewHelper {

/** Shared by [ReactScrollView] and [ReactHorizontalScrollView]. */
@JvmStatic
public fun <T> emitScrollEvent(scrollView: T, xVelocity: Float, yVelocity: Float) where
public fun <T> emitScrollEvent(scrollView: T, xVelocity: Float, yVelocity: Float, isDrawing: Boolean = false) where
T : HasScrollEventThrottle?,
T : ViewGroup {
emitScrollEvent(scrollView, ScrollEventType.SCROLL, xVelocity, yVelocity)
emitScrollEvent(scrollView, ScrollEventType.SCROLL, xVelocity, yVelocity, isDrawing)
}

@JvmStatic
Expand Down Expand Up @@ -111,6 +111,7 @@ public object ReactScrollViewHelper {
scrollEventType: ScrollEventType,
xVelocity: Float,
yVelocity: Float,
isDrawing: Boolean = false
) where T : HasScrollEventThrottle?, T : ViewGroup {
val now = System.currentTimeMillis()
// Throttle the scroll event if scrollEventThrottle is set to be equal or more than 17 ms.
Expand Down Expand Up @@ -146,7 +147,9 @@ public object ReactScrollViewHelper {
contentView.width,
contentView.height,
scrollView.width,
scrollView.height))
scrollView.height).also {
it.isDrawing = isDrawing
})
if (scrollEventType == ScrollEventType.SCROLL) {
scrollView.lastScrollDispatchTime = now
}
Expand Down Expand Up @@ -368,7 +371,8 @@ public object ReactScrollViewHelper {
public fun <T> updateStateOnScrollChanged(
scrollView: T,
xVelocity: Float,
yVelocity: Float
yVelocity: Float,
isDrawing: Boolean = false
) where
T : HasFlingAnimator?,
T : HasScrollEventThrottle?,
Expand All @@ -380,7 +384,7 @@ public object ReactScrollViewHelper {
// "more correct" scroll position. It will frequently be /incorrect/ but this decreases
// the error as much as possible.
updateFabricScrollState(scrollView, scrollView.scrollX, scrollView.scrollY)
emitScrollEvent(scrollView, xVelocity, yVelocity)
emitScrollEvent(scrollView, xVelocity, yVelocity, isDrawing)
}

public fun <T> registerFlingAnimator(scrollView: T) where
Expand Down
Loading