@tamagui/react-native-web-lite
Version:
React Native for Web
679 lines (678 loc) • 31.5 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: !0 });
}, __copyProps = (to, from, except, desc) => {
if (from && typeof from == "object" || typeof from == "function")
for (let key of __getOwnPropNames(from))
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
mod
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var ScrollView_exports = {};
__export(ScrollView_exports, {
default: () => ScrollView_default
});
module.exports = __toCommonJS(ScrollView_exports);
var import_jsx_runtime = require("react/jsx-runtime"), import_react = __toESM(require("react")), import_react_native_web_internals = require("@tamagui/react-native-web-internals"), import_Dimensions = __toESM(require("../Dimensions/index")), import_View = __toESM(require("../View/index")), import_ScrollViewBase = __toESM(require("./ScrollViewBase"));
function _assert_this_initialized(self) {
if (self === void 0)
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return self;
}
function _call_super(_this, derived, args) {
return derived = _get_prototype_of(derived), _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
}
function _class_call_check(instance, Constructor) {
if (!(instance instanceof Constructor))
throw new TypeError("Cannot call a class as a function");
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _create_class(Constructor, protoProps, staticProps) {
return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Constructor;
}
function _define_property(obj, key, value) {
return key in obj ? Object.defineProperty(obj, key, {
value,
enumerable: !0,
configurable: !0,
writable: !0
}) : obj[key] = value, obj;
}
function _get_prototype_of(o) {
return _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function(o2) {
return o2.__proto__ || Object.getPrototypeOf(o2);
}, _get_prototype_of(o);
}
function _inherits(subClass, superClass) {
if (typeof superClass != "function" && superClass !== null)
throw new TypeError("Super expression must either be null or a function");
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: !0,
configurable: !0
}
}), superClass && _set_prototype_of(subClass, superClass);
}
function _possible_constructor_return(self, call) {
return call && (_type_of(call) === "object" || typeof call == "function") ? call : _assert_this_initialized(self);
}
function _set_prototype_of(o, p) {
return _set_prototype_of = Object.setPrototypeOf || function(o2, p2) {
return o2.__proto__ = p2, o2;
}, _set_prototype_of(o, p);
}
function _type_of(obj) {
"@swc/helpers - typeof";
return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
}
function _is_native_reflect_construct() {
try {
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
} catch {
}
return (_is_native_reflect_construct = function() {
return !!result;
})();
}
var emptyObject = {}, IS_ANIMATING_TOUCH_START_THRESHOLD_MS = 16, ScrollView = /* @__PURE__ */ function(_React_Component) {
"use strict";
_inherits(ScrollView2, _React_Component);
function ScrollView2() {
_class_call_check(this, ScrollView2);
var _this;
return _this = _call_super(this, ScrollView2, arguments), _define_property(_this, "_scrollNodeRef", void 0), _define_property(_this, "_innerViewRef", void 0), _define_property(_this, "keyboardWillOpenTo", null), _define_property(_this, "additionalScrollOffset", 0), _define_property(_this, "preventNegativeScrollOffset", !1), _define_property(_this, "isTouching", !1), _define_property(_this, "lastMomentumScrollBeginTime", 0), _define_property(_this, "lastMomentumScrollEndTime", 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).
_define_property(_this, "observedScrollSinceBecomingResponder", !1), _define_property(_this, "becameResponderWhileAnimating", !1), _define_property(_this, "flashScrollIndicators", function() {
_this.scrollResponderFlashScrollIndicators();
}), /**
* Scrolls to a given x, y offset, either immediately or with a smooth animation.
* Syntax:
*
* scrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})
*
* Note: The weird argument signature is due to the fact that, for historical reasons,
* the function also accepts separate arguments as as alternative to the options object.
* This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
*/
_define_property(_this, "scrollTo", function(y, x, animated) {
typeof y == "number" ? console.warn("`scrollTo(y, x, animated)` is deprecated. Use `scrollTo({x: 5, y: 5, animated: true})` instead.") : { x, y, animated } = y || emptyObject, _this.scrollResponderScrollTo({
x: x || 0,
y: y || 0,
animated: animated !== !1
});
}), /**
* 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.
*/
_define_property(_this, "scrollToEnd", function(options) {
var animated = (options && options.animated) !== !1, { horizontal } = _this.props, scrollResponderNode = _this.getScrollableNode(), x = horizontal ? scrollResponderNode.scrollWidth : 0, y = horizontal ? 0 : scrollResponderNode.scrollHeight;
_this.scrollResponderScrollTo({
x,
y,
animated
});
}), /**
* A helper function to scroll to a specific point in the scrollview.
* This is currently used to help focus on child textviews, but can also
* be used to quickly scroll to any element we want to focus. Syntax:
*
* scrollResponderScrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})
*
* Note: The weird argument signature is due to the fact that, for historical reasons,
* the function also accepts separate arguments as as alternative to the options object.
* This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
*/
_define_property(_this, "scrollResponderScrollTo", function(x, y, animated) {
typeof x == "number" ? console.warn("`scrollResponderScrollTo(x, y, animated)` is deprecated. Use `scrollResponderScrollTo({x: 5, y: 5, animated: true})` instead.") : { x, y, animated } = x || emptyObject;
var node = _this.getScrollableNode(), left = x || 0, top = y || 0;
node != null && (typeof node.scroll == "function" ? node.scroll({
top,
left,
behavior: animated ? "smooth" : "auto"
}) : (node.scrollLeft = left, node.scrollTop = top));
}), /**
* 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
*/
_define_property(_this, "scrollResponderZoomTo", function(rect, animated) {
import_react_native_web_internals.Platform.OS !== "ios" && (0, import_react_native_web_internals.invariant)("zoomToRect is not implemented");
}), /**
* 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 {any} nodeHandle The TextInput node handle
* @param {number} additionalOffset The scroll view's top "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.
*/
_define_property(_this, "scrollResponderScrollNativeHandleToKeyboard", function(nodeHandle, additionalOffset, preventNegativeScrollOffset) {
_this.additionalScrollOffset = additionalOffset || 0, _this.preventNegativeScrollOffset = !!preventNegativeScrollOffset, import_react_native_web_internals.UIManager.measureLayout(nodeHandle, _this.getInnerViewNode(), _this.scrollResponderTextInputFocusError, _this.scrollResponderInputMeasureAndScrollToKeyboard);
}), /**
* 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.
*/
_define_property(_this, "scrollResponderInputMeasureAndScrollToKeyboard", function(left, top, width, height) {
var keyboardScreenY = import_Dimensions.default.get("window").height;
_this.keyboardWillOpenTo && (keyboardScreenY = _this.keyboardWillOpenTo.endCoordinates.screenY);
var scrollOffsetY = top - keyboardScreenY + height + _this.additionalScrollOffset;
_this.preventNegativeScrollOffset && (scrollOffsetY = Math.max(0, scrollOffsetY)), _this.scrollResponderScrollTo({
x: 0,
y: scrollOffsetY,
animated: !0
}), _this.additionalScrollOffset = 0, _this.preventNegativeScrollOffset = !1;
}), /**
* 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` providesModule 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).
*/
_define_property(_this, "scrollResponderKeyboardWillShow", function(e) {
_this.keyboardWillOpenTo = e, _this.props.onKeyboardWillShow && _this.props.onKeyboardWillShow(e);
}), _define_property(_this, "scrollResponderKeyboardWillHide", function(e) {
_this.keyboardWillOpenTo = null, _this.props.onKeyboardWillHide && _this.props.onKeyboardWillHide(e);
}), _define_property(_this, "scrollResponderKeyboardDidShow", function(e) {
e && (_this.keyboardWillOpenTo = e), _this.props.onKeyboardDidShow && _this.props.onKeyboardDidShow(e);
}), _define_property(_this, "scrollResponderKeyboardDidHide", function(e) {
_this.keyboardWillOpenTo = null, _this.props.onKeyboardDidHide && _this.props.onKeyboardDidHide(e);
}), _this;
}
return _create_class(ScrollView2, [
{
/**
* 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.
*/
key: "getScrollResponder",
value: function() {
return this;
}
},
{
key: "getScrollableNode",
value: function() {
return this._scrollNodeRef;
}
},
{
key: "getInnerViewRef",
value: function() {
return this._innerViewRef;
}
},
{
key: "getInnerViewNode",
value: function() {
return this._innerViewRef;
}
},
{
key: "getNativeScrollRef",
value: function() {
return this._scrollNodeRef;
}
},
{
key: "render",
value: function() {
var {
contentContainerStyle,
horizontal,
onContentSizeChange,
refreshControl,
stickyHeaderIndices,
pagingEnabled,
/* eslint-disable */
forwardedRef,
keyboardDismissMode,
onScroll,
centerContent,
/* eslint-enable */
...other
} = this.props;
if (process.env.NODE_ENV !== "production" && this.props.style) {
var style = import_react_native_web_internals.StyleSheet.flatten(this.props.style), childLayoutProps = [
"alignItems",
"justifyContent"
].filter(function(prop) {
return style && style[prop] !== void 0;
});
(0, import_react_native_web_internals.invariant)(childLayoutProps.length === 0, `ScrollView child layout (${JSON.stringify(childLayoutProps)}) must be applied through the contentContainerStyle prop.`);
}
var contentSizeChangeProps = {};
onContentSizeChange && (contentSizeChangeProps = {
onLayout: this._handleContentOnLayout.bind(this)
});
var hasStickyHeaderIndices = !horizontal && Array.isArray(stickyHeaderIndices), children = hasStickyHeaderIndices || pagingEnabled ? import_react.default.Children.map(this.props.children, function(child, i) {
var isSticky = hasStickyHeaderIndices && stickyHeaderIndices.indexOf(i) > -1;
return child != null && (isSticky || pagingEnabled) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_View.default, {
style: import_react_native_web_internals.StyleSheet.compose(isSticky && styles.stickyHeader, pagingEnabled && styles.pagingEnabledChild),
children: child
}) : child;
}) : this.props.children, contentContainer = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_View.default, {
...contentSizeChangeProps,
// @ts-ignore
collapsable: !1,
ref: this._setInnerViewRef.bind(this),
style: [
horizontal && styles.contentContainerHorizontal,
centerContent && styles.contentContainerCenterContent,
contentContainerStyle
],
children
}), baseStyle = horizontal ? styles.baseHorizontal : styles.baseVertical, pagingEnabledStyle = horizontal ? styles.pagingEnabledHorizontal : styles.pagingEnabledVertical, props = {
...other,
style: [
baseStyle,
pagingEnabled && pagingEnabledStyle,
this.props.style
],
onTouchStart: this.scrollResponderHandleTouchStart.bind(this),
onTouchMove: this.scrollResponderHandleTouchMove.bind(this),
onTouchEnd: this.scrollResponderHandleTouchEnd.bind(this),
onScrollBeginDrag: this.scrollResponderHandleScrollBeginDrag.bind(this),
onScrollEndDrag: this.scrollResponderHandleScrollEndDrag.bind(this),
onMomentumScrollBegin: this.scrollResponderHandleMomentumScrollBegin.bind(this),
onMomentumScrollEnd: this.scrollResponderHandleMomentumScrollEnd.bind(this),
onStartShouldSetResponder: this.scrollResponderHandleStartShouldSetResponder.bind(this),
onStartShouldSetResponderCapture: this.scrollResponderHandleStartShouldSetResponderCapture.bind(this),
onScrollShouldSetResponder: this.scrollResponderHandleScrollShouldSetResponder.bind(this),
onScroll: this._handleScroll.bind(this),
onResponderGrant: this.scrollResponderHandleResponderGrant.bind(this),
onResponderTerminationRequest: this.scrollResponderHandleTerminationRequest.bind(this),
onResponderRelease: this.scrollResponderHandleResponderRelease.bind(this),
onResponderReject: this.scrollResponderHandleResponderReject.bind(this),
onResponderTerminate: this.scrollResponderHandleTerminate.bind(this)
}, ScrollViewClass = import_ScrollViewBase.default;
(0, import_react_native_web_internals.invariant)(ScrollViewClass !== void 0, "ScrollViewClass must not be undefined");
var scrollView = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ScrollViewClass, {
...props,
ref: this._setScrollNodeRef.bind(this),
children: contentContainer
});
return refreshControl ? /* @__PURE__ */ import_react.default.cloneElement(refreshControl, {
style: props.style
}, scrollView) : scrollView;
}
},
{
key: "_handleContentOnLayout",
value: function(e) {
var _this_props_onContentSizeChange, _this_props, { width, height } = e.nativeEvent.layout;
(_this_props_onContentSizeChange = (_this_props = this.props).onContentSizeChange) === null || _this_props_onContentSizeChange === void 0 || _this_props_onContentSizeChange.call(_this_props, width, height);
}
},
{
key: "_handleScroll",
value: function(e) {
process.env.NODE_ENV !== "production" && this.props.onScroll && this.props.scrollEventThrottle == null && console.info("You specified `onScroll` on a <ScrollView> 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.props.keyboardDismissMode === "on-drag" && (0, import_react_native_web_internals.dismissKeyboard)(), this.scrollResponderHandleScroll(e);
}
},
{
key: "_setInnerViewRef",
value: function(node) {
this._innerViewRef = node;
}
},
{
key: "_setScrollNodeRef",
value: function(node) {
this._scrollNodeRef = node, node != null && (node.getScrollResponder = this.getScrollResponder, node.getInnerViewNode = this.getInnerViewNode, node.getInnerViewRef = this.getInnerViewRef, node.getNativeScrollRef = this.getNativeScrollRef, node.getScrollableNode = this.getScrollableNode, node.scrollTo = this.scrollTo, node.scrollToEnd = this.scrollToEnd, node.flashScrollIndicators = this.flashScrollIndicators, node.scrollResponderZoomTo = this.scrollResponderZoomTo, node.scrollResponderScrollNativeHandleToKeyboard = this.scrollResponderScrollNativeHandleToKeyboard);
var ref = (0, import_react_native_web_internals.mergeRefs)(this.props.forwardedRef);
ref(node);
}
},
{
/**
* Invoke this from an `onScroll` event.
*/
key: "scrollResponderHandleScrollShouldSetResponder",
value: function() {
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.
*
*/
key: "scrollResponderHandleStartShouldSetResponder",
value: function() {
return !1;
}
},
{
/**
* 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 the focused input, while the keyboard is
* up (which should dismiss the keyboard).
*
* Invoke this from an `onStartShouldSetResponderCapture` event.
*/
key: "scrollResponderHandleStartShouldSetResponderCapture",
value: function(e) {
return this.scrollResponderIsAnimating();
}
},
{
/**
* 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.
*/
key: "scrollResponderHandleResponderReject",
value: function() {
(0, import_react_native_web_internals.warning)(!1, "ScrollView doesn't take rejection well - scrolls anyway");
}
},
{
/**
* 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.
*/
key: "scrollResponderHandleTerminationRequest",
value: function() {
return !this.observedScrollSinceBecomingResponder;
}
},
{
/**
* Invoke this from an `onTouchEnd` event.
*
* @param {SyntheticEvent} e Event.
*/
key: "scrollResponderHandleTouchEnd",
value: function(e) {
var nativeEvent = e.nativeEvent;
this.isTouching = nativeEvent.touches.length !== 0, this.props.onTouchEnd && this.props.onTouchEnd(e);
}
},
{
/**
* Invoke this from an `onResponderRelease` event.
*/
key: "scrollResponderHandleResponderRelease",
value: function(e) {
this.props.onResponderRelease && this.props.onResponderRelease(e);
var currentlyFocusedTextInput = import_react_native_web_internals.TextInputState.currentlyFocusedField();
!this.props.keyboardShouldPersistTaps && currentlyFocusedTextInput != null && e.target !== currentlyFocusedTextInput && !this.observedScrollSinceBecomingResponder && !this.becameResponderWhileAnimating && (this.props.onScrollResponderKeyboardDismissed && this.props.onScrollResponderKeyboardDismissed(e), import_react_native_web_internals.TextInputState.blurTextInput(currentlyFocusedTextInput));
}
},
{
key: "scrollResponderHandleScroll",
value: function(e) {
this.observedScrollSinceBecomingResponder = !0, this.props.onScroll && this.props.onScroll(e);
}
},
{
/**
* Invoke this from an `onResponderGrant` event.
*/
key: "scrollResponderHandleResponderGrant",
value: function(e) {
this.observedScrollSinceBecomingResponder = !1, this.props.onResponderGrant && this.props.onResponderGrant(e), this.becameResponderWhileAnimating = this.scrollResponderIsAnimating();
}
},
{
/**
* 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.
*/
key: "scrollResponderHandleScrollBeginDrag",
value: function(e) {
this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e);
}
},
{
/**
* Invoke this from an `onScrollEndDrag` event.
*/
key: "scrollResponderHandleScrollEndDrag",
value: function(e) {
this.props.onScrollEndDrag && this.props.onScrollEndDrag(e);
}
},
{
/**
* Invoke this from an `onMomentumScrollBegin` event.
*/
key: "scrollResponderHandleMomentumScrollBegin",
value: function(e) {
this.lastMomentumScrollBeginTime = Date.now(), this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e);
}
},
{
/**
* Invoke this from an `onMomentumScrollEnd` event.
*/
key: "scrollResponderHandleMomentumScrollEnd",
value: function(e) {
this.lastMomentumScrollEndTime = Date.now(), this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd(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 {SyntheticEvent} e Touch Start event.
*/
key: "scrollResponderHandleTouchStart",
value: function(e) {
this.isTouching = !0, 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 {SyntheticEvent} e Touch Start event.
*/
key: "scrollResponderHandleTouchMove",
value: function(e) {
this.props.onTouchMove && this.props.onTouchMove(e);
}
},
{
key: "scrollResponderHandleTerminate",
value: function(e) {
this.props.onResponderTerminate && this.props.onResponderTerminate(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.
*/
key: "scrollResponderIsAnimating",
value: function() {
var now = Date.now(), timeSinceLastMomentumScrollEnd = now - this.lastMomentumScrollEndTime, isAnimating = timeSinceLastMomentumScrollEnd < IS_ANIMATING_TOUCH_START_THRESHOLD_MS || this.lastMomentumScrollEndTime < this.lastMomentumScrollBeginTime;
return isAnimating;
}
},
{
/**
* Displays the scroll indicators momentarily.
*/
key: "scrollResponderFlashScrollIndicators",
value: function() {
}
},
{
key: "scrollResponderTextInputFocusError",
value: function(e) {
console.error("Error measuring text field: ", e);
}
}
]), ScrollView2;
}(import_react.default.Component), commonStyle = {
flexGrow: 1,
flexShrink: 1,
// Enable hardware compositing in modern browsers.
// Creates a new layer with its own backing surface that can significantly
// improve scroll performance.
transform: [
{
translateZ: 0
}
],
// iOS native scrolling
WebkitOverflowScrolling: "touch"
}, styles = {
baseVertical: {
...commonStyle,
flexDirection: "column",
overflowX: "hidden",
overflowY: "auto"
},
baseHorizontal: {
...commonStyle,
flexDirection: "row",
overflowX: "auto",
overflowY: "hidden"
},
contentContainerHorizontal: {
flexDirection: "row"
},
contentContainerCenterContent: {
justifyContent: "center",
flexGrow: 1
},
stickyHeader: {
position: "sticky",
top: 0,
zIndex: 10
},
pagingEnabledHorizontal: {
scrollSnapType: "x mandatory"
},
pagingEnabledVertical: {
scrollSnapType: "y mandatory"
},
pagingEnabledChild: {
scrollSnapAlign: "start"
}
}, ForwardedScrollView = /* @__PURE__ */ import_react.default.forwardRef(function(props, forwardedRef) {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ScrollView, {
...props,
forwardedRef
});
});
ForwardedScrollView.displayName = "ScrollView";
var ScrollView_default = ForwardedScrollView;
//# sourceMappingURL=index.js.map