From e901ebfcd0b71f2f06186b252b0afdaccb50378e Mon Sep 17 00:00:00 2001 From: ByteZhang1024 Date: Thu, 21 Jul 2022 09:29:53 +0800 Subject: [PATCH] feat: Upgrade depend on --- README.md | 15 +- android/build.gradle | 19 +- android/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59821 bytes .../gradle/wrapper/gradle-wrapper.properties | 5 + android/gradlew | 234 +++ android/gradlew.bat | 89 + .../RNNestedScrollViewPackage.java | 9 +- ...eactHorizontalNestedScrollViewManager.java | 2 - .../ReactHorizontalScrollView.java | 730 +++++++ .../ReactHorizontalScrollViewManager.java | 273 +++ .../ReactNestedScrollView.java | 31 +- .../ReactNestedScrollViewManager.java | 12 +- .../ReactScrollViewHelper.java | 82 + .../com/rnnestedscrollview/ScrollEvent.java | 144 ++ index.js | 2 +- lib/NestedScrollView.js | 1155 ----------- lib/ScrollView.js | 1844 +++++++++++++++++ package.json | 2 +- 18 files changed, 3449 insertions(+), 1199 deletions(-) create mode 100644 android/gradle/wrapper/gradle-wrapper.jar create mode 100644 android/gradle/wrapper/gradle-wrapper.properties create mode 100755 android/gradlew create mode 100644 android/gradlew.bat create mode 100644 android/src/main/java/com/rnnestedscrollview/ReactHorizontalScrollView.java create mode 100644 android/src/main/java/com/rnnestedscrollview/ReactHorizontalScrollViewManager.java create mode 100644 android/src/main/java/com/rnnestedscrollview/ReactScrollViewHelper.java create mode 100644 android/src/main/java/com/rnnestedscrollview/ScrollEvent.java delete mode 100644 lib/NestedScrollView.js create mode 100644 lib/ScrollView.js diff --git a/README.md b/README.md index cbe0ca6..4f5e823 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,8 @@ android/app/build.gradle dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) -+ implementation 'com.android.support:appcompat-v7:27.1.1' -+ implementation 'com.android.support:design:27.1.1' ++ implementation "androidx.appcompat:appcompat:1.3.1" ++ implementation 'com.google.android.material:material:1.6.1' implementation 'com.facebook.react:react-native:+' // From node_modules + implementation project(':react-native-nested-scroll-view') } @@ -85,6 +85,17 @@ include ':app' ``` +android/settings.gradle (monorepo) + +```diff + +include ':app' + ++ include ':react-native-nested-scroll-view' ++ project(':react-native-nested-scroll-view').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-nested-scroll-view/android') + +``` + # License [MIT](./LICENSE) diff --git a/android/build.gradle b/android/build.gradle index 399f7d4..fe44671 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,26 +1,27 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 26 - buildToolsVersion "26.0.2" + compileSdkVersion 32 + buildToolsVersion "30.0.3" defaultConfig { - minSdkVersion 16 - targetSdkVersion 26 + minSdkVersion 21 + targetSdkVersion 32 } } buildscript { repositories { - jcenter() + mavenCentral() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' + classpath 'com.android.tools.build:gradle:7.1.0' } } dependencies { - compile 'com.facebook.react:react-native:+' - compile 'com.android.support:appcompat-v7:26.1.0' - compile 'com.android.support:design:26.1.0' + implementation 'com.facebook.react:react-native:+' + implementation "androidx.appcompat:appcompat:1.4.2" + implementation 'com.google.android.material:material:1.6.1' } diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..41d9927a4d4fb3f96a785543079b8df6723c946b GIT binary patch literal 59821 zcma&NV|1p`(k7gaZQHhOJ9%QKV?D8LCmq{1JGRYE(y=?XJw0>InKkE~^UnAEs2gk5 zUVGPCwX3dOb!}xiFmPB95NK!+5D<~S0s;d1zn&lrfAn7 zC?Nb-LFlib|DTEqB8oDS5&$(u1<5;wsY!V`2F7^=IR@I9so5q~=3i_(hqqG<9SbL8Q(LqDrz+aNtGYWGJ2;p*{a-^;C>BfGzkz_@fPsK8{pTT~_VzB$E`P@> z7+V1WF2+tSW=`ZRj3&0m&d#x_lfXq`bb-Y-SC-O{dkN2EVM7@!n|{s+2=xSEMtW7( zz~A!cBpDMpQu{FP=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al 0 HcmV?d00001 diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..41dfb87 --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew new file mode 100755 index 0000000..1b6c787 --- /dev/null +++ b/android/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat new file mode 100644 index 0000000..ac1b06f --- /dev/null +++ b/android/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/src/main/java/com/rnnestedscrollview/RNNestedScrollViewPackage.java b/android/src/main/java/com/rnnestedscrollview/RNNestedScrollViewPackage.java index 09aeec7..841359b 100644 --- a/android/src/main/java/com/rnnestedscrollview/RNNestedScrollViewPackage.java +++ b/android/src/main/java/com/rnnestedscrollview/RNNestedScrollViewPackage.java @@ -1,14 +1,13 @@ package com.rnnestedscrollview; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import com.facebook.react.ReactPackage; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; -import com.facebook.react.bridge.JavaScriptModule; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; public class RNNestedScrollViewPackage implements ReactPackage { @Override diff --git a/android/src/main/java/com/rnnestedscrollview/ReactHorizontalNestedScrollViewManager.java b/android/src/main/java/com/rnnestedscrollview/ReactHorizontalNestedScrollViewManager.java index 38d1227..13a2eb9 100644 --- a/android/src/main/java/com/rnnestedscrollview/ReactHorizontalNestedScrollViewManager.java +++ b/android/src/main/java/com/rnnestedscrollview/ReactHorizontalNestedScrollViewManager.java @@ -1,7 +1,5 @@ package com.rnnestedscrollview; -import com.facebook.react.views.scroll.ReactHorizontalScrollViewManager; - /** * react-native@0.49.0 introduces a weird breaking change that don't allow us to use * requireNativeComponent twice of the same view name, and since we are using the same diff --git a/android/src/main/java/com/rnnestedscrollview/ReactHorizontalScrollView.java b/android/src/main/java/com/rnnestedscrollview/ReactHorizontalScrollView.java new file mode 100644 index 0000000..aa305b4 --- /dev/null +++ b/android/src/main/java/com/rnnestedscrollview/ReactHorizontalScrollView.java @@ -0,0 +1,730 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.rnnestedscrollview; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Rect; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.Drawable; +import android.util.Log; +import android.view.MotionEvent; +import android.view.View; +import android.widget.HorizontalScrollView; +import android.widget.OverScroller; + +import androidx.core.text.TextUtilsCompat; +import androidx.core.view.ViewCompat; + +import com.facebook.infer.annotation.Assertions; +import com.facebook.react.common.ReactConstants; +import com.facebook.react.uimanager.MeasureSpecAssertions; +import com.facebook.react.uimanager.ReactClippingViewGroup; +import com.facebook.react.uimanager.ReactClippingViewGroupHelper; +import com.facebook.react.uimanager.ViewProps; +import com.facebook.react.uimanager.events.NativeGestureUtil; +import com.facebook.react.views.scroll.FpsListener; +import com.facebook.react.views.scroll.OnScrollDispatchHelper; +import com.facebook.react.views.scroll.VelocityHelper; +import com.facebook.react.views.view.ReactViewBackgroundManager; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Locale; + +import javax.annotation.Nullable; + +/** + * Similar to {@link ReactScrollView} but only supports horizontal scrolling. + */ +public class ReactHorizontalScrollView extends HorizontalScrollView implements + ReactClippingViewGroup { + + private static @Nullable Field sScrollerField; + private static boolean sTriedToGetScrollerField = false; + + private final OnScrollDispatchHelper mOnScrollDispatchHelper = new OnScrollDispatchHelper(); + private final VelocityHelper mVelocityHelper = new VelocityHelper(); + private final @Nullable OverScroller mScroller; + private final Rect mRect = new Rect(); + + private boolean mActivelyScrolling; + private @Nullable Rect mClippingRect; + private @Nullable String mOverflow = ViewProps.HIDDEN; + private boolean mDragging; + private boolean mPagingEnabled = false; + private @Nullable Runnable mPostTouchRunnable; + private boolean mRemoveClippedSubviews; + private boolean mScrollEnabled = true; + private boolean mSendMomentumEvents; + private @Nullable + FpsListener mFpsListener = null; + private @Nullable String mScrollPerfTag; + private @Nullable Drawable mEndBackground; + private int mEndFillColor = Color.TRANSPARENT; + private boolean mDisableIntervalMomentum = false; + private int mSnapInterval = 0; + private float mDecelerationRate = 0.985f; + private @Nullable List mSnapOffsets; + private boolean mSnapToStart = true; + private boolean mSnapToEnd = true; + private ReactViewBackgroundManager mReactBackgroundManager; + + public ReactHorizontalScrollView(Context context) { + this(context, null); + } + + public ReactHorizontalScrollView(Context context, @Nullable FpsListener fpsListener) { + super(context); + mReactBackgroundManager = new ReactViewBackgroundManager(this); + mFpsListener = fpsListener; + + mScroller = getOverScrollerFromParent(); + } + + @Nullable + private OverScroller getOverScrollerFromParent() { + OverScroller scroller; + + if (!sTriedToGetScrollerField) { + sTriedToGetScrollerField = true; + try { + sScrollerField = HorizontalScrollView.class.getDeclaredField("mScroller"); + sScrollerField.setAccessible(true); + } catch (NoSuchFieldException e) { + Log.w( + ReactConstants.TAG, + "Failed to get mScroller field for HorizontalScrollView! " + + "This app will exhibit the bounce-back scrolling bug :("); + } + } + + if (sScrollerField != null) { + try { + Object scrollerValue = sScrollerField.get(this); + if (scrollerValue instanceof OverScroller) { + scroller = (OverScroller) scrollerValue; + } else { + Log.w( + ReactConstants.TAG, + "Failed to cast mScroller field in HorizontalScrollView (probably due to OEM changes to AOSP)! " + + "This app will exhibit the bounce-back scrolling bug :("); + scroller = null; + } + } catch (IllegalAccessException e) { + throw new RuntimeException("Failed to get mScroller from HorizontalScrollView!", e); + } + } else { + scroller = null; + } + + return scroller; + } + + public void setScrollPerfTag(@Nullable String scrollPerfTag) { + mScrollPerfTag = scrollPerfTag; + } + + @Override + public void setRemoveClippedSubviews(boolean removeClippedSubviews) { + if (removeClippedSubviews && mClippingRect == null) { + mClippingRect = new Rect(); + } + mRemoveClippedSubviews = removeClippedSubviews; + updateClippingRect(); + } + + @Override + public boolean getRemoveClippedSubviews() { + return mRemoveClippedSubviews; + } + + public void setDisableIntervalMomentum(boolean disableIntervalMomentum) { + mDisableIntervalMomentum = disableIntervalMomentum; + } + + public void setSendMomentumEvents(boolean sendMomentumEvents) { + mSendMomentumEvents = sendMomentumEvents; + } + + public void setScrollEnabled(boolean scrollEnabled) { + mScrollEnabled = scrollEnabled; + } + + public void setPagingEnabled(boolean pagingEnabled) { + mPagingEnabled = pagingEnabled; + } + + public void setDecelerationRate(float decelerationRate) { + mDecelerationRate = decelerationRate; + + if (mScroller != null) { + mScroller.setFriction(1.0f - mDecelerationRate); + } + } + + public void setSnapInterval(int snapInterval) { + mSnapInterval = snapInterval; + } + + public void setSnapOffsets(List snapOffsets) { + mSnapOffsets = snapOffsets; + } + + public void setSnapToStart(boolean snapToStart) { + mSnapToStart = snapToStart; + } + + public void setSnapToEnd(boolean snapToEnd) { + mSnapToEnd = snapToEnd; + } + + public void flashScrollIndicators() { + awakenScrollBars(); + } + + public void setOverflow(String overflow) { + mOverflow = overflow; + invalidate(); + } + + @Override + protected void onDraw(Canvas canvas) { + getDrawingRect(mRect); + + switch (mOverflow) { + case ViewProps.VISIBLE: + break; + default: + canvas.clipRect(mRect); + break; + } + + super.onDraw(canvas); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + MeasureSpecAssertions.assertExplicitMeasureSpec(widthMeasureSpec, heightMeasureSpec); + + setMeasuredDimension( + MeasureSpec.getSize(widthMeasureSpec), + MeasureSpec.getSize(heightMeasureSpec)); + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + // Call with the present values in order to re-layout if necessary + scrollTo(getScrollX(), getScrollY()); + } + + @Override + protected void onScrollChanged(int x, int y, int oldX, int oldY) { + super.onScrollChanged(x, y, oldX, oldY); + + mActivelyScrolling = true; + + if (mOnScrollDispatchHelper.onScrollChanged(x, y)) { + if (mRemoveClippedSubviews) { + updateClippingRect(); + } + + ReactScrollViewHelper.emitScrollEvent(this); + } + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + if (!mScrollEnabled) { + return false; + } + + try { + if (super.onInterceptTouchEvent(ev)) { + NativeGestureUtil.notifyNativeGestureStarted(this, ev); + ReactScrollViewHelper.emitScrollBeginDragEvent(this); + mDragging = true; + enableFpsListener(); + return true; + } + } catch (IllegalArgumentException e) { + // Log and ignore the error. This seems to be a bug in the android SDK and + // this is the commonly accepted workaround. + // https://tinyurl.com/mw6qkod (Stack Overflow) + Log.w(ReactConstants.TAG, "Error intercepting touch event.", e); + } + + return false; + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + if (!mScrollEnabled) { + return false; + } + + int action = ev.getAction() & MotionEvent.ACTION_MASK; + if (action == MotionEvent.ACTION_UP && mDragging) { + float velocityX = mVelocityHelper.getXVelocity(); + float velocityY = mVelocityHelper.getYVelocity(); + ReactScrollViewHelper.emitScrollEndDragEvent(this); + mDragging = false; + // After the touch finishes, we may need to do some scrolling afterwards either as a result + // of a fling or because we need to page align the content + handlePostTouchScrolling(Math.round(velocityX), Math.round(velocityY)); + } + + return super.onTouchEvent(ev); + } + + @Override + public void fling(int velocityX) { + + // Workaround. + // On Android P if a ScrollView is inverted, we will get a wrong sign for + // velocityX (see https://issuetracker.google.com/issues/112385925). + // At the same time, mOnScrollDispatchHelper tracks the correct velocity direction. + // + // Hence, we can use the absolute value from whatever the OS gives + // us and use the sign of what mOnScrollDispatchHelper has tracked. + final int correctedVelocityX = (int)(Math.abs(velocityX) * Math.signum(mOnScrollDispatchHelper.getXFlingVelocity())); + + if (mPagingEnabled) { + flingAndSnap(correctedVelocityX); + } else if (mScroller != null) { + // FB SCROLLVIEW CHANGE + + // We provide our own version of fling that uses a different call to the standard OverScroller + // which takes into account the possibility of adding new content while the ScrollView is + // animating. Because we give essentially no max X for the fling, the fling will continue as long + // as there is content. See #onOverScrolled() to see the second part of this change which properly + // aborts the scroller animation when we get to the bottom of the ScrollView content. + + int scrollWindowWidth = getWidth() - ViewCompat.getPaddingStart(this) - ViewCompat.getPaddingEnd(this); + + mScroller.fling( + getScrollX(), // startX + getScrollY(), // startY + correctedVelocityX, // velocityX + 0, // velocityY + 0, // minX + Integer.MAX_VALUE, // maxX + 0, // minY + 0, // maxY + scrollWindowWidth / 2, // overX + 0 // overY + ); + + ViewCompat.postInvalidateOnAnimation(this); + + // END FB SCROLLVIEW CHANGE + } else { + super.fling(correctedVelocityX); + } + handlePostTouchScrolling(correctedVelocityX, 0); + } + + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + if (mRemoveClippedSubviews) { + updateClippingRect(); + } + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (mRemoveClippedSubviews) { + updateClippingRect(); + } + } + + @Override + public void updateClippingRect() { + if (!mRemoveClippedSubviews) { + return; + } + + Assertions.assertNotNull(mClippingRect); + + ReactClippingViewGroupHelper.calculateClippingRect(this, mClippingRect); + View contentView = getChildAt(0); + if (contentView instanceof ReactClippingViewGroup) { + ((ReactClippingViewGroup) contentView).updateClippingRect(); + } + } + + @Override + public void getClippingRect(Rect outClippingRect) { + outClippingRect.set(Assertions.assertNotNull(mClippingRect)); + } + + private int getSnapInterval() { + if (mSnapInterval != 0) { + return mSnapInterval; + } + return getWidth(); + } + + public void setEndFillColor(int color) { + if (color != mEndFillColor) { + mEndFillColor = color; + mEndBackground = new ColorDrawable(mEndFillColor); + } + } + + @Override + protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) { + if (mScroller != null) { + // FB SCROLLVIEW CHANGE + + // This is part two of the reimplementation of fling to fix the bounce-back bug. See #fling() for + // more information. + + if (!mScroller.isFinished() && mScroller.getCurrX() != mScroller.getFinalX()) { + int scrollRange = computeHorizontalScrollRange() - getWidth(); + if (scrollX >= scrollRange) { + mScroller.abortAnimation(); + scrollX = scrollRange; + } + } + + // END FB SCROLLVIEW CHANGE + } + + super.onOverScrolled(scrollX, scrollY, clampedX, clampedY); + } + + private void enableFpsListener() { + if (isScrollPerfLoggingEnabled()) { + Assertions.assertNotNull(mFpsListener); + Assertions.assertNotNull(mScrollPerfTag); + mFpsListener.enable(mScrollPerfTag); + } + } + + private void disableFpsListener() { + if (isScrollPerfLoggingEnabled()) { + Assertions.assertNotNull(mFpsListener); + Assertions.assertNotNull(mScrollPerfTag); + mFpsListener.disable(mScrollPerfTag); + } + } + + private boolean isScrollPerfLoggingEnabled() { + return mFpsListener != null && mScrollPerfTag != null && !mScrollPerfTag.isEmpty(); + } + + @Override + public void draw(Canvas canvas) { + if (mEndFillColor != Color.TRANSPARENT) { + final View content = getChildAt(0); + if (mEndBackground != null && content != null && content.getRight() < getWidth()) { + mEndBackground.setBounds(content.getRight(), 0, getWidth(), getHeight()); + mEndBackground.draw(canvas); + } + } + super.draw(canvas); + } + + /** + * This handles any sort of scrolling that may occur after a touch is finished. This may be + * momentum scrolling (fling) or because you have pagingEnabled on the scroll view. Because we + * don't get any events from Android about this lifecycle, we do all our detection by creating a + * runnable that checks if we scrolled in the last frame and if so assumes we are still scrolling. + */ + private void handlePostTouchScrolling(int velocityX, int velocityY) { + // If we aren't going to do anything (send events or snap to page), we can early exit out. + if (!mSendMomentumEvents && !mPagingEnabled && !isScrollPerfLoggingEnabled()) { + return; + } + + // Check if we are already handling this which may occur if this is called by both the touch up + // and a fling call + if (mPostTouchRunnable != null) { + return; + } + + if (mSendMomentumEvents) { + ReactScrollViewHelper.emitScrollMomentumBeginEvent(this); + } + + mActivelyScrolling = false; + mPostTouchRunnable = new Runnable() { + + private boolean mSnappingToPage = false; + + @Override + public void run() { + if (mActivelyScrolling) { + // We are still scrolling so we just post to check again a frame later + mActivelyScrolling = false; + ViewCompat.postOnAnimationDelayed(ReactHorizontalScrollView.this, + this, + ReactScrollViewHelper.MOMENTUM_DELAY); + } else { + if (mPagingEnabled && !mSnappingToPage) { + // Only if we have pagingEnabled and we have not snapped to the page do we + // need to continue checking for the scroll. And we cause that scroll by asking for it + mSnappingToPage = true; + flingAndSnap(0); + ViewCompat.postOnAnimationDelayed(ReactHorizontalScrollView.this, + this, + ReactScrollViewHelper.MOMENTUM_DELAY); + } else { + if (mSendMomentumEvents) { + ReactScrollViewHelper.emitScrollMomentumEndEvent(ReactHorizontalScrollView.this); + } + ReactHorizontalScrollView.this.mPostTouchRunnable = null; + disableFpsListener(); + } + } + } + }; + ViewCompat.postOnAnimationDelayed(ReactHorizontalScrollView.this, + mPostTouchRunnable, + ReactScrollViewHelper.MOMENTUM_DELAY); + } + + private int predictFinalScrollPosition(int velocityX) { + // ScrollView can *only* scroll for 250ms when using smoothScrollTo and there's + // no way to customize the scroll duration. So, we create a temporary OverScroller + // so we can predict where a fling would land and snap to nearby that point. + OverScroller scroller = new OverScroller(getContext()); + scroller.setFriction(1.0f - mDecelerationRate); + + // predict where a fling would end up so we can scroll to the nearest snap offset + int maximumOffset = Math.max(0, computeHorizontalScrollRange() - getWidth()); + int width = getWidth() - ViewCompat.getPaddingStart(this) - ViewCompat.getPaddingEnd(this); + scroller.fling( + getScrollX(), // startX + getScrollY(), // startY + velocityX, // velocityX + 0, // velocityY + 0, // minX + maximumOffset, // maxX + 0, // minY + 0, // maxY + width/2, // overX + 0 // overY + ); + return scroller.getFinalX(); + } + + /** + * This will smooth scroll us to the nearest snap offset point + * It currently just looks at where the content is and slides to the nearest point. + * It is intended to be run after we are done scrolling, and handling any momentum scrolling. + */ + private void smoothScrollAndSnap(int velocity) { + double interval = (double) getSnapInterval(); + double currentOffset = (double) getScrollX(); + double targetOffset = (double) predictFinalScrollPosition(velocity); + + int previousPage = (int) Math.floor(currentOffset / interval); + int nextPage = (int) Math.ceil(currentOffset / interval); + int currentPage = (int) Math.round(currentOffset / interval); + int targetPage = (int) Math.round(targetOffset / interval); + + if (velocity > 0 && nextPage == previousPage) { + nextPage ++; + } else if (velocity < 0 && previousPage == nextPage) { + previousPage --; + } + + if ( + // if scrolling towards next page + velocity > 0 && + // and the middle of the page hasn't been crossed already + currentPage < nextPage && + // and it would have been crossed after flinging + targetPage > previousPage + ) { + currentPage = nextPage; + } + else if ( + // if scrolling towards previous page + velocity < 0 && + // and the middle of the page hasn't been crossed already + currentPage > previousPage && + // and it would have been crossed after flinging + targetPage < nextPage + ) { + currentPage = previousPage; + } + + targetOffset = currentPage * interval; + if (targetOffset != currentOffset) { + mActivelyScrolling = true; + smoothScrollTo((int) targetOffset, getScrollY()); + } + } + + private void flingAndSnap(int velocityX) { + if (getChildCount() <= 0) { + return; + } + + // pagingEnabled only allows snapping one interval at a time + if (mSnapInterval == 0 && mSnapOffsets == null) { + smoothScrollAndSnap(velocityX); + return; + } + + int maximumOffset = Math.max(0, computeHorizontalScrollRange() - getWidth()); + int targetOffset = predictFinalScrollPosition(velocityX); + if (mDisableIntervalMomentum) { + targetOffset = getScrollX(); + } + + int smallerOffset = 0; + int largerOffset = maximumOffset; + int firstOffset = 0; + int lastOffset = maximumOffset; + int width = getWidth() - ViewCompat.getPaddingStart(this) - ViewCompat.getPaddingEnd(this); + + // offsets are from the right edge in RTL layouts + boolean isRTL = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL; + if (isRTL) { + targetOffset = maximumOffset - targetOffset; + velocityX = -velocityX; + } + + // get the nearest snap points to the target offset + if (mSnapOffsets != null) { + firstOffset = mSnapOffsets.get(0); + lastOffset = mSnapOffsets.get(mSnapOffsets.size() - 1); + + for (int i = 0; i < mSnapOffsets.size(); i ++) { + int offset = mSnapOffsets.get(i); + + if (offset <= targetOffset) { + if (targetOffset - offset < targetOffset - smallerOffset) { + smallerOffset = offset; + } + } + + if (offset >= targetOffset) { + if (offset - targetOffset < largerOffset - targetOffset) { + largerOffset = offset; + } + } + } + } else { + double interval = (double) getSnapInterval(); + double ratio = (double) targetOffset / interval; + smallerOffset = (int) (Math.floor(ratio) * interval); + largerOffset = Math.min((int) (Math.ceil(ratio) * interval), maximumOffset); + } + + // Calculate the nearest offset + int nearestOffset = targetOffset - smallerOffset < largerOffset - targetOffset + ? smallerOffset + : largerOffset; + + // if scrolling after the last snap offset and snapping to the + // end of the list is disabled, then we allow free scrolling + int currentOffset = getScrollX(); + if (isRTL) { + currentOffset = maximumOffset - currentOffset; + } + if (!mSnapToEnd && targetOffset >= lastOffset) { + if (currentOffset >= lastOffset) { + // free scrolling + } else { + // snap to end + targetOffset = lastOffset; + } + } else if (!mSnapToStart && targetOffset <= firstOffset) { + if (currentOffset <= firstOffset) { + // free scrolling + } else { + // snap to beginning + targetOffset = firstOffset; + } + } else if (velocityX > 0) { + // when snapping velocity can feel sluggish for slow swipes + velocityX += (int) ((largerOffset - targetOffset) * 10.0); + + targetOffset = largerOffset; + } else if (velocityX < 0) { + // when snapping velocity can feel sluggish for slow swipes + velocityX -= (int) ((targetOffset - smallerOffset) * 10.0); + + targetOffset = smallerOffset; + } else { + targetOffset = nearestOffset; + } + + // Make sure the new offset isn't out of bounds + targetOffset = Math.min(Math.max(0, targetOffset), maximumOffset); + + if (isRTL) { + targetOffset = maximumOffset - targetOffset; + velocityX = -velocityX; + } + + // smoothScrollTo will always scroll over 250ms which is often *waaay* + // too short and will cause the scrolling to feel almost instant + // try to manually interact with OverScroller instead + // if velocity is 0 however, fling() won't work, so we want to use smoothScrollTo + if (mScroller != null) { + mActivelyScrolling = true; + + mScroller.fling( + getScrollX(), // startX + getScrollY(), // startY + // velocity = 0 doesn't work with fling() so we pretend there's a reasonable + // initial velocity going on when a touch is released without any movement + velocityX != 0 ? velocityX : targetOffset - getScrollX(), // velocityX + 0, // velocityY + // setting both minX and maxX to the same value will guarantee that we scroll to it + // but using the standard fling-style easing rather than smoothScrollTo's 250ms animation + targetOffset, // minX + targetOffset, // maxX + 0, // minY + 0, // maxY + // we only want to allow overscrolling if the final offset is at the very edge of the view + (targetOffset == 0 || targetOffset == maximumOffset) ? width / 2 : 0, // overX + 0 // overY + ); + + postInvalidateOnAnimation(); + } else { + smoothScrollTo(targetOffset, getScrollY()); + } + } + + @Override + public void setBackgroundColor(int color) { + mReactBackgroundManager.setBackgroundColor(color); + } + + public void setBorderWidth(int position, float width) { + mReactBackgroundManager.setBorderWidth(position, width); + } + + public void setBorderColor(int position, float color, float alpha) { + mReactBackgroundManager.setBorderColor(position, color, alpha); + } + + public void setBorderRadius(float borderRadius) { + mReactBackgroundManager.setBorderRadius(borderRadius); + } + + public void setBorderRadius(float borderRadius, int position) { + mReactBackgroundManager.setBorderRadius(borderRadius, position); + } + + public void setBorderStyle(@Nullable String style) { + mReactBackgroundManager.setBorderStyle(style); + } + +} diff --git a/android/src/main/java/com/rnnestedscrollview/ReactHorizontalScrollViewManager.java b/android/src/main/java/com/rnnestedscrollview/ReactHorizontalScrollViewManager.java new file mode 100644 index 0000000..8a3e651 --- /dev/null +++ b/android/src/main/java/com/rnnestedscrollview/ReactHorizontalScrollViewManager.java @@ -0,0 +1,273 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.rnnestedscrollview; + +import android.graphics.Color; +import android.util.DisplayMetrics; + +import androidx.core.view.ViewCompat; + +import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.module.annotations.ReactModule; +import com.facebook.react.uimanager.DisplayMetricsHolder; +import com.facebook.react.uimanager.PixelUtil; +import com.facebook.react.uimanager.ReactClippingViewGroupHelper; +import com.facebook.react.uimanager.Spacing; +import com.facebook.react.uimanager.ThemedReactContext; +import com.facebook.react.uimanager.ViewGroupManager; +import com.facebook.react.uimanager.ViewProps; +import com.facebook.react.uimanager.annotations.ReactProp; +import com.facebook.react.uimanager.annotations.ReactPropGroup; +import com.facebook.react.views.scroll.FpsListener; +import com.facebook.react.views.scroll.ReactScrollViewCommandHelper; +import com.facebook.yoga.YogaConstants; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.Nullable; + +/** + * View manager for {@link ReactHorizontalScrollView} components. + * + *

Note that {@link ReactScrollView} and {@link ReactHorizontalScrollView} are exposed to JS + * as a single ScrollView component, configured via the {@code horizontal} boolean property. + */ +@ReactModule(name = ReactHorizontalScrollViewManager.REACT_CLASS) +public class ReactHorizontalScrollViewManager + extends ViewGroupManager + implements ReactScrollViewCommandHelper.ScrollCommandHandler { + + public static final String REACT_CLASS = "AndroidHorizontalScrollView"; + + private static final int[] SPACING_TYPES = { + Spacing.ALL, Spacing.LEFT, Spacing.RIGHT, Spacing.TOP, Spacing.BOTTOM, + }; + + private @Nullable + FpsListener mFpsListener = null; + + public ReactHorizontalScrollViewManager() { + this(null); + } + + public ReactHorizontalScrollViewManager(@Nullable FpsListener fpsListener) { + mFpsListener = fpsListener; + } + + @Override + public String getName() { + return REACT_CLASS; + } + + @Override + public ReactHorizontalScrollView createViewInstance(ThemedReactContext context) { + return new ReactHorizontalScrollView(context, mFpsListener); + } + + @ReactProp(name = "scrollEnabled", defaultBoolean = true) + public void setScrollEnabled(ReactHorizontalScrollView view, boolean value) { + view.setScrollEnabled(value); + } + + @ReactProp(name = "showsHorizontalScrollIndicator") + public void setShowsHorizontalScrollIndicator(ReactHorizontalScrollView view, boolean value) { + view.setHorizontalScrollBarEnabled(value); + } + + @ReactProp(name = "decelerationRate") + public void setDecelerationRate(ReactHorizontalScrollView view, float decelerationRate) { + view.setDecelerationRate(decelerationRate); + } + + @ReactProp(name = "disableIntervalMomentum") + public void setDisableIntervalMomentum(ReactHorizontalScrollView view, boolean disbaleIntervalMomentum) { + view.setDisableIntervalMomentum(disbaleIntervalMomentum); + } + + @ReactProp(name = "snapToInterval") + public void setSnapToInterval(ReactHorizontalScrollView view, float snapToInterval) { + // snapToInterval needs to be exposed as a float because of the Javascript interface. + DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics(); + view.setSnapInterval((int) (snapToInterval * screenDisplayMetrics.density)); + } + + @ReactProp(name = "snapToOffsets") + public void setSnapToOffsets(ReactHorizontalScrollView view, @Nullable ReadableArray snapToOffsets) { + DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics(); + List offsets = new ArrayList(); + for (int i = 0; i < snapToOffsets.size(); i++) { + offsets.add((int) (snapToOffsets.getDouble(i) * screenDisplayMetrics.density)); + } + view.setSnapOffsets(offsets); + } + + @ReactProp(name = "snapToStart") + public void setSnapToStart(ReactHorizontalScrollView view, boolean snapToStart) { + view.setSnapToStart(snapToStart); + } + + @ReactProp(name = "snapToEnd") + public void setSnapToEnd(ReactHorizontalScrollView view, boolean snapToEnd) { + view.setSnapToEnd(snapToEnd); + } + + @ReactProp(name = ReactClippingViewGroupHelper.PROP_REMOVE_CLIPPED_SUBVIEWS) + public void setRemoveClippedSubviews(ReactHorizontalScrollView view, boolean removeClippedSubviews) { + view.setRemoveClippedSubviews(removeClippedSubviews); + } + + /** + * Computing momentum events is potentially expensive since we post a runnable on the UI thread + * to see when it is done. We only do that if {@param sendMomentumEvents} is set to true. This + * is handled automatically in js by checking if there is a listener on the momentum events. + * + * @param view + * @param sendMomentumEvents + */ + @ReactProp(name = "sendMomentumEvents") + public void setSendMomentumEvents(ReactHorizontalScrollView view, boolean sendMomentumEvents) { + view.setSendMomentumEvents(sendMomentumEvents); + } + + /** + * Tag used for logging scroll performance on this scroll view. Will force momentum events to be + * turned on (see setSendMomentumEvents). + * + * @param view + * @param scrollPerfTag + */ + @ReactProp(name = "scrollPerfTag") + public void setScrollPerfTag(ReactHorizontalScrollView view, String scrollPerfTag) { + view.setScrollPerfTag(scrollPerfTag); + } + + @ReactProp(name = "pagingEnabled") + public void setPagingEnabled(ReactHorizontalScrollView view, boolean pagingEnabled) { + view.setPagingEnabled(pagingEnabled); + } + + /** + * Controls overScroll behaviour + */ + @ReactProp(name = "overScrollMode") + public void setOverScrollMode(ReactHorizontalScrollView view, String value) { + view.setOverScrollMode(ReactScrollViewHelper.parseOverScrollMode(value)); + } + + @ReactProp(name = "nestedScrollEnabled") + public void setNestedScrollEnabled(ReactHorizontalScrollView view, boolean value) { + ViewCompat.setNestedScrollingEnabled(view, value); + } + + @Override + public void receiveCommand( + ReactHorizontalScrollView scrollView, + int commandId, + @Nullable ReadableArray args) { + ReactScrollViewCommandHelper.receiveCommand(this, scrollView, commandId, args); + } + + @Override + public void flashScrollIndicators(ReactHorizontalScrollView scrollView) { + scrollView.flashScrollIndicators(); + } + + @Override + public void scrollTo( + ReactHorizontalScrollView scrollView, ReactScrollViewCommandHelper.ScrollToCommandData data) { + if (data.mAnimated) { + scrollView.smoothScrollTo(data.mDestX, data.mDestY); + } else { + scrollView.scrollTo(data.mDestX, data.mDestY); + } + } + + @Override + public void scrollToEnd( + ReactHorizontalScrollView scrollView, + ReactScrollViewCommandHelper.ScrollToEndCommandData data) { + // ScrollView always has one child - the scrollable area + int right = + scrollView.getChildAt(0).getWidth() + scrollView.getPaddingRight(); + if (data.mAnimated) { + scrollView.smoothScrollTo(right, scrollView.getScrollY()); + } else { + scrollView.scrollTo(right, scrollView.getScrollY()); + } + } + + /** + * When set, fills the rest of the scrollview with a color to avoid setting a background and + * creating unnecessary overdraw. + * @param view + * @param color + */ + @ReactProp(name = "endFillColor", defaultInt = Color.TRANSPARENT, customType = "Color") + public void setBottomFillColor(ReactHorizontalScrollView view, int color) { + view.setEndFillColor(color); + } + + @ReactPropGroup(names = { + ViewProps.BORDER_RADIUS, + ViewProps.BORDER_TOP_LEFT_RADIUS, + ViewProps.BORDER_TOP_RIGHT_RADIUS, + ViewProps.BORDER_BOTTOM_RIGHT_RADIUS, + ViewProps.BORDER_BOTTOM_LEFT_RADIUS + }, defaultFloat = YogaConstants.UNDEFINED) + public void setBorderRadius(ReactHorizontalScrollView view, int index, float borderRadius) { + if (!YogaConstants.isUndefined(borderRadius)) { + borderRadius = PixelUtil.toPixelFromDIP(borderRadius); + } + + if (index == 0) { + view.setBorderRadius(borderRadius); + } else { + view.setBorderRadius(borderRadius, index - 1); + } + } + + @ReactProp(name = "borderStyle") + public void setBorderStyle(ReactHorizontalScrollView view, @Nullable String borderStyle) { + view.setBorderStyle(borderStyle); + } + + @ReactPropGroup(names = { + ViewProps.BORDER_WIDTH, + ViewProps.BORDER_LEFT_WIDTH, + ViewProps.BORDER_RIGHT_WIDTH, + ViewProps.BORDER_TOP_WIDTH, + ViewProps.BORDER_BOTTOM_WIDTH, + }, defaultFloat = YogaConstants.UNDEFINED) + public void setBorderWidth(ReactHorizontalScrollView view, int index, float width) { + if (!YogaConstants.isUndefined(width)) { + width = PixelUtil.toPixelFromDIP(width); + } + view.setBorderWidth(SPACING_TYPES[index], width); + } + + @ReactPropGroup(names = { + "borderColor", "borderLeftColor", "borderRightColor", "borderTopColor", "borderBottomColor" + }, customType = "Color") + public void setBorderColor(ReactHorizontalScrollView view, int index, Integer color) { + float rgbComponent = + color == null ? YogaConstants.UNDEFINED : (float) ((int)color & 0x00FFFFFF); + float alphaComponent = color == null ? YogaConstants.UNDEFINED : (float) ((int)color >>> 24); + view.setBorderColor(SPACING_TYPES[index], rgbComponent, alphaComponent); + } + + @ReactProp(name = "overflow") + public void setOverflow(ReactHorizontalScrollView view, @Nullable String overflow) { + view.setOverflow(overflow); + } + + @ReactProp(name = "persistentScrollbar") + public void setPersistentScrollbar(ReactHorizontalScrollView view, boolean value) { + view.setScrollbarFadingEnabled(!value); + } +} diff --git a/android/src/main/java/com/rnnestedscrollview/ReactNestedScrollView.java b/android/src/main/java/com/rnnestedscrollview/ReactNestedScrollView.java index a7f8967..ed93b05 100644 --- a/android/src/main/java/com/rnnestedscrollview/ReactNestedScrollView.java +++ b/android/src/main/java/com/rnnestedscrollview/ReactNestedScrollView.java @@ -13,29 +13,31 @@ import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; -import androidx.core.widget.NestedScrollView; -import androidx.core.view.ViewCompat; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.OverScroller; +import androidx.core.view.ViewCompat; +import androidx.core.widget.NestedScrollView; + import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.ReactContext; import com.facebook.react.common.ReactConstants; -import com.facebook.react.views.scroll.FpsListener; -import com.facebook.react.views.scroll.OnScrollDispatchHelper; -import com.facebook.react.views.scroll.VelocityHelper; -import com.facebook.react.views.scroll.ReactScrollViewHelper; -import com.facebook.react.uimanager.events.NativeGestureUtil; import com.facebook.react.uimanager.MeasureSpecAssertions; import com.facebook.react.uimanager.ReactClippingViewGroup; import com.facebook.react.uimanager.ReactClippingViewGroupHelper; import com.facebook.react.uimanager.ViewProps; +import com.facebook.react.uimanager.events.NativeGestureUtil; +import com.facebook.react.views.scroll.FpsListener; +import com.facebook.react.views.scroll.OnScrollDispatchHelper; +import com.facebook.react.views.scroll.VelocityHelper; import com.facebook.react.views.view.ReactViewBackgroundManager; + import java.lang.reflect.Field; import java.util.List; + import javax.annotation.Nullable; /** @@ -54,8 +56,8 @@ public class ReactNestedScrollView extends NestedScrollView implements ReactClip private static boolean sTriedToGetScrollerField = false; private final OnScrollDispatchHelper mOnScrollDispatchHelper = new OnScrollDispatchHelper(); - private final @Nullable OverScroller mScroller; private final VelocityHelper mVelocityHelper = new VelocityHelper(); + private final @Nullable OverScroller mScroller; private final Rect mRect = new Rect(); // for reuse to avoid allocation private boolean mActivelyScrolling; @@ -223,10 +225,7 @@ protected void onScrollChanged(int x, int y, int oldX, int oldY) { updateClippingRect(); } - ReactScrollViewHelper.emitScrollEvent( - this, - mOnScrollDispatchHelper.getXFlingVelocity(), - mOnScrollDispatchHelper.getYFlingVelocity()); + ReactScrollViewHelper.emitScrollEvent(this); } } @@ -260,15 +259,11 @@ public boolean onTouchEvent(MotionEvent ev) { return false; } - mVelocityHelper.calculateVelocity(ev); int action = ev.getAction() & MotionEvent.ACTION_MASK; if (action == MotionEvent.ACTION_UP && mDragging) { float velocityX = mVelocityHelper.getXVelocity(); float velocityY = mVelocityHelper.getYVelocity(); - ReactScrollViewHelper.emitScrollEndDragEvent( - this, - velocityX, - velocityY); + ReactScrollViewHelper.emitScrollEndDragEvent(this); mDragging = false; // After the touch finishes, we may need to do some scrolling afterwards either as a result // of a fling or because we need to page align the content @@ -433,7 +428,7 @@ private void handlePostTouchScrolling(int velocityX, int velocityY) { if (mSendMomentumEvents) { enableFpsListener(); - ReactScrollViewHelper.emitScrollMomentumBeginEvent(this, velocityX, velocityY); + ReactScrollViewHelper.emitScrollMomentumBeginEvent(this); } mActivelyScrolling = false; diff --git a/android/src/main/java/com/rnnestedscrollview/ReactNestedScrollViewManager.java b/android/src/main/java/com/rnnestedscrollview/ReactNestedScrollViewManager.java index cc614dd..2182dd6 100644 --- a/android/src/main/java/com/rnnestedscrollview/ReactNestedScrollViewManager.java +++ b/android/src/main/java/com/rnnestedscrollview/ReactNestedScrollViewManager.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. @@ -7,11 +7,11 @@ package com.rnnestedscrollview; -import android.annotation.TargetApi; import android.graphics.Color; -import androidx.core.view.ViewCompat; import android.util.DisplayMetrics; +import androidx.core.view.ViewCompat; + import com.facebook.react.bridge.ReadableArray; import com.facebook.react.common.MapBuilder; import com.facebook.react.module.annotations.ReactModule; @@ -24,15 +24,15 @@ import com.facebook.react.uimanager.ViewProps; import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactPropGroup; -import com.facebook.yoga.YogaConstants; import com.facebook.react.views.scroll.FpsListener; -import com.facebook.react.views.scroll.ScrollEventType; -import com.facebook.react.views.scroll.ReactScrollViewHelper; import com.facebook.react.views.scroll.ReactScrollViewCommandHelper; +import com.facebook.react.views.scroll.ScrollEventType; +import com.facebook.yoga.YogaConstants; import java.util.ArrayList; import java.util.List; import java.util.Map; + import javax.annotation.Nullable; /** diff --git a/android/src/main/java/com/rnnestedscrollview/ReactScrollViewHelper.java b/android/src/main/java/com/rnnestedscrollview/ReactScrollViewHelper.java new file mode 100644 index 0000000..6044932 --- /dev/null +++ b/android/src/main/java/com/rnnestedscrollview/ReactScrollViewHelper.java @@ -0,0 +1,82 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.rnnestedscrollview; + +import android.view.View; +import android.view.ViewGroup; + +import com.facebook.react.bridge.JSApplicationIllegalArgumentException; +import com.facebook.react.bridge.ReactContext; +import com.facebook.react.uimanager.UIManagerModule; +import com.facebook.react.views.scroll.ScrollEventType; + +/** + * Helper class that deals with emitting Scroll Events. + */ +public class ReactScrollViewHelper { + + public static final long MOMENTUM_DELAY = 20; + public static final String OVER_SCROLL_ALWAYS = "always"; + public static final String AUTO = "auto"; + public static final String OVER_SCROLL_NEVER = "never"; + + /** + * Shared by {@link ReactScrollView} and {@link ReactHorizontalScrollView}. + */ + public static void emitScrollEvent(ViewGroup scrollView) { + emitScrollEvent(scrollView, ScrollEventType.SCROLL); + } + + public static void emitScrollBeginDragEvent(ViewGroup scrollView) { + emitScrollEvent(scrollView, ScrollEventType.BEGIN_DRAG); + } + + public static void emitScrollEndDragEvent(ViewGroup scrollView) { + emitScrollEvent(scrollView, ScrollEventType.END_DRAG); + } + + public static void emitScrollMomentumBeginEvent(ViewGroup scrollView) { + emitScrollEvent(scrollView, ScrollEventType.MOMENTUM_BEGIN); + } + + public static void emitScrollMomentumEndEvent(ViewGroup scrollView) { + emitScrollEvent(scrollView, ScrollEventType.MOMENTUM_END); + } + + private static void emitScrollEvent(ViewGroup scrollView, ScrollEventType scrollEventType) { + View contentView = scrollView.getChildAt(0); + + if (contentView == null) { + return; + } + + ReactContext reactContext = (ReactContext) scrollView.getContext(); + reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent( + ScrollEvent.obtain( + scrollView.getId(), + scrollEventType, + scrollView.getScrollX(), + scrollView.getScrollY(), + contentView.getWidth(), + contentView.getHeight(), + scrollView.getWidth(), + scrollView.getHeight())); + } + + public static int parseOverScrollMode(String jsOverScrollMode) { + if (jsOverScrollMode == null || jsOverScrollMode.equals(AUTO)) { + return View.OVER_SCROLL_IF_CONTENT_SCROLLS; + } else if (jsOverScrollMode.equals(OVER_SCROLL_ALWAYS)) { + return View.OVER_SCROLL_ALWAYS; + } else if (jsOverScrollMode.equals(OVER_SCROLL_NEVER)) { + return View.OVER_SCROLL_NEVER; + } else { + throw new JSApplicationIllegalArgumentException("wrong overScrollMode: " + jsOverScrollMode); + } + } +} diff --git a/android/src/main/java/com/rnnestedscrollview/ScrollEvent.java b/android/src/main/java/com/rnnestedscrollview/ScrollEvent.java new file mode 100644 index 0000000..bd1b08b --- /dev/null +++ b/android/src/main/java/com/rnnestedscrollview/ScrollEvent.java @@ -0,0 +1,144 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.rnnestedscrollview; + +import androidx.core.util.Pools; + +import com.facebook.infer.annotation.Assertions; +import com.facebook.react.bridge.Arguments; +import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.PixelUtil; +import com.facebook.react.uimanager.events.Event; +import com.facebook.react.uimanager.events.RCTEventEmitter; +import com.facebook.react.views.scroll.ScrollEventType; + +import javax.annotation.Nullable; + +/** + * A event dispatched from a ScrollView scrolling. + */ +public class ScrollEvent extends Event { + + private static final Pools.SynchronizedPool EVENTS_POOL = + new Pools.SynchronizedPool<>(3); + + private int mScrollX; + private int mScrollY; + private int mContentWidth; + private int mContentHeight; + private int mScrollViewWidth; + private int mScrollViewHeight; + private @Nullable ScrollEventType mScrollEventType; + + public static ScrollEvent obtain( + int viewTag, + ScrollEventType scrollEventType, + int scrollX, + int scrollY, + int contentWidth, + int contentHeight, + int scrollViewWidth, + int scrollViewHeight) { + ScrollEvent event = EVENTS_POOL.acquire(); + if (event == null) { + event = new ScrollEvent(); + } + event.init( + viewTag, + scrollEventType, + scrollX, + scrollY, + contentWidth, + contentHeight, + scrollViewWidth, + scrollViewHeight); + return event; + } + + @Override + public void onDispose() { + EVENTS_POOL.release(this); + } + + private ScrollEvent() { + } + + private void init( + int viewTag, + ScrollEventType scrollEventType, + int scrollX, + int scrollY, + int contentWidth, + int contentHeight, + int scrollViewWidth, + int scrollViewHeight) { + super.init(viewTag); + mScrollEventType = scrollEventType; + mScrollX = scrollX; + mScrollY = scrollY; + mContentWidth = contentWidth; + mContentHeight = contentHeight; + mScrollViewWidth = scrollViewWidth; + mScrollViewHeight = scrollViewHeight; + } + + @Override + public String getEventName() { + return ScrollEventType.getJSEventName(Assertions.assertNotNull(mScrollEventType)); + } + + @Override + public short getCoalescingKey() { + // All scroll events for a given view can be coalesced + return 0; + } + + @Override + public boolean canCoalesce() { + // Only SCROLL events can be coalesced, all others can not be + if (mScrollEventType == ScrollEventType.SCROLL) { + return true; + } + return false; + } + + @Override + public void dispatch(RCTEventEmitter rctEventEmitter) { + rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); + } + + private WritableMap serializeEventData() { + WritableMap contentInset = Arguments.createMap(); + contentInset.putDouble("top", 0); + contentInset.putDouble("bottom", 0); + contentInset.putDouble("left", 0); + contentInset.putDouble("right", 0); + + WritableMap contentOffset = Arguments.createMap(); + contentOffset.putDouble("x", PixelUtil.toDIPFromPixel(mScrollX)); + contentOffset.putDouble("y", PixelUtil.toDIPFromPixel(mScrollY)); + + WritableMap contentSize = Arguments.createMap(); + contentSize.putDouble("width", PixelUtil.toDIPFromPixel(mContentWidth)); + contentSize.putDouble("height", PixelUtil.toDIPFromPixel(mContentHeight)); + + WritableMap layoutMeasurement = Arguments.createMap(); + layoutMeasurement.putDouble("width", PixelUtil.toDIPFromPixel(mScrollViewWidth)); + layoutMeasurement.putDouble("height", PixelUtil.toDIPFromPixel(mScrollViewHeight)); + + WritableMap event = Arguments.createMap(); + event.putMap("contentInset", contentInset); + event.putMap("contentOffset", contentOffset); + event.putMap("contentSize", contentSize); + event.putMap("layoutMeasurement", layoutMeasurement); + + event.putInt("target", getViewTag()); + event.putBoolean("responderIgnoreScroll", true); + return event; + } +} diff --git a/index.js b/index.js index e03520a..a0ac5f2 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ import { Platform, ScrollView } from 'react-native'; export default Platform.OS === 'android' - ? require('./lib/NestedScrollView') + ? require('./lib/ScrollView') : ScrollView; diff --git a/lib/NestedScrollView.js b/lib/NestedScrollView.js deleted file mode 100644 index 0481a4f..0000000 --- a/lib/NestedScrollView.js +++ /dev/null @@ -1,1155 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * Forked from https://github.com/facebook/react-native/blob/0.56-stable/Libraries/Components/ScrollView/ScrollView.js - * - * @format - * @flow - */ - -'use strict'; - -const React = require('react'); -const ReactNative = require('react-native'); - -const { - View, - Platform, - StyleSheet, - requireNativeComponent, -} = ReactNative; - -const AnimatedImplementation = require('react-native/Libraries/Animated/src/AnimatedImplementation'); -const ScrollResponder = require('react-native/Libraries/Components/ScrollResponder'); -const ScrollViewStickyHeader = require('react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader'); - -const createReactClass = require('create-react-class'); -const dismissKeyboard = require('react-native/Libraries/Utilities/dismissKeyboard'); -const flattenStyle = require('react-native/Libraries/StyleSheet/flattenStyle'); -const invariant = require('fbjs/lib/invariant'); -const processDecelerationRate = require('react-native/Libraries/Components/ScrollView/processDecelerationRate'); -const warning = require('fbjs/lib/warning'); -const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource'); - -import type {PressEvent} from 'CoreEventTypes'; -import type {EdgeInsetsProp} from 'EdgeInsetsPropType'; -import type {NativeMethodsMixinType} from 'ReactNativeTypes'; -import type {ViewStyleProp} from 'StyleSheet'; -import type {ViewProps} from 'ViewPropTypes'; -import type {PointProp} from 'PointPropType'; - -import type {ColorValue} from 'StyleSheetTypes'; - -let AndroidScrollView; -let AndroidHorizontalScrollContentView; -let AndroidHorizontalScrollView; -let RCTScrollView; -let RCTScrollContentView; - -if (Platform.OS === 'android') { - AndroidScrollView = requireNativeComponent('RCTNestedScrollView'); - AndroidHorizontalScrollView = requireNativeComponent( - 'AndroidHorizontalNestedScrollView', - ); - AndroidHorizontalScrollContentView = requireNativeComponent( - 'AndroidHorizontalNestedScrollContentView', - ); -} else if (Platform.OS === 'ios') { - RCTScrollView = requireNativeComponent('RCTScrollView'); - RCTScrollContentView = requireNativeComponent('RCTScrollContentView'); -} else { - RCTScrollView = requireNativeComponent('RCTScrollView'); - RCTScrollContentView = requireNativeComponent('RCTScrollContentView'); -} - -type TouchableProps = $ReadOnly<{| - onTouchStart?: (event: PressEvent) => void, - onTouchMove?: (event: PressEvent) => void, - onTouchEnd?: (event: PressEvent) => void, - onTouchCancel?: (event: PressEvent) => void, - onTouchEndCapture?: (event: PressEvent) => void, -|}>; - -type IOSProps = $ReadOnly<{| - /** - * Controls whether iOS should automatically adjust the content inset - * for scroll views that are placed behind a navigation bar or - * tab bar/ toolbar. The default value is true. - * @platform ios - */ - automaticallyAdjustContentInsets?: ?boolean, - /** - * The amount by which the scroll view content is inset from the edges - * of the scroll view. Defaults to `{top: 0, left: 0, bottom: 0, right: 0}`. - * @platform ios - */ - contentInset?: ?EdgeInsetsProp, - /** - * Used to manually set the starting scroll offset. - * The default value is `{x: 0, y: 0}`. - * @platform ios - */ - contentOffset?: ?PointProp, - /** - * When true, the scroll view bounces when it reaches the end of the - * content if the content is larger then the scroll view along the axis of - * the scroll direction. When false, it disables all bouncing even if - * the `alwaysBounce*` props are true. The default value is true. - * @platform ios - */ - bounces?: ?boolean, - /** - * By default, ScrollView has an active pan responder that hijacks panresponders - * deeper in the render tree in order to prevent accidental touches while scrolling. - * However, in certain occasions (such as when using snapToInterval) in a vertical scrollview - * You may want to disable this behavior in order to prevent the ScrollView from blocking touches - */ - disableScrollViewPanResponder?: ?boolean, - /** - * When true, gestures can drive zoom past min/max and the zoom will animate - * to the min/max value at gesture end, otherwise the zoom will not exceed - * the limits. - * @platform ios - */ - bouncesZoom?: ?boolean, - /** - * When true, the scroll view bounces horizontally when it reaches the end - * even if the content is smaller than the scroll view itself. The default - * value is true when `horizontal={true}` and false otherwise. - * @platform ios - */ - alwaysBounceHorizontal?: ?boolean, - /** - * When true, the scroll view bounces vertically when it reaches the end - * even if the content is smaller than the scroll view itself. The default - * value is false when `horizontal={true}` and true otherwise. - * @platform ios - */ - alwaysBounceVertical?: ?boolean, - /** - * When true, the scroll view automatically centers the content when the - * content is smaller than the scroll view bounds; when the content is - * larger than the scroll view, this property has no effect. The default - * value is false. - * @platform ios - */ - centerContent?: ?boolean, - /** - * The style of the scroll indicators. - * - * - `'default'` (the default), same as `black`. - * - `'black'`, scroll indicator is black. This style is good against a light background. - * - `'white'`, scroll indicator is white. This style is good against a dark background. - * - * @platform ios - */ - indicatorStyle?: ?('default' | 'black' | 'white'), - /** - * When true, the ScrollView will try to lock to only vertical or horizontal - * scrolling while dragging. The default value is false. - * @platform ios - */ - directionalLockEnabled?: ?boolean, - /** - * When false, once tracking starts, won't try to drag if the touch moves. - * The default value is true. - * @platform ios - */ - canCancelContentTouches?: ?boolean, - /** - * When set, the scroll view will adjust the scroll position so that the first child that is - * currently visible and at or beyond `minIndexForVisible` will not change position. This is - * useful for lists that are loading content in both directions, e.g. a chat thread, where new - * messages coming in might otherwise cause the scroll position to jump. A value of 0 is common, - * but other values such as 1 can be used to skip loading spinners or other content that should - * not maintain position. - * - * The optional `autoscrollToTopThreshold` can be used to make the content automatically scroll - * to the top after making the adjustment if the user was within the threshold of the top before - * the adjustment was made. This is also useful for chat-like applications where you want to see - * new messages scroll into place, but not if the user has scrolled up a ways and it would be - * disruptive to scroll a bunch. - * - * Caveat 1: Reordering elements in the scrollview with this enabled will probably cause - * jumpiness and jank. It can be fixed, but there are currently no plans to do so. For now, - * don't re-order the content of any ScrollViews or Lists that use this feature. - * - * Caveat 2: This simply uses `contentOffset` and `frame.origin` in native code to compute - * visibility. Occlusion, transforms, and other complexity won't be taken into account as to - * whether content is "visible" or not. - * - * @platform ios - */ - maintainVisibleContentPosition?: ?$ReadOnly<{| - minIndexForVisible: number, - autoscrollToTopThreshold?: ?number, - |}>, - /** - * The maximum allowed zoom scale. The default value is 1.0. - * @platform ios - */ - maximumZoomScale?: ?number, - /** - * The minimum allowed zoom scale. The default value is 1.0. - * @platform ios - */ - minimumZoomScale?: ?number, - /** - * When true, ScrollView allows use of pinch gestures to zoom in and out. - * The default value is true. - * @platform ios - */ - pinchGestureEnabled?: ?boolean, - /** - * - * Values between 0 and 17ms indicate 60fps updates are needed and throttling - * will be disabled. - * - * If you do not need precise scroll position tracking, set this value higher - * to limit the information being sent across the bridge. - * - * The default value is zero, which results in the scroll event being sent only - * once each time the view is scrolled. - * - * @platform ios - */ - scrollEventThrottle?: ?number, - /** - * The amount by which the scroll view indicators are inset from the edges - * of the scroll view. This should normally be set to the same value as - * the `contentInset`. Defaults to `{0, 0, 0, 0}`. - * @platform ios - */ - scrollIndicatorInsets?: ?EdgeInsetsProp, - /** - * When true, the scroll view can be programmatically scrolled beyond its - * content size. The default value is false. - * @platform ios - */ - scrollToOverflowEnabled?: ?boolean, - /** - * When true, the scroll view scrolls to top when the status bar is tapped. - * The default value is true. - * @platform ios - */ - scrollsToTop?: ?boolean, - /** - * Fires when the scroll view scrolls to top after the status bar has been tapped - * @platform ios - */ - onScrollToTop?: (event: ScrollEvent) => void, - /** - * When true, shows a horizontal scroll indicator. - * The default value is true. - */ - showsHorizontalScrollIndicator?: ?boolean, - /** - * When `snapToInterval` is set, `snapToAlignment` will define the relationship - * of the snapping to the scroll view. - * - * - `'start'` (the default) will align the snap at the left (horizontal) or top (vertical) - * - `'center'` will align the snap in the center - * - `'end'` will align the snap at the right (horizontal) or bottom (vertical) - * - * @platform ios - */ - snapToAlignment?: ?('start' | 'center' | 'end'), - /** - * The current scale of the scroll view content. The default value is 1.0. - * @platform ios - */ - zoomScale?: ?number, - /** - * This property specifies how the safe area insets are used to modify the - * content area of the scroll view. The default value of this property is - * "never". Available on iOS 11 and later. - * @platform ios - */ - contentInsetAdjustmentBehavior?: ?( - | 'automatic' - | 'scrollableAxes' - | 'never' - | 'always' - ), - /** - * When true, ScrollView will emit updateChildFrames data in scroll events, - * otherwise will not compute or emit child frame data. This only exists - * to support legacy issues, `onLayout` should be used instead to retrieve - * frame data. - * The default value is false. - * @platform ios - */ - DEPRECATED_sendUpdatedChildFrames?: ?boolean, -|}>; - -type AndroidProps = $ReadOnly<{| - /** - * Enables nested scrolling for Android API level 21+. - * Nested scrolling is supported by default on iOS - * @platform android - */ - nestedScrollEnabled?: ?boolean, - /** - * Sometimes a scrollview takes up more space than its content fills. When this is - * the case, this prop will fill the rest of the scrollview with a color to avoid setting - * a background and creating unnecessary overdraw. This is an advanced optimization - * that is not needed in the general case. - * @platform android - */ - endFillColor?: ?ColorValue, - /** - * Tag used to log scroll performance on this scroll view. Will force - * momentum events to be turned on (see sendMomentumEvents). This doesn't do - * anything out of the box and you need to implement a custom native - * FpsListener for it to be useful. - * @platform android - */ - scrollPerfTag?: ?string, - /** - * Used to override default value of overScroll mode. - * - * Possible values: - * - * - `'auto'` - Default value, allow a user to over-scroll - * this view only if the content is large enough to meaningfully scroll. - * - `'always'` - Always allow a user to over-scroll this view. - * - `'never'` - Never allow a user to over-scroll this view. - * - * @platform android - */ - overScrollMode?: ?('auto' | 'always' | 'never'), - /** - * Causes the scrollbars not to turn transparent when they are not in use. - * The default value is false. - * - * @platform android - */ - persistentScrollbar?: ?boolean, -|}>; - -type VRProps = $ReadOnly<{| - /** - * Optionally an image can be used for the scroll bar thumb. This will - * override the color. While the image is loading or the image fails to - * load the color will be used instead. Use an alpha of 0 in the color - * to avoid seeing it while the image is loading. - * - * - `uri` - a string representing the resource identifier for the image, which - * should be either a local file path or the name of a static image resource - * - `number` - Opaque type returned by something like - * `import IMAGE from './image.jpg'`. - * @platform vr - */ - scrollBarThumbImage?: ?($ReadOnly<{||}> | number), // Opaque type returned by import IMAGE from './image.jpg' -|}>; - -export type Props = $ReadOnly<{| - ...ViewProps, - ...TouchableProps, - ...IOSProps, - ...AndroidProps, - ...VRProps, - - /** - * These styles will be applied to the scroll view content container which - * wraps all of the child views. Example: - * - * ``` - * return ( - * - * - * ); - * ... - * const styles = StyleSheet.create({ - * contentContainer: { - * paddingVertical: 20 - * } - * }); - * ``` - */ - contentContainerStyle?: ?ViewStyleProp, - /** - * When true, the scroll view stops on the next index (in relation to scroll - * position at release) regardless of how fast the gesture is. This can be - * used for horizontal pagination when the page is less than the width of - * the ScrollView. The default value is false. - */ - disableIntervalMomentum?: ?boolean, - /** - * A floating-point number that determines how quickly the scroll view - * decelerates after the user lifts their finger. You may also use string - * shortcuts `"normal"` and `"fast"` which match the underlying iOS settings - * for `UIScrollViewDecelerationRateNormal` and - * `UIScrollViewDecelerationRateFast` respectively. - * - * - `'normal'`: 0.998 on iOS, 0.985 on Android (the default) - * - `'fast'`: 0.99 on iOS, 0.9 on Android - */ - decelerationRate?: ?('fast' | 'normal' | number), - /** - * When true, the scroll view's children are arranged horizontally in a row - * instead of vertically in a column. The default value is false. - */ - horizontal?: ?boolean, - /** - * If sticky headers should stick at the bottom instead of the top of the - * ScrollView. This is usually used with inverted ScrollViews. - */ - invertStickyHeaders?: ?boolean, - /** - * Determines whether the keyboard gets dismissed in response to a drag. - * - * *Cross platform* - * - * - `'none'` (the default), drags do not dismiss the keyboard. - * - `'on-drag'`, the keyboard is dismissed when a drag begins. - * - * *iOS Only* - * - * - `'interactive'`, the keyboard is dismissed interactively with the drag and moves in - * synchrony with the touch; dragging upwards cancels the dismissal. - * On android this is not supported and it will have the same behavior as 'none'. - */ - keyboardDismissMode?: ?( - | 'none' // default - | 'on-drag' // cross-platform - | 'interactive' - ), // ios only - /** - * Determines when the keyboard should stay visible after a tap. - * - * - `'never'` (the default), tapping outside of the focused text input when the keyboard - * is up dismisses the keyboard. When this happens, children won't receive the tap. - * - `'always'`, the keyboard will not dismiss automatically, and the scroll view will not - * catch taps, but children of the scroll view can catch taps. - * - `'handled'`, the keyboard will not dismiss automatically when the tap was handled by - * a children, (or captured by an ancestor). - * - `false`, deprecated, use 'never' instead - * - `true`, deprecated, use 'always' instead - */ - keyboardShouldPersistTaps?: ?('always' | 'never' | 'handled' | true | false), - /** - * Called when the momentum scroll starts (scroll which occurs as the ScrollView glides to a stop). - */ - onMomentumScrollBegin?: (event: ScrollEvent) => void, - /** - * Called when the momentum scroll ends (scroll which occurs as the ScrollView glides to a stop). - */ - onMomentumScrollEnd?: (event: ScrollEvent) => void, - - /** - * Fires at most once per frame during scrolling. The frequency of the - * events can be controlled using the `scrollEventThrottle` prop. - */ - onScroll?: (event: ScrollEvent) => void, - /** - * Called when the user begins to drag the scroll view. - */ - onScrollBeginDrag?: (event: ScrollEvent) => void, - /** - * Called when the user stops dragging the scroll view and it either stops - * or begins to glide. - */ - onScrollEndDrag?: (event: ScrollEvent) => void, - /** - * Called when scrollable content view of the ScrollView changes. - * - * Handler function is passed the content width and content height as parameters: - * `(contentWidth, contentHeight)` - * - * It's implemented using onLayout handler attached to the content container - * which this ScrollView renders. - */ - onContentSizeChange?: (contentWidth: number, contentHeight: number) => void, - onKeyboardDidShow?: (event: PressEvent) => void, - /** - * When true, the scroll view stops on multiples of the scroll view's size - * when scrolling. This can be used for horizontal pagination. The default - * value is false. - * - * Note: Vertical pagination is not supported on Android. - */ - pagingEnabled?: ?boolean, - - /** - * When false, the view cannot be scrolled via touch interaction. - * The default value is true. - * - * Note that the view can always be scrolled by calling `scrollTo`. - */ - scrollEnabled?: ?boolean, - /** - * When true, shows a vertical scroll indicator. - * The default value is true. - */ - showsVerticalScrollIndicator?: ?boolean, - /** - * An array of child indices determining which children get docked to the - * top of the screen when scrolling. For example, passing - * `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the - * top of the scroll view. This property is not supported in conjunction - * with `horizontal={true}`. - */ - stickyHeaderIndices?: ?$ReadOnlyArray, - /** - * When set, causes the scroll view to stop at multiples of the value of - * `snapToInterval`. This can be used for paginating through children - * that have lengths smaller than the scroll view. Typically used in - * combination with `snapToAlignment` and `decelerationRate="fast"`. - * - * Overrides less configurable `pagingEnabled` prop. - */ - snapToInterval?: ?number, - /** - * When set, causes the scroll view to stop at the defined offsets. - * This can be used for paginating through variously sized children - * that have lengths smaller than the scroll view. Typically used in - * combination with `decelerationRate="fast"`. - * - * Overrides less configurable `pagingEnabled` and `snapToInterval` props. - */ - snapToOffsets?: ?$ReadOnlyArray, - /** - * Use in conjuction with `snapToOffsets`. By default, the beginning - * of the list counts as a snap offset. Set `snapToStart` to false to disable - * this behavior and allow the list to scroll freely between its start and - * the first `snapToOffsets` offset. - * The default value is true. - */ - snapToStart?: ?boolean, - /** - * Use in conjuction with `snapToOffsets`. By default, the end - * of the list counts as a snap offset. Set `snapToEnd` to false to disable - * this behavior and allow the list to scroll freely between its end and - * the last `snapToOffsets` offset. - * The default value is true. - */ - snapToEnd?: ?boolean, - /** - * Experimental: When true, offscreen child views (whose `overflow` value is - * `hidden`) are removed from their native backing superview when offscreen. - * This can improve scrolling performance on long lists. The default value is - * true. - */ - removeClippedSubviews?: ?boolean, - /** - * A RefreshControl component, used to provide pull-to-refresh - * functionality for the ScrollView. Only works for vertical ScrollViews - * (`horizontal` prop must be `false`). - * - * See [RefreshControl](docs/refreshcontrol.html). - */ - // $FlowFixMe - how to handle generic type without existential opereator? - refreshControl?: ?React.Element, - children?: React.Node, -|}>; - -type State = {| - layoutHeight: ?number, - ...ScrollResponderState, -|}; -function createScrollResponder( - node: React.ElementRef, -): typeof ScrollResponder.Mixin { - const scrollResponder = {...ScrollResponder.Mixin}; - for (const key in scrollResponder) { - if (typeof scrollResponder[key] === 'function') { - scrollResponder[key] = scrollResponder[key].bind(node); - } - } - return scrollResponder; -} - -/** - * Component that wraps platform ScrollView while providing - * integration with touch locking "responder" system. - * - * Keep in mind that ScrollViews must have a bounded height in order to work, - * since they contain unbounded-height children into a bounded container (via - * a scroll interaction). In order to bound the height of a ScrollView, either - * set the height of the view directly (discouraged) or make sure all parent - * views have bounded height. Forgetting to transfer `{flex: 1}` down the - * view stack can lead to errors here, which the element inspector makes - * easy to debug. - * - * Doesn't yet support other contained responders from blocking this scroll - * view from becoming the responder. - * - * - * `` vs [``](/react-native/docs/flatlist.html) - which one to use? - * - * `ScrollView` simply renders all its react child components at once. That - * makes it very easy to understand and use. - * - * On the other hand, this has a performance downside. Imagine you have a very - * long list of items you want to display, maybe several screens worth of - * content. Creating JS components and native views for everything all at once, - * much of which may not even be shown, will contribute to slow rendering and - * increased memory usage. - * - * This is where `FlatList` comes into play. `FlatList` renders items lazily, - * just when they are about to appear, and removes items that scroll way off - * screen to save memory and processing time. - * - * `FlatList` is also handy if you want to render separators between your items, - * multiple columns, infinite scroll loading, or any number of other features it - * supports out of the box. - */ -class ScrollView extends React.Component { - /** - * Part 1: Removing ScrollResponder.Mixin: - * - * 1. Mixin methods should be flow typed. That's why we create a - * copy of ScrollResponder.Mixin and attach it to this._scrollResponder. - * Otherwise, we'd have to manually declare each method on the component - * class and assign it a flow type. - * 2. Mixin methods can call component methods, and access the component's - * props and state. So, we need to bind all mixin methods to the - * component instance. - * 3. Continued... - */ - _scrollResponder: typeof ScrollResponder.Mixin = createScrollResponder(this); - constructor(props: Props) { - super(props); - /** - * Part 2: Removing ScrollResponder.Mixin - * - * 3. Mixin methods access other mixin methods via dynamic dispatch using - * this. Since mixin methods are bound to the component instance, we need - * to copy all mixin methods to the component instance. This is also - * necessary because getScrollResponder() is a public method that returns - * an object that can be used to execute all scrollResponder methods. - * Since the object returned from that method is the ScrollView instance, - * we need to bind all mixin methods to the ScrollView instance. - */ - for (const key in ScrollResponder.Mixin) { - if ( - typeof ScrollResponder.Mixin[key] === 'function' && - key.startsWith('scrollResponder') - ) { - // $FlowFixMe - dynamically adding properties to a class - (this: any)[key] = ScrollResponder.Mixin[key].bind(this); - } - } - /** - * Part 3: Removing ScrollResponder.Mixin - * - * 4. Mixins can initialize properties and use properties on the component - * instance. - */ - Object.keys(ScrollResponder.Mixin) - .filter(key => typeof ScrollResponder.Mixin[key] !== 'function') - .forEach(key => { - // $FlowFixMe - dynamically adding properties to a class - (this: any)[key] = ScrollResponder.Mixin[key]; - }); - } - - _scrollAnimatedValue: AnimatedImplementation.Value = new AnimatedImplementation.Value( - 0, - ); - _scrollAnimatedValueAttachment: ?{detach: () => void} = null; - _stickyHeaderRefs: Map = new Map(); - _headerLayoutYs: Map = new Map(); - - - state = { - layoutHeight: null, - ...ScrollResponder.Mixin.scrollResponderMixinGetInitialState(), - }; - - UNSAFE_componentWillMount() { - this._scrollResponder.UNSAFE_componentWillMount(); - this._scrollAnimatedValue = new AnimatedImplementation.Value( - this.props.contentOffset ? this.props.contentOffset.y : 0, - ); - this._scrollAnimatedValue.setOffset( - /* $FlowFixMe(>=0.98.0 site=react_native_fb) This comment suppresses an - * error found when Flow v0.98 was deployed. To see the error delete this - * comment and run Flow. */ - this.props.contentInset ? this.props.contentInset.top : 0, - ); - this._stickyHeaderRefs = new Map(); - this._headerLayoutYs = new Map(); - } - - UNSAFE_componentWillReceiveProps(nextProps: Props) { - const currentContentInsetTop = this.props.contentInset - ? this.props.contentInset.top - : 0; - const nextContentInsetTop = nextProps.contentInset - ? nextProps.contentInset.top - : 0; - if (currentContentInsetTop !== nextContentInsetTop) { - this._scrollAnimatedValue.setOffset(nextContentInsetTop || 0); - } - } - - componentDidMount() { - this._updateAnimatedNodeAttachment(); - } - - componentDidUpdate() { - this._updateAnimatedNodeAttachment(); - } - - componentWillUnmount() { - if (this._scrollAnimatedValueAttachment) { - this._scrollAnimatedValueAttachment.detach(); - } - } - - setNativeProps(props: {[key: string]: mixed}) { - this._scrollViewRef && this._scrollViewRef.setNativeProps(props); - } - - /** - * Returns a reference to the underlying scroll responder, which supports - * operations like `scrollTo`. All ScrollView-like components should - * implement this method so that they can be composed while providing access - * to the underlying scroll responder's methods. - */ - getScrollResponder(): ScrollResponderType { - // $FlowFixMe - overriding type to include ScrollResponder.Mixin - return ((this: any): ScrollResponderType); - } - - getScrollableNode(): ?number { - return ReactNative.findNodeHandle(this._scrollViewRef); - } - - getInnerViewNode(): ?number { - return ReactNative.findNodeHandle(this._innerViewRef); - } - - getNativeScrollRef(): ?ScrollView { - return this._scrollViewRef; - } - - /** - * Scrolls to a given x, y offset, either immediately or with a smooth animation. - * - * Example: - * - * `scrollTo({x: 0, y: 0, animated: true})` - * - * Note: The weird function signature is due to the fact that, for historical reasons, - * the function also accepts separate arguments as an alternative to the options object. - * This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED. - */ - scrollTo( - options?: {x?: number, y?: number, animated?: boolean} | number, - deprecatedX?: number, - deprecatedAnimated?: boolean, - ) { - let x, y, animated; - if (typeof options === 'number') { - console.warn( - '`scrollTo(y, x, animated)` is deprecated. Use `scrollTo({x: 5, y: 5, ' + - 'animated: true})` instead.', - ); - y = options; - x = deprecatedX; - animated = deprecatedAnimated; - } else if (options) { - y = options.y; - x = options.x; - animated = options.animated; - } - this._scrollResponder.scrollResponderScrollTo({ - x: x || 0, - y: y || 0, - animated: animated !== false, - }); - } - - /** - * If this is a vertical ScrollView scrolls to the bottom. - * If this is a horizontal ScrollView scrolls to the right. - * - * Use `scrollToEnd({animated: true})` for smooth animated scrolling, - * `scrollToEnd({animated: false})` for immediate scrolling. - * If no options are passed, `animated` defaults to true. - */ - scrollToEnd(options?: ?{animated?: boolean}) { - // Default to true - const animated = (options && options.animated) !== false; - this._scrollResponder.scrollResponderScrollToEnd({ - animated: animated, - }); - } - - /** - * Deprecated, use `scrollTo` instead. - */ - scrollWithoutAnimationTo(y: number = 0, x: number = 0) { - console.warn( - '`scrollWithoutAnimationTo` is deprecated. Use `scrollTo` instead', - ); - this.scrollTo({x, y, animated: false}); - } - - /** - * Displays the scroll indicators momentarily. - * - * @platform ios - */ - flashScrollIndicators() { - this._scrollResponder.scrollResponderFlashScrollIndicators(); - } - - _getKeyForIndex(index, childArray) { - // $FlowFixMe Invalid prop usage - const child = childArray[index]; - return child && child.key; - } - - _updateAnimatedNodeAttachment() { - if (this._scrollAnimatedValueAttachment) { - this._scrollAnimatedValueAttachment.detach(); - } - if ( - this.props.stickyHeaderIndices && - this.props.stickyHeaderIndices.length > 0 - ) { - this._scrollAnimatedValueAttachment = AnimatedImplementation.attachNativeEvent( - this._scrollViewRef, - 'onScroll', - [{nativeEvent: {contentOffset: {y: this._scrollAnimatedValue}}}], - ); - } - } - - _setStickyHeaderRef(key, ref) { - if (ref) { - this._stickyHeaderRefs.set(key, ref); - } else { - this._stickyHeaderRefs.delete(key); - } - } - - _onStickyHeaderLayout(index, event, key) { - const {stickyHeaderIndices} = this.props; - if (!stickyHeaderIndices) { - return; - } - const childArray = React.Children.toArray(this.props.children); - if (key !== this._getKeyForIndex(index, childArray)) { - // ignore stale layout update - return; - } - const layoutY = event.nativeEvent.layout.y; - this._headerLayoutYs.set(key, layoutY); - const indexOfIndex = stickyHeaderIndices.indexOf(index); - const previousHeaderIndex = stickyHeaderIndices[indexOfIndex - 1]; - if (previousHeaderIndex != null) { - const previousHeader = this._stickyHeaderRefs.get( - this._getKeyForIndex(previousHeaderIndex, childArray), - ); - previousHeader && previousHeader.setNextHeaderY(layoutY); - } - } - - _handleScroll = (e: ScrollEvent) => { - if (__DEV__) { - if ( - this.props.onScroll && - this.props.scrollEventThrottle == null && - Platform.OS === 'ios' - ) { - console.log( - 'You specified `onScroll` on a but not ' + - '`scrollEventThrottle`. You will only receive one event. ' + - 'Using `16` you get all the events but be aware that it may ' + - "cause frame drops, use a bigger number if you don't need as " + - 'much precision.', - ); - } - } - if (Platform.OS === 'android') { - if ( - this.props.keyboardDismissMode === 'on-drag' && - this.state.isTouching - ) { - dismissKeyboard(); - } - } - this._scrollResponder.scrollResponderHandleScroll(e); - } - - _handleLayout = (e: LayoutEvent) => { - if (this.props.invertStickyHeaders === true) { - this.setState({layoutHeight: e.nativeEvent.layout.height}); - } - if (this.props.onLayout) { - this.props.onLayout(e); - } - }; - - _handleContentOnLayout = (e: LayoutEvent) => { - const {width, height} = e.nativeEvent.layout; - this.props.onContentSizeChange && - this.props.onContentSizeChange(width, height); - }; - - _scrollViewRef: ?ScrollView = null; - _setScrollViewRef = (ref: ?ScrollView) => { - this._scrollViewRef = ref; - }; - - _innerViewRef: ?NativeMethodsMixinType = null; - _setInnerViewRef = (ref: ?NativeMethodsMixinType) => { - this._innerViewRef = ref; - }; - - render() { - let ScrollViewClass; - let ScrollContentContainerViewClass; - if (Platform.OS === 'android') { - if (this.props.horizontal === true) { - ScrollViewClass = AndroidHorizontalScrollView; - ScrollContentContainerViewClass = AndroidHorizontalScrollContentView; - } else { - ScrollViewClass = AndroidScrollView; - ScrollContentContainerViewClass = View; - } - } else { - ScrollViewClass = RCTScrollView; - ScrollContentContainerViewClass = RCTScrollContentView; - } - - invariant( - ScrollViewClass !== undefined, - 'ScrollViewClass must not be undefined', - ); - - invariant( - ScrollContentContainerViewClass !== undefined, - 'ScrollContentContainerViewClass must not be undefined', - ); - - const contentContainerStyle = [ - this.props.horizontal === true && styles.contentContainerHorizontal, - this.props.contentContainerStyle, - ]; - if (__DEV__ && this.props.style !== undefined) { - const style = flattenStyle(this.props.style); - const childLayoutProps = ['alignItems', 'justifyContent'].filter( - prop => style && style[prop] !== undefined, - ); - invariant( - childLayoutProps.length === 0, - 'ScrollView child layout (' + - JSON.stringify(childLayoutProps) + - ') must be applied through the contentContainerStyle prop.', - ); - } - - let contentSizeChangeProps = {}; - if (this.props.onContentSizeChange) { - contentSizeChangeProps = { - onLayout: this._handleContentOnLayout, - }; - } - - const {stickyHeaderIndices} = this.props; - let children = this.props.children; - if (stickyHeaderIndices != null && stickyHeaderIndices.length > 0) { - const childArray = React.Children.toArray(this.props.children); - children = childArray.map((child, index) => { - const indexOfIndex = child ? stickyHeaderIndices.indexOf(index) : -1; - if (indexOfIndex > -1) { - const key = child.key; - const nextIndex = stickyHeaderIndices[indexOfIndex + 1]; - return ( - this._setStickyHeaderRef(key, ref)} - nextHeaderLayoutY={this._headerLayoutYs.get( - this._getKeyForIndex(nextIndex, childArray), - )} - onLayout={event => this._onStickyHeaderLayout(index, event, key)} - scrollAnimatedValue={this._scrollAnimatedValue} - inverted={this.props.invertStickyHeaders} - scrollViewHeight={this.state.layoutHeight}> - {child} - - ); - } else { - return child; - } - }); - } - const hasStickyHeaders = - Array.isArray(stickyHeaderIndices) && stickyHeaderIndices.length > 0; - - const contentContainer = ( - - {children} - - ); - - const alwaysBounceHorizontal = - this.props.alwaysBounceHorizontal !== undefined - ? this.props.alwaysBounceHorizontal - : this.props.horizontal; - - const alwaysBounceVertical = - this.props.alwaysBounceVertical !== undefined - ? this.props.alwaysBounceVertical - : !this.props.horizontal; - - const DEPRECATED_sendUpdatedChildFrames = !!this.props - .DEPRECATED_sendUpdatedChildFrames; - - const baseStyle = - this.props.horizontal === true - ? styles.baseHorizontal - : styles.baseVertical; - const props = { - ...this.props, - alwaysBounceHorizontal, - alwaysBounceVertical, - style: [baseStyle, this.props.style], - // Override the onContentSizeChange from props, since this event can - // bubble up from TextInputs - onContentSizeChange: null, - onLayout: this._handleLayout, - onMomentumScrollBegin: this._scrollResponder - .scrollResponderHandleMomentumScrollBegin, - onMomentumScrollEnd: this._scrollResponder - .scrollResponderHandleMomentumScrollEnd, - onResponderGrant: this._scrollResponder - .scrollResponderHandleResponderGrant, - onResponderReject: this._scrollResponder - .scrollResponderHandleResponderReject, - onResponderRelease: this._scrollResponder - .scrollResponderHandleResponderRelease, - // $FlowFixMe - onResponderTerminate: this._scrollResponder - .scrollResponderHandleTerminate, - onResponderTerminationRequest: this._scrollResponder - .scrollResponderHandleTerminationRequest, - onScrollBeginDrag: this._scrollResponder - .scrollResponderHandleScrollBeginDrag, - onScrollEndDrag: this._scrollResponder.scrollResponderHandleScrollEndDrag, - onScrollShouldSetResponder: this._scrollResponder - .scrollResponderHandleScrollShouldSetResponder, - onStartShouldSetResponder: this._scrollResponder - .scrollResponderHandleStartShouldSetResponder, - onStartShouldSetResponderCapture: this._scrollResponder - .scrollResponderHandleStartShouldSetResponderCapture, - onTouchEnd: this._scrollResponder.scrollResponderHandleTouchEnd, - onTouchMove: this._scrollResponder.scrollResponderHandleTouchMove, - onTouchStart: this._scrollResponder.scrollResponderHandleTouchStart, - onTouchCancel: this._scrollResponder.scrollResponderHandleTouchCancel, - onScroll: this._handleScroll, - scrollBarThumbImage: resolveAssetSource(this.props.scrollBarThumbImage), - scrollEventThrottle: hasStickyHeaders - ? 1 - : this.props.scrollEventThrottle, - sendMomentumEvents: - this.props.onMomentumScrollBegin || this.props.onMomentumScrollEnd - ? true - : false, - DEPRECATED_sendUpdatedChildFrames, - // default to true - snapToStart: this.props.snapToStart !== false, - // default to true - snapToEnd: this.props.snapToEnd !== false, - // pagingEnabled is overridden by snapToInterval / snapToOffsets - pagingEnabled: Platform.select({ - // on iOS, pagingEnabled must be set to false to have snapToInterval / snapToOffsets work - ios: - this.props.pagingEnabled === true && - this.props.snapToInterval == null && - this.props.snapToOffsets == null, - // on Android, pagingEnabled must be set to true to have snapToInterval / snapToOffsets work - android: - this.props.pagingEnabled === true || - this.props.snapToInterval != null || - this.props.snapToOffsets != null, - }), - }; - - const {decelerationRate} = this.props; - if (decelerationRate != null) { - props.decelerationRate = processDecelerationRate(decelerationRate); - } - - const refreshControl = this.props.refreshControl; - - if (refreshControl) { - if (Platform.OS === 'ios') { - // On iOS the RefreshControl is a child of the ScrollView. - // tvOS lacks native support for RefreshControl, so don't include it in that case - return ( - // $FlowFixMe - - {Platform.isTV ? null : refreshControl} - {contentContainer} - - ); - } else if (Platform.OS === 'android') { - // On Android wrap the ScrollView with a AndroidSwipeRefreshLayout. - // Since the ScrollView is wrapped add the style props to the - // AndroidSwipeRefreshLayout and use flex: 1 for the ScrollView. - // Note: we should split props.style on the inner and outer props - // however, the ScrollView still needs the baseStyle to be scrollable - const {outer, inner} = splitLayoutProps(flattenStyle(props.style)); - return React.cloneElement( - refreshControl, - {style: [baseStyle, outer]}, - - {contentContainer} - , - ); - } - } - return ( - // FlowFixMe - - {contentContainer} - - ); - } -} - -const styles = StyleSheet.create({ - baseVertical: { - flexGrow: 1, - flexShrink: 1, - flexDirection: 'column', - overflow: 'scroll', - }, - baseHorizontal: { - flexGrow: 1, - flexShrink: 1, - flexDirection: 'row', - overflow: 'scroll', - }, - contentContainerHorizontal: { - flexDirection: 'row', - }, -}); - -module.exports = ScrollView; diff --git a/lib/ScrollView.js b/lib/ScrollView.js new file mode 100644 index 0000000..1a89caf --- /dev/null +++ b/lib/ScrollView.js @@ -0,0 +1,1844 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict-local + */ +const AnimatedImplementation = require('react-native/Libraries/Animated/AnimatedImplementation'); +import Dimensions from 'react-native/Libraries/Utilities/Dimensions'; +import Platform from 'react-native/Libraries/Utilities/Platform'; +import * as React from 'react'; +import ReactNative from 'react-native/Libraries/Renderer/shims/ReactNative'; +require('react-native/Libraries/Renderer/shims/ReactNative'); // Force side effects to prevent T55744311 +import ScrollViewStickyHeader from 'react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader'; +import StyleSheet from 'react-native/Libraries/StyleSheet/StyleSheet'; +import View from 'react-native/Libraries/Components/View/View'; +import UIManager from 'react-native/Libraries/ReactNative/UIManager'; +import Keyboard from 'react-native/Libraries/Components/Keyboard/Keyboard'; +import FrameRateLogger from 'react-native/Libraries/Interaction/FrameRateLogger'; +import TextInputState from 'react-native/Libraries/Components/TextInput/TextInputState'; + +import dismissKeyboard from 'react-native/Libraries/Utilities/dismissKeyboard'; +import flattenStyle from 'react-native/Libraries/StyleSheet/flattenStyle'; +import invariant from 'invariant'; +import processDecelerationRate from 'react-native/Libraries/Components/ScrollView/processDecelerationRate'; +import splitLayoutProps from 'react-native/Libraries/StyleSheet/splitLayoutProps'; +import setAndForwardRef from 'react-native/Libraries/Utilities/setAndForwardRef'; + +import type {EdgeInsetsProp} from 'react-native/Libraries/StyleSheet/EdgeInsetsPropType'; +import type {PointProp} from 'react-native/Libraries/StyleSheet/PointPropType'; +import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet'; +import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheet'; +import type { + PressEvent, + ScrollEvent, + LayoutEvent, +} from 'react-native/Libraries/Types/CoreEventTypes'; +import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; +import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; +import ScrollViewContext, {HORIZONTAL, VERTICAL} from 'react-native/Libraries/Components/ScrollView/ScrollViewContext'; +import type {Props as ScrollViewStickyHeaderProps} from 'react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader'; +import type {KeyboardEvent} from 'react-native/Libraries/Components/Keyboard/Keyboard'; +import type {EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter'; + +import Commands from 'react-native/Libraries/Components/ScrollView/ScrollViewCommands'; +import AndroidHorizontalScrollContentViewNativeComponent from 'react-native/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent'; +import AndroidHorizontalScrollViewNativeComponent from 'react-native/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent'; +import ScrollContentViewNativeComponent from 'react-native/Libraries/Components/ScrollView/ScrollContentViewNativeComponent'; +import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; + +const ScrollViewNativeComponent = codegenNativeComponent('RCTNestedScrollView'); + +const {NativeHorizontalScrollViewTuple, NativeVerticalScrollViewTuple} = + Platform.OS === 'android' + ? { + NativeHorizontalScrollViewTuple: [ + AndroidHorizontalScrollViewNativeComponent, + AndroidHorizontalScrollContentViewNativeComponent, + ], + NativeVerticalScrollViewTuple: [ScrollViewNativeComponent, View], + } + : { + NativeHorizontalScrollViewTuple: [ + ScrollViewNativeComponent, + ScrollContentViewNativeComponent, + ], + NativeVerticalScrollViewTuple: [ + ScrollViewNativeComponent, + ScrollContentViewNativeComponent, + ], + }; + +/* + * iOS scroll event timing nuances: + * =============================== + * + * + * Scrolling without bouncing, if you touch down: + * ------------------------------- + * + * 1. `onMomentumScrollBegin` (when animation begins after letting up) + * ... physical touch starts ... + * 2. `onTouchStartCapture` (when you press down to stop the scroll) + * 3. `onTouchStart` (same, but bubble phase) + * 4. `onResponderRelease` (when lifting up - you could pause forever before * lifting) + * 5. `onMomentumScrollEnd` + * + * + * Scrolling with bouncing, if you touch down: + * ------------------------------- + * + * 1. `onMomentumScrollBegin` (when animation begins after letting up) + * ... bounce begins ... + * ... some time elapses ... + * ... physical touch during bounce ... + * 2. `onMomentumScrollEnd` (Makes no sense why this occurs first during bounce) + * 3. `onTouchStartCapture` (immediately after `onMomentumScrollEnd`) + * 4. `onTouchStart` (same, but bubble phase) + * 5. `onTouchEnd` (You could hold the touch start for a long time) + * 6. `onMomentumScrollBegin` (When releasing the view starts bouncing back) + * + * So when we receive an `onTouchStart`, how can we tell if we are touching + * *during* an animation (which then causes the animation to stop)? The only way + * to tell is if the `touchStart` occurred immediately after the + * `onMomentumScrollEnd`. + * + * This is abstracted out for you, so you can just call this.scrollResponderIsAnimating() if + * necessary + * + * `ScrollView` also includes logic for blurring a currently focused input + * if one is focused while scrolling. This is a natural place + * to put this logic since it can support not dismissing the keyboard while + * scrolling, unless a recognized "tap"-like gesture has occurred. + * + * The public lifecycle API includes events for keyboard interaction, responder + * interaction, and scrolling (among others). The keyboard callbacks + * `onKeyboardWill/Did/*` are *global* events, but are invoked on scroll + * responder's props so that you can guarantee that the scroll responder's + * internal state has been updated accordingly (and deterministically) by + * the time the props callbacks are invoke. Otherwise, you would always wonder + * if the scroll responder is currently in a state where it recognizes new + * keyboard positions etc. If coordinating scrolling with keyboard movement, + * *always* use these hooks instead of listening to your own global keyboard + * events. + * + * Public keyboard lifecycle API: (props callbacks) + * + * Standard Keyboard Appearance Sequence: + * + * this.props.onKeyboardWillShow + * this.props.onKeyboardDidShow + * + * `onScrollResponderKeyboardDismissed` will be invoked if an appropriate + * tap inside the scroll responder's scrollable region was responsible + * for the dismissal of the keyboard. There are other reasons why the + * keyboard could be dismissed. + * + * this.props.onScrollResponderKeyboardDismissed + * + * Standard Keyboard Hide Sequence: + * + * this.props.onKeyboardWillHide + * this.props.onKeyboardDidHide + */ + +// Public methods for ScrollView +export type ScrollViewImperativeMethods = $ReadOnly<{| + getScrollResponder: $PropertyType, + getScrollableNode: $PropertyType, + getInnerViewNode: $PropertyType, + getInnerViewRef: $PropertyType, + getNativeScrollRef: $PropertyType, + scrollTo: $PropertyType, + scrollToEnd: $PropertyType, + flashScrollIndicators: $PropertyType, + scrollResponderZoomTo: $PropertyType, + scrollResponderScrollNativeHandleToKeyboard: $PropertyType< + ScrollView, + 'scrollResponderScrollNativeHandleToKeyboard', + >, +|}>; + +export type DecelerationRateType = 'fast' | 'normal' | number; +export type ScrollResponderType = ScrollViewImperativeMethods; + +type IOSProps = $ReadOnly<{| + /** + * Controls whether iOS should automatically adjust the content inset + * for scroll views that are placed behind a navigation bar or + * tab bar/ toolbar. The default value is true. + * @platform ios + */ + automaticallyAdjustContentInsets?: ?boolean, + /** + * Controls whether the ScrollView should automatically adjust it's contentInset + * and scrollViewInsets when the Keyboard changes it's size. The default value is false. + * @platform ios + */ + automaticallyAdjustKeyboardInsets?: ?boolean, + /** + * Controls whether iOS should automatically adjust the scroll indicator + * insets. The default value is true. Available on iOS 13 and later. + * @platform ios + */ + automaticallyAdjustsScrollIndicatorInsets?: ?boolean, + /** + * The amount by which the scroll view content is inset from the edges + * of the scroll view. Defaults to `{top: 0, left: 0, bottom: 0, right: 0}`. + * @platform ios + */ + contentInset?: ?EdgeInsetsProp, + /** + * Used to manually set the starting scroll offset. + * The default value is `{x: 0, y: 0}`. + * @platform ios + */ + contentOffset?: ?PointProp, + /** + * When true, the scroll view bounces when it reaches the end of the + * content if the content is larger then the scroll view along the axis of + * the scroll direction. When false, it disables all bouncing even if + * the `alwaysBounce*` props are true. The default value is true. + * @platform ios + */ + bounces?: ?boolean, + /** + * By default, ScrollView has an active pan responder that hijacks panresponders + * deeper in the render tree in order to prevent accidental touches while scrolling. + * However, in certain occasions (such as when using snapToInterval) in a vertical scrollview + * You may want to disable this behavior in order to prevent the ScrollView from blocking touches + */ + disableScrollViewPanResponder?: ?boolean, + /** + * When true, gestures can drive zoom past min/max and the zoom will animate + * to the min/max value at gesture end, otherwise the zoom will not exceed + * the limits. + * @platform ios + */ + bouncesZoom?: ?boolean, + /** + * When true, the scroll view bounces horizontally when it reaches the end + * even if the content is smaller than the scroll view itself. The default + * value is true when `horizontal={true}` and false otherwise. + * @platform ios + */ + alwaysBounceHorizontal?: ?boolean, + /** + * When true, the scroll view bounces vertically when it reaches the end + * even if the content is smaller than the scroll view itself. The default + * value is false when `horizontal={true}` and true otherwise. + * @platform ios + */ + alwaysBounceVertical?: ?boolean, + /** + * When true, the scroll view automatically centers the content when the + * content is smaller than the scroll view bounds; when the content is + * larger than the scroll view, this property has no effect. The default + * value is false. + * @platform ios + */ + centerContent?: ?boolean, + /** + * The style of the scroll indicators. + * + * - `'default'` (the default), same as `black`. + * - `'black'`, scroll indicator is black. This style is good against a light background. + * - `'white'`, scroll indicator is white. This style is good against a dark background. + * + * @platform ios + */ + indicatorStyle?: ?('default' | 'black' | 'white'), + /** + * When true, the ScrollView will try to lock to only vertical or horizontal + * scrolling while dragging. The default value is false. + * @platform ios + */ + directionalLockEnabled?: ?boolean, + /** + * When false, once tracking starts, won't try to drag if the touch moves. + * The default value is true. + * @platform ios + */ + canCancelContentTouches?: ?boolean, + /** + * When set, the scroll view will adjust the scroll position so that the first child that is + * currently visible and at or beyond `minIndexForVisible` will not change position. This is + * useful for lists that are loading content in both directions, e.g. a chat thread, where new + * messages coming in might otherwise cause the scroll position to jump. A value of 0 is common, + * but other values such as 1 can be used to skip loading spinners or other content that should + * not maintain position. + * + * The optional `autoscrollToTopThreshold` can be used to make the content automatically scroll + * to the top after making the adjustment if the user was within the threshold of the top before + * the adjustment was made. This is also useful for chat-like applications where you want to see + * new messages scroll into place, but not if the user has scrolled up a ways and it would be + * disruptive to scroll a bunch. + * + * Caveat 1: Reordering elements in the scrollview with this enabled will probably cause + * jumpiness and jank. It can be fixed, but there are currently no plans to do so. For now, + * don't re-order the content of any ScrollViews or Lists that use this feature. + * + * Caveat 2: This simply uses `contentOffset` and `frame.origin` in native code to compute + * visibility. Occlusion, transforms, and other complexity won't be taken into account as to + * whether content is "visible" or not. + * + * @platform ios + */ + maintainVisibleContentPosition?: ?$ReadOnly<{| + minIndexForVisible: number, + autoscrollToTopThreshold?: ?number, + |}>, + /** + * The maximum allowed zoom scale. The default value is 1.0. + * @platform ios + */ + maximumZoomScale?: ?number, + /** + * The minimum allowed zoom scale. The default value is 1.0. + * @platform ios + */ + minimumZoomScale?: ?number, + /** + * When true, ScrollView allows use of pinch gestures to zoom in and out. + * The default value is true. + * @platform ios + */ + pinchGestureEnabled?: ?boolean, + /** + * This controls how often the scroll event will be fired while scrolling + * (as a time interval in ms). A lower number yields better accuracy for code + * that is tracking the scroll position, but can lead to scroll performance + * problems due to the volume of information being send over the bridge. + * + * Values between 0 and 17ms indicate 60fps updates are needed and throttling + * will be disabled. + * + * If you do not need precise scroll position tracking, set this value higher + * to limit the information being sent across the bridge. + * + * The default value is zero, which results in the scroll event being sent only + * once each time the view is scrolled. + * + * @platform ios + */ + scrollEventThrottle?: ?number, + /** + * The amount by which the scroll view indicators are inset from the edges + * of the scroll view. This should normally be set to the same value as + * the `contentInset`. Defaults to `{0, 0, 0, 0}`. + * @platform ios + */ + scrollIndicatorInsets?: ?EdgeInsetsProp, + /** + * When true, the scroll view can be programmatically scrolled beyond its + * content size. The default value is false. + * @platform ios + */ + scrollToOverflowEnabled?: ?boolean, + /** + * When true, the scroll view scrolls to top when the status bar is tapped. + * The default value is true. + * @platform ios + */ + scrollsToTop?: ?boolean, + /** + * Fires when the scroll view scrolls to top after the status bar has been tapped + * @platform ios + */ + onScrollToTop?: (event: ScrollEvent) => void, + /** + * When true, shows a horizontal scroll indicator. + * The default value is true. + */ + showsHorizontalScrollIndicator?: ?boolean, + /** + * The current scale of the scroll view content. The default value is 1.0. + * @platform ios + */ + zoomScale?: ?number, + /** + * This property specifies how the safe area insets are used to modify the + * content area of the scroll view. The default value of this property is + * "never". Available on iOS 11 and later. + * @platform ios + */ + contentInsetAdjustmentBehavior?: ?( + | 'automatic' + | 'scrollableAxes' + | 'never' + | 'always' + ), +|}>; + +type AndroidProps = $ReadOnly<{| + /** + * Enables nested scrolling for Android API level 21+. + * Nested scrolling is supported by default on iOS + * @platform android + */ + nestedScrollEnabled?: ?boolean, + /** + * Sometimes a scrollview takes up more space than its content fills. When this is + * the case, this prop will fill the rest of the scrollview with a color to avoid setting + * a background and creating unnecessary overdraw. This is an advanced optimization + * that is not needed in the general case. + * @platform android + */ + endFillColor?: ?ColorValue, + /** + * Tag used to log scroll performance on this scroll view. Will force + * momentum events to be turned on (see sendMomentumEvents). This doesn't do + * anything out of the box and you need to implement a custom native + * FpsListener for it to be useful. + * @platform android + */ + scrollPerfTag?: ?string, + /** + * Used to override default value of overScroll mode. + * + * Possible values: + * + * - `'auto'` - Default value, allow a user to over-scroll + * this view only if the content is large enough to meaningfully scroll. + * - `'always'` - Always allow a user to over-scroll this view. + * - `'never'` - Never allow a user to over-scroll this view. + * + * @platform android + */ + overScrollMode?: ?('auto' | 'always' | 'never'), + /** + * Causes the scrollbars not to turn transparent when they are not in use. + * The default value is false. + * + * @platform android + */ + persistentScrollbar?: ?boolean, + /** + * Fades out the edges of the the scroll content. + * + * If the value is greater than 0, the fading edges will be set accordingly + * to the current scroll direction and position, + * indicating if there is more content to show. + * + * The default value is 0. + * + * @platform android + */ + fadingEdgeLength?: ?number, +|}>; + +type StickyHeaderComponentType = React.AbstractComponent< + ScrollViewStickyHeaderProps, + $ReadOnly void}>, +>; + +export type Props = $ReadOnly<{| + ...ViewProps, + ...IOSProps, + ...AndroidProps, + + /** + * These styles will be applied to the scroll view content container which + * wraps all of the child views. Example: + * + * ``` + * return ( + * + * + * ); + * ... + * const styles = StyleSheet.create({ + * contentContainer: { + * paddingVertical: 20 + * } + * }); + * ``` + */ + contentContainerStyle?: ?ViewStyleProp, + /** + * When true, the scroll view stops on the next index (in relation to scroll + * position at release) regardless of how fast the gesture is. This can be + * used for pagination when the page is less than the width of the + * horizontal ScrollView or the height of the vertical ScrollView. The default value is false. + */ + disableIntervalMomentum?: ?boolean, + /** + * A floating-point number that determines how quickly the scroll view + * decelerates after the user lifts their finger. You may also use string + * shortcuts `"normal"` and `"fast"` which match the underlying iOS settings + * for `UIScrollViewDecelerationRateNormal` and + * `UIScrollViewDecelerationRateFast` respectively. + * + * - `'normal'`: 0.998 on iOS, 0.985 on Android (the default) + * - `'fast'`: 0.99 on iOS, 0.9 on Android + */ + decelerationRate?: ?DecelerationRateType, + /** + * When true, the scroll view's children are arranged horizontally in a row + * instead of vertically in a column. The default value is false. + */ + horizontal?: ?boolean, + /** + * If sticky headers should stick at the bottom instead of the top of the + * ScrollView. This is usually used with inverted ScrollViews. + */ + invertStickyHeaders?: ?boolean, + /** + * Determines whether the keyboard gets dismissed in response to a drag. + * + * *Cross platform* + * + * - `'none'` (the default), drags do not dismiss the keyboard. + * - `'on-drag'`, the keyboard is dismissed when a drag begins. + * + * *iOS Only* + * + * - `'interactive'`, the keyboard is dismissed interactively with the drag and moves in + * synchrony with the touch; dragging upwards cancels the dismissal. + * On android this is not supported and it will have the same behavior as 'none'. + */ + keyboardDismissMode?: ?// default + // cross-platform + ('none' | 'on-drag' | 'interactive'), // ios only + /** + * Determines when the keyboard should stay visible after a tap. + * + * - `'never'` (the default), tapping outside of the focused text input when the keyboard + * is up dismisses the keyboard. When this happens, children won't receive the tap. + * - `'always'`, the keyboard will not dismiss automatically, and the scroll view will not + * catch taps, but children of the scroll view can catch taps. + * - `'handled'`, the keyboard will not dismiss automatically when the tap was handled by + * a children, (or captured by an ancestor). + * - `false`, deprecated, use 'never' instead + * - `true`, deprecated, use 'always' instead + */ + keyboardShouldPersistTaps?: ?('always' | 'never' | 'handled' | true | false), + /** + * Called when the momentum scroll starts (scroll which occurs as the ScrollView glides to a stop). + */ + onMomentumScrollBegin?: ?(event: ScrollEvent) => void, + /** + * Called when the momentum scroll ends (scroll which occurs as the ScrollView glides to a stop). + */ + onMomentumScrollEnd?: ?(event: ScrollEvent) => void, + + /** + * Fires at most once per frame during scrolling. The frequency of the + * events can be controlled using the `scrollEventThrottle` prop. + */ + onScroll?: ?(event: ScrollEvent) => void, + /** + * Called when the user begins to drag the scroll view. + */ + onScrollBeginDrag?: ?(event: ScrollEvent) => void, + /** + * Called when the user stops dragging the scroll view and it either stops + * or begins to glide. + */ + onScrollEndDrag?: ?(event: ScrollEvent) => void, + /** + * Called when scrollable content view of the ScrollView changes. + * + * Handler function is passed the content width and content height as parameters: + * `(contentWidth, contentHeight)` + * + * It's implemented using onLayout handler attached to the content container + * which this ScrollView renders. + */ + onContentSizeChange?: (contentWidth: number, contentHeight: number) => void, + onKeyboardDidShow?: (event: KeyboardEvent) => void, + onKeyboardDidHide?: (event: KeyboardEvent) => void, + onKeyboardWillShow?: (event: KeyboardEvent) => void, + onKeyboardWillHide?: (event: KeyboardEvent) => void, + /** + * When true, the scroll view stops on multiples of the scroll view's size + * when scrolling. This can be used for horizontal pagination. The default + * value is false. + * + * Note: Vertical pagination is not supported on Android. + */ + pagingEnabled?: ?boolean, + + /** + * When false, the view cannot be scrolled via touch interaction. + * The default value is true. + * + * Note that the view can always be scrolled by calling `scrollTo`. + */ + scrollEnabled?: ?boolean, + /** + * When true, shows a vertical scroll indicator. + * The default value is true. + */ + showsVerticalScrollIndicator?: ?boolean, + /** + * When true, Sticky header is hidden when scrolling down, and dock at the top + * when scrolling up + */ + stickyHeaderHiddenOnScroll?: ?boolean, + /** + * An array of child indices determining which children get docked to the + * top of the screen when scrolling. For example, passing + * `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the + * top of the scroll view. This property is not supported in conjunction + * with `horizontal={true}`. + */ + stickyHeaderIndices?: ?$ReadOnlyArray, + /** + * A React Component that will be used to render sticky headers. + * To be used together with `stickyHeaderIndices` or with `SectionList`, defaults to `ScrollViewStickyHeader`. + * You may need to set this if your sticky header uses custom transforms (eg. translation), + * for example when you want your list to have an animated hidable header. + */ + StickyHeaderComponent?: StickyHeaderComponentType, + /** + * When `snapToInterval` is set, `snapToAlignment` will define the relationship + * of the snapping to the scroll view. + * + * - `'start'` (the default) will align the snap at the left (horizontal) or top (vertical) + * - `'center'` will align the snap in the center + * - `'end'` will align the snap at the right (horizontal) or bottom (vertical) + */ + snapToAlignment?: ?('start' | 'center' | 'end'), + /** + * When set, causes the scroll view to stop at multiples of the value of + * `snapToInterval`. This can be used for paginating through children + * that have lengths smaller than the scroll view. Typically used in + * combination with `snapToAlignment` and `decelerationRate="fast"`. + * + * Overrides less configurable `pagingEnabled` prop. + */ + snapToInterval?: ?number, + /** + * When set, causes the scroll view to stop at the defined offsets. + * This can be used for paginating through variously sized children + * that have lengths smaller than the scroll view. Typically used in + * combination with `decelerationRate="fast"`. + * + * Overrides less configurable `pagingEnabled` and `snapToInterval` props. + */ + snapToOffsets?: ?$ReadOnlyArray, + /** + * Use in conjunction with `snapToOffsets`. By default, the beginning + * of the list counts as a snap offset. Set `snapToStart` to false to disable + * this behavior and allow the list to scroll freely between its start and + * the first `snapToOffsets` offset. + * The default value is true. + */ + snapToStart?: ?boolean, + /** + * Use in conjunction with `snapToOffsets`. By default, the end + * of the list counts as a snap offset. Set `snapToEnd` to false to disable + * this behavior and allow the list to scroll freely between its end and + * the last `snapToOffsets` offset. + * The default value is true. + */ + snapToEnd?: ?boolean, + /** + * Experimental: When true, offscreen child views (whose `overflow` value is + * `hidden`) are removed from their native backing superview when offscreen. + * This can improve scrolling performance on long lists. The default value is + * true. + */ + removeClippedSubviews?: ?boolean, + /** + * A RefreshControl component, used to provide pull-to-refresh + * functionality for the ScrollView. Only works for vertical ScrollViews + * (`horizontal` prop must be `false`). + * + * See [RefreshControl](docs/refreshcontrol.html). + */ + /* $FlowFixMe[unclear-type] - how to handle generic type without existential + * operator? */ + refreshControl?: ?React.Element, + children?: React.Node, + /** + * A ref to the inner View element of the ScrollView. This should be used + * instead of calling `getInnerViewRef`. + */ + innerViewRef?: React.Ref, + /** + * A ref to the Native ScrollView component. This ref can be used to call + * all of ScrollView's public methods, in addition to native methods like + * measure, measureLayout, etc. + */ + scrollViewRef?: React.Ref< + typeof ScrollViewNativeComponent & ScrollViewImperativeMethods, + >, +|}>; + +type State = {| + layoutHeight: ?number, +|}; + +const IS_ANIMATING_TOUCH_START_THRESHOLD_MS = 16; + +type ScrollViewComponentStatics = $ReadOnly<{| + Context: typeof ScrollViewContext, +|}>; + +/** + * Component that wraps platform ScrollView while providing + * integration with touch locking "responder" system. + * + * Keep in mind that ScrollViews must have a bounded height in order to work, + * since they contain unbounded-height children into a bounded container (via + * a scroll interaction). In order to bound the height of a ScrollView, either + * set the height of the view directly (discouraged) or make sure all parent + * views have bounded height. Forgetting to transfer `{flex: 1}` down the + * view stack can lead to errors here, which the element inspector makes + * easy to debug. + * + * Doesn't yet support other contained responders from blocking this scroll + * view from becoming the responder. + * + * + * `` vs [``](https://reactnative.dev/docs/flatlist) - which one to use? + * + * `ScrollView` simply renders all its react child components at once. That + * makes it very easy to understand and use. + * + * On the other hand, this has a performance downside. Imagine you have a very + * long list of items you want to display, maybe several screens worth of + * content. Creating JS components and native views for everything all at once, + * much of which may not even be shown, will contribute to slow rendering and + * increased memory usage. + * + * This is where `FlatList` comes into play. `FlatList` renders items lazily, + * just when they are about to appear, and removes items that scroll way off + * screen to save memory and processing time. + * + * `FlatList` is also handy if you want to render separators between your items, + * multiple columns, infinite scroll loading, or any number of other features it + * supports out of the box. + */ +class ScrollView extends React.Component { + static Context: typeof ScrollViewContext = ScrollViewContext; + + constructor(props: Props) { + super(props); + + this._scrollAnimatedValue = new AnimatedImplementation.Value( + this.props.contentOffset?.y ?? 0, + ); + this._scrollAnimatedValue.setOffset(this.props.contentInset?.top ?? 0); + } + + _scrollAnimatedValue: AnimatedImplementation.Value; + _scrollAnimatedValueAttachment: ?{detach: () => void, ...} = null; + _stickyHeaderRefs: Map> = + new Map(); + _headerLayoutYs: Map = new Map(); + + _keyboardWillOpenTo: ?KeyboardEvent = null; + _additionalScrollOffset: number = 0; + _isTouching: boolean = false; + _lastMomentumScrollBeginTime: number = 0; + _lastMomentumScrollEndTime: number = 0; + + // Reset to false every time becomes responder. This is used to: + // - Determine if the scroll view has been scrolled and therefore should + // refuse to give up its responder lock. + // - Determine if releasing should dismiss the keyboard when we are in + // tap-to-dismiss mode (this.props.keyboardShouldPersistTaps !== 'always'). + _observedScrollSinceBecomingResponder: boolean = false; + _becameResponderWhileAnimating: boolean = false; + _preventNegativeScrollOffset: ?boolean = null; + + _animated = null; + + _subscriptionKeyboardWillShow: ?EventSubscription = null; + _subscriptionKeyboardWillHide: ?EventSubscription = null; + _subscriptionKeyboardDidShow: ?EventSubscription = null; + _subscriptionKeyboardDidHide: ?EventSubscription = null; + + state: State = { + layoutHeight: null, + }; + + componentDidMount() { + if (typeof this.props.keyboardShouldPersistTaps === 'boolean') { + console.warn( + `'keyboardShouldPersistTaps={${ + this.props.keyboardShouldPersistTaps === true ? 'true' : 'false' + }}' is deprecated. ` + + `Use 'keyboardShouldPersistTaps="${ + this.props.keyboardShouldPersistTaps ? 'always' : 'never' + }"' instead`, + ); + } + + this._keyboardWillOpenTo = null; + this._additionalScrollOffset = 0; + + this._subscriptionKeyboardWillShow = Keyboard.addListener( + 'keyboardWillShow', + this.scrollResponderKeyboardWillShow, + ); + this._subscriptionKeyboardWillHide = Keyboard.addListener( + 'keyboardWillHide', + this.scrollResponderKeyboardWillHide, + ); + this._subscriptionKeyboardDidShow = Keyboard.addListener( + 'keyboardDidShow', + this.scrollResponderKeyboardDidShow, + ); + this._subscriptionKeyboardDidHide = Keyboard.addListener( + 'keyboardDidHide', + this.scrollResponderKeyboardDidHide, + ); + + this._updateAnimatedNodeAttachment(); + } + + componentDidUpdate(prevProps: Props) { + const prevContentInsetTop = prevProps.contentInset + ? prevProps.contentInset.top + : 0; + const newContentInsetTop = this.props.contentInset + ? this.props.contentInset.top + : 0; + if (prevContentInsetTop !== newContentInsetTop) { + this._scrollAnimatedValue.setOffset(newContentInsetTop || 0); + } + + this._updateAnimatedNodeAttachment(); + } + + componentWillUnmount() { + if (this._subscriptionKeyboardWillShow != null) { + this._subscriptionKeyboardWillShow.remove(); + } + if (this._subscriptionKeyboardWillHide != null) { + this._subscriptionKeyboardWillHide.remove(); + } + if (this._subscriptionKeyboardDidShow != null) { + this._subscriptionKeyboardDidShow.remove(); + } + if (this._subscriptionKeyboardDidHide != null) { + this._subscriptionKeyboardDidHide.remove(); + } + + if (this._scrollAnimatedValueAttachment) { + this._scrollAnimatedValueAttachment.detach(); + } + } + + _setNativeRef = setAndForwardRef({ + getForwardedRef: () => this.props.scrollViewRef, + setLocalRef: ref => { + this._scrollViewRef = ref; + + /* + This is a hack. Ideally we would forwardRef to the underlying + host component. However, since ScrollView has it's own methods that can be + called as well, if we used the standard forwardRef then these + methods wouldn't be accessible and thus be a breaking change. + + Therefore we edit ref to include ScrollView's public methods so that + they are callable from the ref. + */ + if (ref) { + ref.getScrollResponder = this.getScrollResponder; + ref.getScrollableNode = this.getScrollableNode; + ref.getInnerViewNode = this.getInnerViewNode; + ref.getInnerViewRef = this.getInnerViewRef; + ref.getNativeScrollRef = this.getNativeScrollRef; + ref.scrollTo = this.scrollTo; + ref.scrollToEnd = this.scrollToEnd; + ref.flashScrollIndicators = this.flashScrollIndicators; + ref.scrollResponderZoomTo = this.scrollResponderZoomTo; + ref.scrollResponderScrollNativeHandleToKeyboard = + this.scrollResponderScrollNativeHandleToKeyboard; + } + }, + }); + + /** + * Returns a reference to the underlying scroll responder, which supports + * operations like `scrollTo`. All ScrollView-like components should + * implement this method so that they can be composed while providing access + * to the underlying scroll responder's methods. + */ + getScrollResponder: () => ScrollResponderType = () => { + // $FlowFixMe[unclear-type] + return ((this: any): ScrollResponderType); + }; + + getScrollableNode: () => ?number = () => { + return ReactNative.findNodeHandle(this._scrollViewRef); + }; + + getInnerViewNode: () => ?number = () => { + return ReactNative.findNodeHandle(this._innerViewRef); + }; + + getInnerViewRef: () => ?React.ElementRef = () => { + return this._innerViewRef; + }; + + getNativeScrollRef: () => ?React.ElementRef> = () => { + return this._scrollViewRef; + }; + + /** + * Scrolls to a given x, y offset, either immediately or with a smooth animation. + * + * Example: + * + * `scrollTo({x: 0, y: 0, animated: true})` + * + * Note: The weird function signature is due to the fact that, for historical reasons, + * the function also accepts separate arguments as an alternative to the options object. + * This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED. + */ + scrollTo: ( + options?: + | { + x?: number, + y?: number, + animated?: boolean, + ... + } + | number, + deprecatedX?: number, + deprecatedAnimated?: boolean, + ) => void = ( + options?: + | { + x?: number, + y?: number, + animated?: boolean, + ... + } + | number, + deprecatedX?: number, + deprecatedAnimated?: boolean, + ) => { + let x, y, animated; + if (typeof options === 'number') { + console.warn( + '`scrollTo(y, x, animated)` is deprecated. Use `scrollTo({x: 5, y: 5, ' + + 'animated: true})` instead.', + ); + y = options; + x = deprecatedX; + animated = deprecatedAnimated; + } else if (options) { + y = options.y; + x = options.x; + animated = options.animated; + } + if (this._scrollViewRef == null) { + return; + } + Commands.scrollTo(this._scrollViewRef, x || 0, y || 0, animated !== false); + }; + + /** + * If this is a vertical ScrollView scrolls to the bottom. + * If this is a horizontal ScrollView scrolls to the right. + * + * Use `scrollToEnd({animated: true})` for smooth animated scrolling, + * `scrollToEnd({animated: false})` for immediate scrolling. + * If no options are passed, `animated` defaults to true. + */ + scrollToEnd: (options?: ?{animated?: boolean, ...}) => void = ( + options?: ?{animated?: boolean, ...}, + ) => { + // Default to true + const animated = (options && options.animated) !== false; + if (this._scrollViewRef == null) { + return; + } + Commands.scrollToEnd(this._scrollViewRef, animated); + }; + + /** + * Displays the scroll indicators momentarily. + * + * @platform ios + */ + flashScrollIndicators: () => void = () => { + if (this._scrollViewRef == null) { + return; + } + Commands.flashScrollIndicators(this._scrollViewRef); + }; + + /** + * This method should be used as the callback to onFocus in a TextInputs' + * parent view. Note that any module using this mixin needs to return + * the parent view's ref in getScrollViewRef() in order to use this method. + * @param {number} nodeHandle The TextInput node handle + * @param {number} additionalOffset The scroll view's bottom "contentInset". + * Default is 0. + * @param {bool} preventNegativeScrolling Whether to allow pulling the content + * down to make it meet the keyboard's top. Default is false. + */ + scrollResponderScrollNativeHandleToKeyboard: ( + nodeHandle: number | React.ElementRef>, + additionalOffset?: number, + preventNegativeScrollOffset?: boolean, + ) => void = ( + nodeHandle: number | React.ElementRef>, + additionalOffset?: number, + preventNegativeScrollOffset?: boolean, + ) => { + this._additionalScrollOffset = additionalOffset || 0; + this._preventNegativeScrollOffset = !!preventNegativeScrollOffset; + + if (this._innerViewRef == null) { + return; + } + + if (typeof nodeHandle === 'number') { + UIManager.measureLayout( + nodeHandle, + ReactNative.findNodeHandle(this), + // $FlowFixMe[method-unbinding] added when improving typing for this parameters + this._textInputFocusError, + this._inputMeasureAndScrollToKeyboard, + ); + } else { + nodeHandle.measureLayout( + this._innerViewRef, + this._inputMeasureAndScrollToKeyboard, + // $FlowFixMe[method-unbinding] added when improving typing for this parameters + this._textInputFocusError, + ); + } + }; + + /** + * A helper function to zoom to a specific rect in the scrollview. The argument has the shape + * {x: number; y: number; width: number; height: number; animated: boolean = true} + * + * @platform ios + */ + scrollResponderZoomTo: ( + rect: {| + x: number, + y: number, + width: number, + height: number, + animated?: boolean, + |}, + animated?: boolean, // deprecated, put this inside the rect argument instead + ) => void = ( + rect: {| + x: number, + y: number, + width: number, + height: number, + animated?: boolean, + |}, + animated?: boolean, // deprecated, put this inside the rect argument instead + ) => { + invariant(Platform.OS === 'ios', 'zoomToRect is not implemented'); + if ('animated' in rect) { + this._animated = rect.animated; + delete rect.animated; + } else if (typeof animated !== 'undefined') { + console.warn( + '`scrollResponderZoomTo` `animated` argument is deprecated. Use `options.animated` instead', + ); + } + + if (this._scrollViewRef == null) { + return; + } + Commands.zoomToRect(this._scrollViewRef, rect, animated !== false); + }; + + _textInputFocusError() { + console.warn('Error measuring text field.'); + } + + /** + * The calculations performed here assume the scroll view takes up the entire + * screen - even if has some content inset. We then measure the offsets of the + * keyboard, and compensate both for the scroll view's "contentInset". + * + * @param {number} left Position of input w.r.t. table view. + * @param {number} top Position of input w.r.t. table view. + * @param {number} width Width of the text input. + * @param {number} height Height of the text input. + */ + _inputMeasureAndScrollToKeyboard: ( + left: number, + top: number, + width: number, + height: number, + ) => void = (left: number, top: number, width: number, height: number) => { + let keyboardScreenY = Dimensions.get('window').height; + + const scrollTextInputIntoVisibleRect = () => { + if (this._keyboardWillOpenTo != null) { + keyboardScreenY = this._keyboardWillOpenTo.endCoordinates.screenY; + } + let scrollOffsetY = + top - keyboardScreenY + height + this._additionalScrollOffset; + + // By default, this can scroll with negative offset, pulling the content + // down so that the target component's bottom meets the keyboard's top. + // If requested otherwise, cap the offset at 0 minimum to avoid content + // shifting down. + if (this._preventNegativeScrollOffset === true) { + scrollOffsetY = Math.max(0, scrollOffsetY); + } + this.scrollTo({x: 0, y: scrollOffsetY, animated: true}); + + this._additionalScrollOffset = 0; + this._preventNegativeScrollOffset = false; + }; + + if (this._keyboardWillOpenTo == null) { + // `_keyboardWillOpenTo` is set inside `scrollResponderKeyboardWillShow` which + // is not guaranteed to be called before `_inputMeasureAndScrollToKeyboard` but native has already scheduled it. + // In case it was not called before `_inputMeasureAndScrollToKeyboard`, we postpone scrolling to + // text input. + setTimeout(() => { + scrollTextInputIntoVisibleRect(); + }, 0); + } else { + scrollTextInputIntoVisibleRect(); + } + }; + + _getKeyForIndex(index, childArray) { + const child = childArray[index]; + return child && child.key; + } + + _updateAnimatedNodeAttachment() { + if (this._scrollAnimatedValueAttachment) { + this._scrollAnimatedValueAttachment.detach(); + } + if ( + this.props.stickyHeaderIndices && + this.props.stickyHeaderIndices.length > 0 + ) { + this._scrollAnimatedValueAttachment = + AnimatedImplementation.attachNativeEvent( + this._scrollViewRef, + 'onScroll', + [{nativeEvent: {contentOffset: {y: this._scrollAnimatedValue}}}], + ); + } + } + + _setStickyHeaderRef( + key: string, + ref: ?React.ElementRef, + ) { + if (ref) { + this._stickyHeaderRefs.set(key, ref); + } else { + this._stickyHeaderRefs.delete(key); + } + } + + _onStickyHeaderLayout(index, event, key) { + const {stickyHeaderIndices} = this.props; + if (!stickyHeaderIndices) { + return; + } + const childArray = React.Children.toArray(this.props.children); + if (key !== this._getKeyForIndex(index, childArray)) { + // ignore stale layout update + return; + } + + const layoutY = event.nativeEvent.layout.y; + this._headerLayoutYs.set(key, layoutY); + + const indexOfIndex = stickyHeaderIndices.indexOf(index); + const previousHeaderIndex = stickyHeaderIndices[indexOfIndex - 1]; + if (previousHeaderIndex != null) { + const previousHeader = this._stickyHeaderRefs.get( + this._getKeyForIndex(previousHeaderIndex, childArray), + ); + previousHeader && + previousHeader.setNextHeaderY && + previousHeader.setNextHeaderY(layoutY); + } + } + + _handleScroll = (e: ScrollEvent) => { + if (__DEV__) { + if ( + this.props.onScroll && + this.props.scrollEventThrottle == null && + Platform.OS === 'ios' + ) { + console.log( + 'You specified `onScroll` on a but not ' + + '`scrollEventThrottle`. You will only receive one event. ' + + 'Using `16` you get all the events but be aware that it may ' + + "cause frame drops, use a bigger number if you don't need as " + + 'much precision.', + ); + } + } + this._observedScrollSinceBecomingResponder = true; + this.props.onScroll && this.props.onScroll(e); + }; + + _handleLayout = (e: LayoutEvent) => { + if (this.props.invertStickyHeaders === true) { + this.setState({layoutHeight: e.nativeEvent.layout.height}); + } + if (this.props.onLayout) { + this.props.onLayout(e); + } + }; + + _handleContentOnLayout = (e: LayoutEvent) => { + const {width, height} = e.nativeEvent.layout; + this.props.onContentSizeChange && + this.props.onContentSizeChange(width, height); + }; + + _scrollViewRef: ?React.ElementRef> = null; + + _innerViewRef: ?React.ElementRef = null; + _setInnerViewRef = setAndForwardRef({ + getForwardedRef: () => this.props.innerViewRef, + setLocalRef: ref => { + this._innerViewRef = ref; + }, + }); + + /** + * Warning, this may be called several times for a single keyboard opening. + * It's best to store the information in this method and then take any action + * at a later point (either in `keyboardDidShow` or other). + * + * Here's the order that events occur in: + * - focus + * - willShow {startCoordinates, endCoordinates} several times + * - didShow several times + * - blur + * - willHide {startCoordinates, endCoordinates} several times + * - didHide several times + * + * The `ScrollResponder` module callbacks for each of these events. + * Even though any user could have easily listened to keyboard events + * themselves, using these `props` callbacks ensures that ordering of events + * is consistent - and not dependent on the order that the keyboard events are + * subscribed to. This matters when telling the scroll view to scroll to where + * the keyboard is headed - the scroll responder better have been notified of + * the keyboard destination before being instructed to scroll to where the + * keyboard will be. Stick to the `ScrollResponder` callbacks, and everything + * will work. + * + * WARNING: These callbacks will fire even if a keyboard is displayed in a + * different navigation pane. Filter out the events to determine if they are + * relevant to you. (For example, only if you receive these callbacks after + * you had explicitly focused a node etc). + */ + + scrollResponderKeyboardWillShow: (e: KeyboardEvent) => void = ( + e: KeyboardEvent, + ) => { + this._keyboardWillOpenTo = e; + this.props.onKeyboardWillShow && this.props.onKeyboardWillShow(e); + }; + + scrollResponderKeyboardWillHide: (e: KeyboardEvent) => void = ( + e: KeyboardEvent, + ) => { + this._keyboardWillOpenTo = null; + this.props.onKeyboardWillHide && this.props.onKeyboardWillHide(e); + }; + + scrollResponderKeyboardDidShow: (e: KeyboardEvent) => void = ( + e: KeyboardEvent, + ) => { + // TODO(7693961): The event for DidShow is not available on iOS yet. + // Use the one from WillShow and do not assign. + if (e) { + this._keyboardWillOpenTo = e; + } + this.props.onKeyboardDidShow && this.props.onKeyboardDidShow(e); + }; + + scrollResponderKeyboardDidHide: (e: KeyboardEvent) => void = ( + e: KeyboardEvent, + ) => { + this._keyboardWillOpenTo = null; + this.props.onKeyboardDidHide && this.props.onKeyboardDidHide(e); + }; + + /** + * Invoke this from an `onMomentumScrollBegin` event. + */ + _handleMomentumScrollBegin: (e: ScrollEvent) => void = (e: ScrollEvent) => { + this._lastMomentumScrollBeginTime = global.performance.now(); + this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e); + }; + + /** + * Invoke this from an `onMomentumScrollEnd` event. + */ + _handleMomentumScrollEnd: (e: ScrollEvent) => void = (e: ScrollEvent) => { + FrameRateLogger.endScroll(); + this._lastMomentumScrollEndTime = global.performance.now(); + this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd(e); + }; + + /** + * Unfortunately, `onScrollBeginDrag` also fires when *stopping* the scroll + * animation, and there's not an easy way to distinguish a drag vs. stopping + * momentum. + * + * Invoke this from an `onScrollBeginDrag` event. + */ + _handleScrollBeginDrag: (e: ScrollEvent) => void = (e: ScrollEvent) => { + FrameRateLogger.beginScroll(); // TODO: track all scrolls after implementing onScrollEndAnimation + + if ( + Platform.OS === 'android' && + this.props.keyboardDismissMode === 'on-drag' + ) { + dismissKeyboard(); + } + + this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e); + }; + + /** + * Invoke this from an `onScrollEndDrag` event. + */ + _handleScrollEndDrag: (e: ScrollEvent) => void = (e: ScrollEvent) => { + const {velocity} = e.nativeEvent; + // - If we are animating, then this is a "drag" that is stopping the scrollview and momentum end + // will fire. + // - If velocity is non-zero, then the interaction will stop when momentum scroll ends or + // another drag starts and ends. + // - If we don't get velocity, better to stop the interaction twice than not stop it. + if ( + !this._isAnimating() && + (!velocity || (velocity.x === 0 && velocity.y === 0)) + ) { + FrameRateLogger.endScroll(); + } + this.props.onScrollEndDrag && this.props.onScrollEndDrag(e); + }; + + /** + * A helper function for this class that lets us quickly determine if the + * view is currently animating. This is particularly useful to know when + * a touch has just started or ended. + */ + _isAnimating: () => boolean = () => { + const now = global.performance.now(); + const timeSinceLastMomentumScrollEnd = + now - this._lastMomentumScrollEndTime; + const isAnimating = + timeSinceLastMomentumScrollEnd < IS_ANIMATING_TOUCH_START_THRESHOLD_MS || + this._lastMomentumScrollEndTime < this._lastMomentumScrollBeginTime; + return isAnimating; + }; + + /** + * Invoke this from an `onResponderGrant` event. + */ + _handleResponderGrant: (e: PressEvent) => void = (e: PressEvent) => { + this._observedScrollSinceBecomingResponder = false; + this.props.onResponderGrant && this.props.onResponderGrant(e); + this._becameResponderWhileAnimating = this._isAnimating(); + }; + + /** + * Invoke this from an `onResponderReject` event. + * + * Some other element is not yielding its role as responder. Normally, we'd + * just disable the `UIScrollView`, but a touch has already began on it, the + * `UIScrollView` will not accept being disabled after that. The easiest + * solution for now is to accept the limitation of disallowing this + * altogether. To improve this, find a way to disable the `UIScrollView` after + * a touch has already started. + */ + _handleResponderReject: () => void = () => {}; + + /** + * Invoke this from an `onResponderRelease` event. + */ + _handleResponderRelease: (e: PressEvent) => void = (e: PressEvent) => { + this._isTouching = e.nativeEvent.touches.length !== 0; + this.props.onResponderRelease && this.props.onResponderRelease(e); + + if (typeof e.target === 'number') { + if (__DEV__) { + console.error( + 'Did not expect event target to be a number. Should have been a native component', + ); + } + + return; + } + + // By default scroll views will unfocus a textField + // if another touch occurs outside of it + const currentlyFocusedTextInput = TextInputState.currentlyFocusedInput(); + if ( + this.props.keyboardShouldPersistTaps !== true && + this.props.keyboardShouldPersistTaps !== 'always' && + this._keyboardIsDismissible() && + e.target !== currentlyFocusedTextInput && + !this._observedScrollSinceBecomingResponder && + !this._becameResponderWhileAnimating + ) { + TextInputState.blurTextInput(currentlyFocusedTextInput); + } + }; + + /** + * We will allow the scroll view to give up its lock iff it acquired the lock + * during an animation. This is a very useful default that happens to satisfy + * many common user experiences. + * + * - Stop a scroll on the left edge, then turn that into an outer view's + * backswipe. + * - Stop a scroll mid-bounce at the top, continue pulling to have the outer + * view dismiss. + * - However, without catching the scroll view mid-bounce (while it is + * motionless), if you drag far enough for the scroll view to become + * responder (and therefore drag the scroll view a bit), any backswipe + * navigation of a swipe gesture higher in the view hierarchy, should be + * rejected. + */ + _handleResponderTerminationRequest: () => boolean = () => { + return !this._observedScrollSinceBecomingResponder; + }; + + /** + * Invoke this from an `onScroll` event. + */ + _handleScrollShouldSetResponder: () => boolean = () => { + // Allow any event touch pass through if the default pan responder is disabled + if (this.props.disableScrollViewPanResponder === true) { + return false; + } + return this._isTouching; + }; + + /** + * Merely touch starting is not sufficient for a scroll view to become the + * responder. Being the "responder" means that the very next touch move/end + * event will result in an action/movement. + * + * Invoke this from an `onStartShouldSetResponder` event. + * + * `onStartShouldSetResponder` is used when the next move/end will trigger + * some UI movement/action, but when you want to yield priority to views + * nested inside of the view. + * + * There may be some cases where scroll views actually should return `true` + * from `onStartShouldSetResponder`: Any time we are detecting a standard tap + * that gives priority to nested views. + * + * - If a single tap on the scroll view triggers an action such as + * recentering a map style view yet wants to give priority to interaction + * views inside (such as dropped pins or labels), then we would return true + * from this method when there is a single touch. + * + * - Similar to the previous case, if a two finger "tap" should trigger a + * zoom, we would check the `touches` count, and if `>= 2`, we would return + * true. + * + */ + _handleStartShouldSetResponder: (e: PressEvent) => boolean = ( + e: PressEvent, + ) => { + // Allow any event touch pass through if the default pan responder is disabled + if (this.props.disableScrollViewPanResponder === true) { + return false; + } + + const currentlyFocusedInput = TextInputState.currentlyFocusedInput(); + + if ( + this.props.keyboardShouldPersistTaps === 'handled' && + this._keyboardIsDismissible() && + e.target !== currentlyFocusedInput + ) { + return true; + } + return false; + }; + + /** + * There are times when the scroll view wants to become the responder + * (meaning respond to the next immediate `touchStart/touchEnd`), in a way + * that *doesn't* give priority to nested views (hence the capture phase): + * + * - Currently animating. + * - Tapping anywhere that is not a text input, while the keyboard is + * up (which should dismiss the keyboard). + * + * Invoke this from an `onStartShouldSetResponderCapture` event. + */ + _handleStartShouldSetResponderCapture: (e: PressEvent) => boolean = ( + e: PressEvent, + ) => { + // The scroll view should receive taps instead of its descendants if: + // * it is already animating/decelerating + if (this._isAnimating()) { + return true; + } + + // Allow any event touch pass through if the default pan responder is disabled + if (this.props.disableScrollViewPanResponder === true) { + return false; + } + + // * the keyboard is up, keyboardShouldPersistTaps is 'never' (the default), + // and a new touch starts with a non-textinput target (in which case the + // first tap should be sent to the scroll view and dismiss the keyboard, + // then the second tap goes to the actual interior view) + const {keyboardShouldPersistTaps} = this.props; + const keyboardNeverPersistTaps = + !keyboardShouldPersistTaps || keyboardShouldPersistTaps === 'never'; + + if (typeof e.target === 'number') { + if (__DEV__) { + console.error( + 'Did not expect event target to be a number. Should have been a native component', + ); + } + + return false; + } + + if ( + keyboardNeverPersistTaps && + this._keyboardIsDismissible() && + e.target != null && + !TextInputState.isTextInput(e.target) + ) { + return true; + } + + return false; + }; + + /** + * Do we consider there to be a dismissible soft-keyboard open? + */ + _keyboardIsDismissible: () => boolean = () => { + const currentlyFocusedInput = TextInputState.currentlyFocusedInput(); + + // We cannot dismiss the keyboard without an input to blur, even if a soft + // keyboard is open (e.g. when keyboard is open due to a native component + // not participating in TextInputState). It's also possible that the + // currently focused input isn't a TextInput (such as by calling ref.focus + // on a non-TextInput). + const hasFocusedTextInput = + currentlyFocusedInput != null && + TextInputState.isTextInput(currentlyFocusedInput); + + // Even if an input is focused, we may not have a keyboard to dismiss. E.g + // when using a physical keyboard. Ensure we have an event for an opened + // keyboard, except on Android where setting windowSoftInputMode to + // adjustNone leads to missing keyboard events. + const softKeyboardMayBeOpen = + this._keyboardWillOpenTo != null || Platform.OS === 'android'; + + return hasFocusedTextInput && softKeyboardMayBeOpen; + }; + + /** + * Invoke this from an `onTouchEnd` event. + * + * @param {PressEvent} e Event. + */ + _handleTouchEnd: (e: PressEvent) => void = (e: PressEvent) => { + const nativeEvent = e.nativeEvent; + this._isTouching = nativeEvent.touches.length !== 0; + this.props.onTouchEnd && this.props.onTouchEnd(e); + }; + + /** + * Invoke this from an `onTouchCancel` event. + * + * @param {PressEvent} e Event. + */ + _handleTouchCancel: (e: PressEvent) => void = (e: PressEvent) => { + this._isTouching = false; + this.props.onTouchCancel && this.props.onTouchCancel(e); + }; + + /** + * Invoke this from an `onTouchStart` event. + * + * Since we know that the `SimpleEventPlugin` occurs later in the plugin + * order, after `ResponderEventPlugin`, we can detect that we were *not* + * permitted to be the responder (presumably because a contained view became + * responder). The `onResponderReject` won't fire in that case - it only + * fires when a *current* responder rejects our request. + * + * @param {PressEvent} e Touch Start event. + */ + _handleTouchStart: (e: PressEvent) => void = (e: PressEvent) => { + this._isTouching = true; + this.props.onTouchStart && this.props.onTouchStart(e); + }; + + /** + * Invoke this from an `onTouchMove` event. + * + * Since we know that the `SimpleEventPlugin` occurs later in the plugin + * order, after `ResponderEventPlugin`, we can detect that we were *not* + * permitted to be the responder (presumably because a contained view became + * responder). The `onResponderReject` won't fire in that case - it only + * fires when a *current* responder rejects our request. + * + * @param {PressEvent} e Touch Start event. + */ + _handleTouchMove: (e: PressEvent) => void = (e: PressEvent) => { + this.props.onTouchMove && this.props.onTouchMove(e); + }; + + render(): React.Node | React.Element { + const [NativeDirectionalScrollView, NativeDirectionalScrollContentView] = + this.props.horizontal === true + ? NativeHorizontalScrollViewTuple + : NativeVerticalScrollViewTuple; + + const contentContainerStyle = [ + this.props.horizontal === true && styles.contentContainerHorizontal, + this.props.contentContainerStyle, + ]; + if (__DEV__ && this.props.style !== undefined) { + const style = flattenStyle(this.props.style); + const childLayoutProps = ['alignItems', 'justifyContent'].filter( + prop => style && style[prop] !== undefined, + ); + invariant( + childLayoutProps.length === 0, + 'ScrollView child layout (' + + JSON.stringify(childLayoutProps) + + ') must be applied through the contentContainerStyle prop.', + ); + } + + const contentSizeChangeProps = + this.props.onContentSizeChange == null + ? null + : { + onLayout: this._handleContentOnLayout, + }; + + const {stickyHeaderIndices} = this.props; + let children = this.props.children; + + if (stickyHeaderIndices != null && stickyHeaderIndices.length > 0) { + const childArray = React.Children.toArray(this.props.children); + + children = childArray.map((child, index) => { + const indexOfIndex = child ? stickyHeaderIndices.indexOf(index) : -1; + if (indexOfIndex > -1) { + const key = child.key; + const nextIndex = stickyHeaderIndices[indexOfIndex + 1]; + const StickyHeaderComponent = + this.props.StickyHeaderComponent || ScrollViewStickyHeader; + return ( + this._setStickyHeaderRef(key, ref)} + nextHeaderLayoutY={this._headerLayoutYs.get( + this._getKeyForIndex(nextIndex, childArray), + )} + onLayout={event => this._onStickyHeaderLayout(index, event, key)} + scrollAnimatedValue={this._scrollAnimatedValue} + inverted={this.props.invertStickyHeaders} + hiddenOnScroll={this.props.stickyHeaderHiddenOnScroll} + scrollViewHeight={this.state.layoutHeight}> + {child} + + ); + } else { + return child; + } + }); + } + children = ( + + {children} + + ); + + const hasStickyHeaders = + Array.isArray(stickyHeaderIndices) && stickyHeaderIndices.length > 0; + + const contentContainer = ( + + {children} + + ); + + const alwaysBounceHorizontal = + this.props.alwaysBounceHorizontal !== undefined + ? this.props.alwaysBounceHorizontal + : this.props.horizontal; + + const alwaysBounceVertical = + this.props.alwaysBounceVertical !== undefined + ? this.props.alwaysBounceVertical + : !this.props.horizontal; + + const baseStyle = + this.props.horizontal === true + ? styles.baseHorizontal + : styles.baseVertical; + const props = { + ...this.props, + alwaysBounceHorizontal, + alwaysBounceVertical, + style: StyleSheet.compose(baseStyle, this.props.style), + // Override the onContentSizeChange from props, since this event can + // bubble up from TextInputs + onContentSizeChange: null, + onLayout: this._handleLayout, + onMomentumScrollBegin: this._handleMomentumScrollBegin, + onMomentumScrollEnd: this._handleMomentumScrollEnd, + onResponderGrant: this._handleResponderGrant, + onResponderReject: this._handleResponderReject, + onResponderRelease: this._handleResponderRelease, + onResponderTerminationRequest: this._handleResponderTerminationRequest, + onScrollBeginDrag: this._handleScrollBeginDrag, + onScrollEndDrag: this._handleScrollEndDrag, + onScrollShouldSetResponder: this._handleScrollShouldSetResponder, + onStartShouldSetResponder: this._handleStartShouldSetResponder, + onStartShouldSetResponderCapture: + this._handleStartShouldSetResponderCapture, + onTouchEnd: this._handleTouchEnd, + onTouchMove: this._handleTouchMove, + onTouchStart: this._handleTouchStart, + onTouchCancel: this._handleTouchCancel, + onScroll: this._handleScroll, + scrollEventThrottle: hasStickyHeaders + ? 1 + : this.props.scrollEventThrottle, + sendMomentumEvents: + this.props.onMomentumScrollBegin || this.props.onMomentumScrollEnd + ? true + : false, + // default to true + snapToStart: this.props.snapToStart !== false, + // default to true + snapToEnd: this.props.snapToEnd !== false, + // pagingEnabled is overridden by snapToInterval / snapToOffsets + pagingEnabled: Platform.select({ + // on iOS, pagingEnabled must be set to false to have snapToInterval / snapToOffsets work + ios: + this.props.pagingEnabled === true && + this.props.snapToInterval == null && + this.props.snapToOffsets == null, + // on Android, pagingEnabled must be set to true to have snapToInterval / snapToOffsets work + android: + this.props.pagingEnabled === true || + this.props.snapToInterval != null || + this.props.snapToOffsets != null, + }), + }; + + const {decelerationRate} = this.props; + if (decelerationRate != null) { + props.decelerationRate = processDecelerationRate(decelerationRate); + } + + const refreshControl = this.props.refreshControl; + + if (refreshControl) { + if (Platform.OS === 'ios') { + // On iOS the RefreshControl is a child of the ScrollView. + return ( + + {refreshControl} + {contentContainer} + + ); + } else if (Platform.OS === 'android') { + // On Android wrap the ScrollView with a AndroidSwipeRefreshLayout. + // Since the ScrollView is wrapped add the style props to the + // AndroidSwipeRefreshLayout and use flex: 1 for the ScrollView. + // Note: we should split props.style on the inner and outer props + // however, the ScrollView still needs the baseStyle to be scrollable + const {outer, inner} = splitLayoutProps(flattenStyle(props.style)); + return React.cloneElement( + refreshControl, + {style: StyleSheet.compose(baseStyle, outer)}, + + {contentContainer} + , + ); + } + } + return ( + + {contentContainer} + + ); + } +} + +const styles = StyleSheet.create({ + baseVertical: { + flexGrow: 1, + flexShrink: 1, + flexDirection: 'column', + overflow: 'scroll', + }, + baseHorizontal: { + flexGrow: 1, + flexShrink: 1, + flexDirection: 'row', + overflow: 'scroll', + }, + contentContainerHorizontal: { + flexDirection: 'row', + }, +}); + +function Wrapper(props, ref) { + return ; +} +Wrapper.displayName = 'ScrollView'; +const ForwardedScrollView = React.forwardRef(Wrapper); + +// $FlowFixMe[prop-missing] Add static context to ForwardedScrollView +ForwardedScrollView.Context = ScrollViewContext; + +ForwardedScrollView.displayName = 'ScrollView'; + +module.exports = ((ForwardedScrollView: $FlowFixMe): React.AbstractComponent< + React.ElementConfig, + $ReadOnly<{| + ...$Exact>>, + ...ScrollViewImperativeMethods, + |}>, +> & + ScrollViewComponentStatics); diff --git a/package.json b/package.json index 8e5aa8b..7b1ec63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-nested-scroll-view", - "version": "9.0.0", + "version": "9.0.1", "description": "React Native ScrollView replacement with NestedScrollView", "main": "index.js", "keywords": [