@tamagui/sheet 1.127.0 → 1.127.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/SheetImplementationCustom.cjs +1 -0
- package/dist/cjs/SheetImplementationCustom.js +2 -0
- package/dist/cjs/SheetImplementationCustom.js.map +1 -1
- package/dist/cjs/SheetImplementationCustom.native.js +2 -0
- package/dist/cjs/SheetImplementationCustom.native.js.map +2 -2
- package/dist/cjs/SheetScrollView.cjs +42 -6
- package/dist/cjs/SheetScrollView.js +34 -6
- package/dist/cjs/SheetScrollView.js.map +1 -1
- package/dist/cjs/SheetScrollView.native.js +34 -34
- package/dist/cjs/SheetScrollView.native.js.map +2 -2
- package/dist/esm/SheetImplementationCustom.js +2 -0
- package/dist/esm/SheetImplementationCustom.js.map +1 -1
- package/dist/esm/SheetImplementationCustom.mjs +1 -0
- package/dist/esm/SheetImplementationCustom.mjs.map +1 -1
- package/dist/esm/SheetImplementationCustom.native.js +1 -0
- package/dist/esm/SheetImplementationCustom.native.js.map +1 -1
- package/dist/esm/SheetScrollView.js +36 -6
- package/dist/esm/SheetScrollView.js.map +1 -1
- package/dist/esm/SheetScrollView.mjs +41 -5
- package/dist/esm/SheetScrollView.mjs.map +1 -1
- package/dist/esm/SheetScrollView.native.js +42 -34
- package/dist/esm/SheetScrollView.native.js.map +1 -1
- package/dist/jsx/SheetImplementationCustom.js +2 -0
- package/dist/jsx/SheetImplementationCustom.js.map +1 -1
- package/dist/jsx/SheetImplementationCustom.mjs +1 -0
- package/dist/jsx/SheetImplementationCustom.mjs.map +1 -1
- package/dist/jsx/SheetImplementationCustom.native.js +2 -0
- package/dist/jsx/SheetImplementationCustom.native.js.map +2 -2
- package/dist/jsx/SheetScrollView.js +36 -6
- package/dist/jsx/SheetScrollView.js.map +1 -1
- package/dist/jsx/SheetScrollView.mjs +41 -5
- package/dist/jsx/SheetScrollView.mjs.map +1 -1
- package/dist/jsx/SheetScrollView.native.js +36 -34
- package/dist/jsx/SheetScrollView.native.js.map +2 -2
- package/package.json +19 -19
- package/src/SheetImplementationCustom.tsx +5 -1
- package/src/SheetScrollView.tsx +62 -48
- package/types/SheetImplementationCustom.d.ts.map +1 -1
- package/types/SheetScrollView.d.ts.map +1 -1
package/src/SheetScrollView.tsx
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import React, { useEffect } from 'react'
|
|
2
1
|
import { composeRefs } from '@tamagui/compose-refs'
|
|
3
|
-
import type
|
|
2
|
+
import { isWeb, type GetRef } from '@tamagui/core'
|
|
4
3
|
import type { ScrollViewProps } from '@tamagui/scroll-view'
|
|
5
4
|
import { ScrollView } from '@tamagui/scroll-view'
|
|
6
|
-
|
|
5
|
+
import { useControllableState } from '@tamagui/use-controllable-state'
|
|
6
|
+
import React, { useEffect } from 'react'
|
|
7
7
|
import type { ScrollView as RNScrollView } from 'react-native'
|
|
8
|
-
|
|
9
8
|
import { useSheetContext } from './SheetContext'
|
|
10
9
|
import type { SheetScopedProps } from './types'
|
|
11
10
|
|
|
@@ -26,14 +25,17 @@ export const SheetScrollView = React.forwardRef<
|
|
|
26
25
|
__scopeSheet,
|
|
27
26
|
children,
|
|
28
27
|
onScroll,
|
|
29
|
-
scrollEnabled,
|
|
28
|
+
scrollEnabled: scrollEnabledProp,
|
|
30
29
|
...props
|
|
31
30
|
}: SheetScopedProps<ScrollViewProps>,
|
|
32
31
|
ref
|
|
33
32
|
) => {
|
|
34
33
|
const context = useSheetContext(SHEET_SCROLL_VIEW_NAME, __scopeSheet)
|
|
35
34
|
const { scrollBridge, scrollEnabled: scrollEnabled_, setHasScrollView } = context
|
|
36
|
-
|
|
35
|
+
const [scrollEnabled, setScrollEnabled_] = useControllableState({
|
|
36
|
+
prop: scrollEnabledProp,
|
|
37
|
+
defaultProp: true,
|
|
38
|
+
})
|
|
37
39
|
const scrollRef = React.useRef<RNScrollView | null>(null)
|
|
38
40
|
|
|
39
41
|
// could make it so it has negative bottom margin and then pads the bottom content
|
|
@@ -41,12 +43,12 @@ export const SheetScrollView = React.forwardRef<
|
|
|
41
43
|
// or more ideally could use context to register if it has a scrollview and change behavior
|
|
42
44
|
// const offscreenSize = useSheetOffscreenSize(context)
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
const setScrollEnabled = (next: boolean) => {
|
|
47
|
+
scrollRef.current?.setNativeProps?.({
|
|
48
|
+
scrollEnabled: next,
|
|
49
|
+
})
|
|
50
|
+
setScrollEnabled_(next)
|
|
51
|
+
}
|
|
50
52
|
|
|
51
53
|
const state = React.useRef({
|
|
52
54
|
lastPageY: 0,
|
|
@@ -70,7 +72,7 @@ export const SheetScrollView = React.forwardRef<
|
|
|
70
72
|
state.current.isDragging = false
|
|
71
73
|
scrollBridge.scrollStartY = -1
|
|
72
74
|
state.current.isScrolling = false
|
|
73
|
-
|
|
75
|
+
setScrollEnabled(true)
|
|
74
76
|
let vy = 0
|
|
75
77
|
if (state.current.dys.length) {
|
|
76
78
|
const recentDys = state.current.dys.slice(-10)
|
|
@@ -102,6 +104,9 @@ export const SheetScrollView = React.forwardRef<
|
|
|
102
104
|
onScroll={(e) => {
|
|
103
105
|
const { y } = e.nativeEvent.contentOffset
|
|
104
106
|
scrollBridge.y = y
|
|
107
|
+
if (isWeb) {
|
|
108
|
+
scrollBridge.scrollLock = y > 0
|
|
109
|
+
}
|
|
105
110
|
if (y > 0) {
|
|
106
111
|
scrollBridge.scrollStartY = -1
|
|
107
112
|
}
|
|
@@ -123,41 +128,50 @@ export const SheetScrollView = React.forwardRef<
|
|
|
123
128
|
return scrollable
|
|
124
129
|
}}
|
|
125
130
|
// setting to false while onResponderMove is disabled
|
|
126
|
-
onMoveShouldSetResponder={() =>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
131
|
+
onMoveShouldSetResponder={(e) => {
|
|
132
|
+
return scrollable
|
|
133
|
+
}}
|
|
134
|
+
contentContainerStyle={{
|
|
135
|
+
minHeight: '100%',
|
|
136
|
+
}}
|
|
137
|
+
onResponderMove={(e) => {
|
|
138
|
+
// limiting to web as its tested on web
|
|
139
|
+
if (isWeb) {
|
|
140
|
+
const { pageY } = e.nativeEvent
|
|
141
|
+
|
|
142
|
+
if (state.current.isScrolling) {
|
|
143
|
+
e.stopPropagation()
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (scrollBridge.scrollStartY === -1) {
|
|
148
|
+
scrollBridge.scrollStartY = pageY
|
|
149
|
+
state.current.lastPageY = pageY
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const dragAt = pageY - scrollBridge.scrollStartY
|
|
153
|
+
const dy = pageY - state.current.lastPageY
|
|
154
|
+
state.current.lastPageY = pageY // after dy
|
|
155
|
+
const isDraggingUp = dy < 0
|
|
156
|
+
const isPaneAtTop = scrollBridge.paneY <= scrollBridge.paneMinY
|
|
157
|
+
|
|
158
|
+
if ((dy === 0 || isDraggingUp) && isPaneAtTop) {
|
|
159
|
+
state.current.isScrolling = true
|
|
160
|
+
scrollBridge.scrollLock = true
|
|
161
|
+
setScrollEnabled(true)
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
setScrollEnabled(false)
|
|
166
|
+
scrollBridge.drag(dragAt)
|
|
167
|
+
state.current.dragAt = dragAt
|
|
168
|
+
state.current.dys.push(dy)
|
|
169
|
+
// only do every so often, cut down to 10 again
|
|
170
|
+
if (state.current.dys.length > 100) {
|
|
171
|
+
state.current.dys = state.current.dys.slice(-10)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}}
|
|
161
175
|
{...props}
|
|
162
176
|
>
|
|
163
177
|
{children}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetImplementationCustom.d.ts","sourceRoot":"","sources":["../src/SheetImplementationCustom.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAA2B,MAAM,OAAO,CAAA;AAO/C,OAAO,EAAsC,IAAI,EAAE,MAAM,cAAc,CAAA;AAIvE,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,SAAS,CAAA;AAWzD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;yBAOhC,MAAM,aACT;;;
|
|
1
|
+
{"version":3,"file":"SheetImplementationCustom.d.ts","sourceRoot":"","sources":["../src/SheetImplementationCustom.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAA2B,MAAM,OAAO,CAAA;AAO/C,OAAO,EAAsC,IAAI,EAAE,MAAM,cAAc,CAAA;AAIvE,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,SAAS,CAAA;AAWzD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;yBAOhC,MAAM,aACT;;;8BAggBF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetScrollView.d.ts","sourceRoot":"","sources":["../src/SheetScrollView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SheetScrollView.d.ts","sourceRoot":"","sources":["../src/SheetScrollView.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,KAAK,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,cAAc,CAAA;AAY9D,eAAO,MAAM,eAAe;oDAXO,eACnC,uBAAuB,cAAc,0BAEvB,eAAc;;;;oDAHO,eACnC,uBAAuB,cAAc,0BAEvB,eAAc;;oDAHO,eACnC,uBAAuB,cAAc,0BAEvB,eAAc;;;;oDAHO,eACnC,uBAAuB,cAAc,0BAEvB,eAAc;;oDAHO,eACnC,uBAAuB,cAAc,0BAEvB,eAAc;;;wCA0K3B,CAAA"}
|