@codeleap/mobile 3.15.3 → 3.15.4
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/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AnyFunction,
|
|
2
3
|
ComponentVariants,
|
|
3
4
|
onUpdate,
|
|
4
5
|
TypeGuards,
|
|
@@ -48,6 +49,7 @@ export type PagerProps = React.PropsWithChildren<{
|
|
|
48
49
|
scrollRightEnabled?: boolean
|
|
49
50
|
scrollLeftEnabled?: boolean
|
|
50
51
|
scrollDirectionThrottle?: number
|
|
52
|
+
onSwipeLastPage?: (event: ScrollEvent) => void
|
|
51
53
|
} & ScrollViewProps>
|
|
52
54
|
|
|
53
55
|
const defaultProps: Partial<PagerProps> = {
|
|
@@ -81,6 +83,7 @@ export const Pager = (pagerProps: PagerProps) => {
|
|
|
81
83
|
scrollRightEnabled,
|
|
82
84
|
onScroll,
|
|
83
85
|
scrollDirectionThrottle,
|
|
86
|
+
onSwipeLastPage,
|
|
84
87
|
} = {
|
|
85
88
|
...defaultProps,
|
|
86
89
|
...pagerProps,
|
|
@@ -125,13 +128,15 @@ export const Pager = (pagerProps: PagerProps) => {
|
|
|
125
128
|
const hasScrollDirectionDisabled = !scrollLeftEnabled || !scrollRightEnabled
|
|
126
129
|
|
|
127
130
|
const handleScrollEnd = useCallback(
|
|
128
|
-
(
|
|
129
|
-
const x = nativeEvent.contentOffset.x
|
|
131
|
+
(event: ScrollEvent) => {
|
|
132
|
+
const x = event?.nativeEvent.contentOffset.x
|
|
130
133
|
const toPage = Math.ceil(x / width)
|
|
131
134
|
|
|
132
135
|
if (toPage !== page && toPage <= childArr.length - 1) {
|
|
133
136
|
setPage(toPage)
|
|
134
137
|
setPositionX(toPage * width)
|
|
138
|
+
} else if (toPage >= childArr.length - 1 && TypeGuards.isFunction(onSwipeLastPage)) {
|
|
139
|
+
onSwipeLastPage?.(event)
|
|
135
140
|
}
|
|
136
141
|
},
|
|
137
142
|
[childArr, page, setPage],
|