@fountain-ui/lab 2.0.0-beta.45 → 2.0.0-beta.46

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.
Files changed (45) hide show
  1. package/build/commonjs/ComicViewer/ComicViewer.js +28 -3
  2. package/build/commonjs/ComicViewer/ComicViewer.js.map +1 -1
  3. package/build/commonjs/ComicViewer/ComicViewerProps.js.map +1 -1
  4. package/build/commonjs/ComicViewer/FastScroll.js +162 -0
  5. package/build/commonjs/ComicViewer/FastScroll.js.map +1 -0
  6. package/build/commonjs/ComicViewer/FastScrollProps.js +6 -0
  7. package/build/commonjs/ComicViewer/FastScrollProps.js.map +1 -0
  8. package/build/commonjs/ComicViewer/index.js.map +1 -1
  9. package/build/commonjs/ComicViewer/util.js +27 -0
  10. package/build/commonjs/ComicViewer/util.js.map +1 -0
  11. package/build/module/ComicViewer/ComicViewer.js +27 -3
  12. package/build/module/ComicViewer/ComicViewer.js.map +1 -1
  13. package/build/module/ComicViewer/ComicViewerProps.js.map +1 -1
  14. package/build/module/ComicViewer/FastScroll.js +141 -0
  15. package/build/module/ComicViewer/FastScroll.js.map +1 -0
  16. package/build/module/ComicViewer/FastScrollProps.js +2 -0
  17. package/build/module/ComicViewer/FastScrollProps.js.map +1 -0
  18. package/build/module/ComicViewer/index.js.map +1 -1
  19. package/build/module/ComicViewer/util.js +15 -0
  20. package/build/module/ComicViewer/util.js.map +1 -0
  21. package/build/typescript/AnimatedY/AnimatedY.d.ts +1 -0
  22. package/build/typescript/BottomSheet/BottomSheetNative.d.ts +1 -0
  23. package/build/typescript/BottomSheet/BottomSheetWeb.d.ts +1 -0
  24. package/build/typescript/BottomSheet/TransparentBackdrop.d.ts +1 -0
  25. package/build/typescript/ComicViewer/ComicViewer.d.ts +1 -0
  26. package/build/typescript/ComicViewer/ComicViewerProps.d.ts +5 -0
  27. package/build/typescript/ComicViewer/FastScroll.d.ts +4 -0
  28. package/build/typescript/ComicViewer/FastScrollProps.d.ts +70 -0
  29. package/build/typescript/ComicViewer/ReloadButton.d.ts +1 -0
  30. package/build/typescript/ComicViewer/ViewerItem.d.ts +1 -0
  31. package/build/typescript/ComicViewer/index.d.ts +1 -0
  32. package/build/typescript/ComicViewer/util.d.ts +2 -0
  33. package/build/typescript/DateTimePicker/DateTimePicker.d.ts +1 -0
  34. package/build/typescript/DateTimePicker/YearPicker.d.ts +1 -0
  35. package/build/typescript/FlipCard/FlipCard.d.ts +1 -0
  36. package/build/typescript/StatusBarProvider/StatusBarProvider.d.ts +1 -0
  37. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerView.d.ts +1 -0
  38. package/package.json +3 -3
  39. package/src/ComicViewer/ComicViewer.tsx +40 -13
  40. package/src/ComicViewer/ComicViewerProps.ts +6 -0
  41. package/src/ComicViewer/FastScroll.tsx +158 -0
  42. package/src/ComicViewer/FastScrollProps.ts +83 -0
  43. package/src/ComicViewer/index.ts +6 -0
  44. package/src/ComicViewer/util.ts +15 -0
  45. package/yarn-error.log +103 -0
@@ -0,0 +1,158 @@
1
+ import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
2
+ import { NativeScrollEvent, NativeSyntheticEvent, View } from 'react-native';
3
+ import { Gesture, GestureDetector } from 'react-native-gesture-handler';
4
+ import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';
5
+ import { ChevronDown, ChevronUp } from '@fountain-ui/icons';
6
+ import { StyleSheet } from '@fountain-ui/core';
7
+ import FastScrollProps from './FastScrollProps';
8
+ import { offsetToPercentage, percentageToOffset } from './util';
9
+
10
+ const styles = StyleSheet.create({
11
+ indicator: {
12
+ width: 24,
13
+ height: 40,
14
+ backgroundColor: '#767676',
15
+ flexDirection: 'column',
16
+ alignItems: 'center',
17
+ borderRadius: 4,
18
+ },
19
+ view: { position: 'absolute' },
20
+ });
21
+
22
+ const FastScroll = React.forwardRef((props: FastScrollProps, ref) => {
23
+ const {
24
+ absolutePosition,
25
+ additionalLength = 0,
26
+ contentLength,
27
+ movementRange,
28
+ scrollContentToOffset,
29
+ visibleDurations = { hideMillis: 200, showMillis: 350 },
30
+ } = props;
31
+
32
+ const lastIndicatorOffset = useSharedValue(0);
33
+ const indicatorOffset = useSharedValue(lastIndicatorOffset.value);
34
+
35
+ const isIndicatorDragging = useRef(false);
36
+
37
+ const indicatorOpacity = useSharedValue(1);
38
+ const [visible, setVisible] = useState(true);
39
+
40
+ const animatedStyle = useAnimatedStyle(() => ({
41
+ transform: [{ translateY: indicatorOffset.value }],
42
+ opacity: indicatorOpacity.value,
43
+ }));
44
+
45
+ const totalContentLength = contentLength + additionalLength;
46
+
47
+ const onContentScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
48
+ if (isIndicatorDragging.current === false) {
49
+ const contentPercentage = offsetToPercentage(event.nativeEvent.contentOffset.y, totalContentLength);
50
+ const offset = percentageToOffset(contentPercentage, movementRange);
51
+
52
+ if (offset < 0 || indicatorOffset.value < 0) {
53
+ lastIndicatorOffset.value = 0;
54
+ indicatorOffset.value = 0;
55
+ return;
56
+ }
57
+
58
+ if (offset > movementRange || indicatorOffset.value > movementRange) {
59
+ lastIndicatorOffset.value = movementRange;
60
+ indicatorOffset.value = movementRange;
61
+ return;
62
+ }
63
+
64
+ lastIndicatorOffset.value = offset;
65
+ } else {
66
+ setVisible(true);
67
+ }
68
+ };
69
+
70
+ const getIsIndicatorDragging = () => isIndicatorDragging.current;
71
+
72
+ useImperativeHandle(
73
+ ref,
74
+ () => ({
75
+ getIsIndicatorDragging,
76
+ onContentScroll,
77
+ setVisible,
78
+ }),
79
+ [],
80
+ );
81
+
82
+ const handleUpdate = () => {
83
+ const contentPercentage = offsetToPercentage(indicatorOffset.value, movementRange);
84
+ const offset = percentageToOffset(contentPercentage, totalContentLength);
85
+
86
+ scrollContentToOffset(offset);
87
+ };
88
+
89
+ const setIsIndicatorDragging = (value: boolean) => isIndicatorDragging.current = value;
90
+
91
+ const pan = Gesture.Pan()
92
+ .onBegin((e) => {
93
+ indicatorOffset.value = lastIndicatorOffset.value;
94
+ runOnJS(setIsIndicatorDragging)(true);
95
+ })
96
+ .onUpdate((e) => {
97
+ if (indicatorOffset.value <= 0 && e.translationY < 0) {
98
+ indicatorOffset.value = 0;
99
+ return;
100
+ }
101
+
102
+ if (indicatorOffset.value >= movementRange && e.translationY > 0) {
103
+ indicatorOffset.value = movementRange;
104
+ return;
105
+ }
106
+
107
+ indicatorOffset.value = lastIndicatorOffset.value + e.translationY;
108
+
109
+ runOnJS(handleUpdate)();
110
+ })
111
+ .onFinalize((e) => {
112
+ lastIndicatorOffset.value = indicatorOffset.value;
113
+ runOnJS(setIsIndicatorDragging)(false);
114
+ });
115
+
116
+ const hide = () => indicatorOpacity.value = withDelay(0, withTiming(0, { duration: visibleDurations.hideMillis }));
117
+
118
+ const show = () => indicatorOpacity.value = withDelay(0, withTiming(1, { duration: visibleDurations.showMillis }));
119
+
120
+ useEffect(() => {
121
+ if (visible) {
122
+ indicatorOffset.value = lastIndicatorOffset.value;
123
+ show();
124
+ } else {
125
+ hide();
126
+ }
127
+ }, [visible]);
128
+
129
+ return (
130
+ <View
131
+ style={[
132
+ { height: movementRange },
133
+ styles.view,
134
+ absolutePosition,
135
+ ]}
136
+ >
137
+ <GestureDetector gesture={pan}>
138
+ <Animated.View style={[
139
+ animatedStyle,
140
+ styles.indicator,
141
+ ]}>
142
+ <ChevronUp
143
+ fill={'#ededed'}
144
+ height={20}
145
+ width={20}
146
+ />
147
+ <ChevronDown
148
+ fill={'#ededed'}
149
+ height={20}
150
+ width={20}
151
+ />
152
+ </Animated.View>
153
+ </GestureDetector>
154
+ </View>
155
+ );
156
+ });
157
+
158
+ export default FastScroll;
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import { NativeScrollEvent, NativeSyntheticEvent } from 'react-native';
3
+ import type { RefObject } from 'react';
4
+
5
+ /**
6
+ * Position infos with display: 'position'.
7
+ */
8
+ export type AbsolutePosition = {
9
+ top: number;
10
+ bottom: number;
11
+ right: number;
12
+ left: number;
13
+ };
14
+
15
+ /**
16
+ * Durations(millis) for show, hide animation.
17
+ */
18
+ export type VisibleDurations = {
19
+ hideMillis: number;
20
+ showMillis: number;
21
+ }
22
+
23
+ export interface FastScrollInstance {
24
+ /**
25
+ * Handle content scroll event, not using fast scroll indicator.
26
+ * @param event Function onScroll event params.
27
+ */
28
+ onContentScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
29
+
30
+ /**
31
+ * Set indicator visible state.
32
+ */
33
+ setVisible: React.Dispatch<React.SetStateAction<boolean>>;
34
+
35
+ /**
36
+ * Return true, if pan gesture state is begin to finalize.
37
+ */
38
+ getIsIndicatorDragging: () => boolean,
39
+ }
40
+
41
+ export interface FastScrollOptions {
42
+ /**
43
+ * Ref for React.forwardRef.
44
+ */
45
+ ref: RefObject<FastScrollInstance>;
46
+
47
+ /**
48
+ * Range within which the indicator can move.
49
+ */
50
+ movementRange: number;
51
+
52
+ /**
53
+ * Scrollbar positions for 'display: position'.
54
+ */
55
+ absolutePosition?: Partial<AbsolutePosition>;
56
+
57
+ /**
58
+ * Durations(millis) for show, hide animation.
59
+ * @default { hide: 200, show: 350 }
60
+ */
61
+ visibleDurations?: VisibleDurations;
62
+
63
+ /**
64
+ * Additional height except contentLength.
65
+ * @default 0
66
+ */
67
+ additionalLength?: number;
68
+ }
69
+
70
+ interface FastScrollProps extends FastScrollOptions {
71
+ /**
72
+ * Total length of scrollable content.
73
+ */
74
+ contentLength: number;
75
+
76
+ /**
77
+ * Scroll content to offset appropriate for the indicator location.
78
+ * @param offset Content offset.
79
+ */
80
+ scrollContentToOffset: (offset: number) => void;
81
+ }
82
+
83
+ export default FastScrollProps;
@@ -1,3 +1,9 @@
1
1
  export { default } from './ComicViewer';
2
2
  export type { Dimension, default as ComicViewerProps } from './ComicViewerProps';
3
3
  export type { ViewerItemProps } from './ViewerItem';
4
+ export type {
5
+ AbsolutePosition,
6
+ FastScrollInstance,
7
+ FastScrollOptions,
8
+ VisibleDurations,
9
+ } from './FastScrollProps';
@@ -0,0 +1,15 @@
1
+ export const offsetToPercentage = (offset: number, total: number) => {
2
+ if (offset === 0 || total === 0) {
3
+ return 0;
4
+ }
5
+
6
+ return offset / total * 100;
7
+ };
8
+
9
+ export const percentageToOffset = (percentage: number, total: number) => {
10
+ if (percentage === 0 || total === 0) {
11
+ return 0;
12
+ }
13
+
14
+ return percentage / 100 * total;
15
+ };
package/yarn-error.log ADDED
@@ -0,0 +1,103 @@
1
+ Arguments:
2
+ /Users/chan/.nvm/versions/node/v16.16.0/bin/node /usr/local/Cellar/yarn/1.22.19/libexec/bin/yarn.js add react-native-device-info
3
+
4
+ PATH:
5
+ /Users/chan/.nvm/versions/node/v16.16.0/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/chan/IdeaProjects/tappytoon/bin/git-ext:/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/chan/IdeaProjects/tappytoon/bin/git-ext:/Users/chan/Library/Android/sdk/tools:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/chan/IdeaProjects/tappytoon/bin/git-ext:/Users/chan/Library/Android/sdk/platform-tools:/Users/chan/library/android/sdk/tools:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/chan/IdeaProjects/tappytoon/bin/git-ext:/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/chan/IdeaProjects/tappytoon/bin/git-ext:/Users/chan/Library/Android/sdk/tools:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/chan/IdeaProjects/tappytoon/bin/git-ext:/Users/chan/Library/Android/sdk/platform-tools:/Users/hyungchanyuk/library/android/sdk/platform-tools:/Users/chan/WebstormProjects/tappytoon/bin/git-ext
6
+
7
+ Yarn version:
8
+ 1.22.19
9
+
10
+ Node version:
11
+ 16.16.0
12
+
13
+ Platform:
14
+ darwin x64
15
+
16
+ Trace:
17
+ SyntaxError: /Users/chan/WebstormProjects/tappytoon/nodejs/fountain-ui/packages/fountain-ui-lab/package.json: Unexpected token } in JSON at position 681
18
+ at JSON.parse (<anonymous>)
19
+ at /usr/local/Cellar/yarn/1.22.19/libexec/lib/cli.js:1629:59
20
+ at Generator.next (<anonymous>)
21
+ at step (/usr/local/Cellar/yarn/1.22.19/libexec/lib/cli.js:310:30)
22
+ at /usr/local/Cellar/yarn/1.22.19/libexec/lib/cli.js:321:13
23
+
24
+ npm manifest:
25
+ {
26
+ "name": "@fountain-ui/lab",
27
+ "version": "2.0.0-beta.45",
28
+ "private": false,
29
+ "author": "Fountain-UI Team",
30
+ "description": "Incubator for Fountain-UI React components.",
31
+ "license": "MIT",
32
+ "main": "./build/commonjs/index.js",
33
+ "module": "./build/module/index.js",
34
+ "react-native": "./src/index.ts",
35
+ "source": "./src/index.ts",
36
+ "types": "./build/typescript/index.d.ts",
37
+ "scripts": {
38
+ "clean": "rimraf build",
39
+ "prepare": "bob build"
40
+ },
41
+ "dependencies": {
42
+ "@emotion/react": "^11.10.0",
43
+ "@emotion/styled": "^11.10.0",
44
+ "@fountain-ui/icons": "^2.0.0-beta.9",
45
+ "@fountain-ui/utils": "^2.0.0-beta.4",
46
+ "react-native-calendars": "1.1267.0",
47
+ },
48
+ "peerDependencies": {
49
+ "@fountain-ui/core": "^2.0.0-beta.3",
50
+ "@gorhom/bottom-sheet": "^4.5.0",
51
+ "date-fns": "^2.0.0",
52
+ "react": "^16.8.0 || ^17.0.0",
53
+ "react-dom": "^16.8.0 || ^17.0.0",
54
+ "react-native": "^0.63.0",
55
+ "react-native-gesture-handler": "^2.0.0",
56
+ "react-native-pager-view": "^4.0.0"
57
+ },
58
+ "peerDependenciesMeta": {
59
+ "@gorhom/bottom-sheet": {
60
+ "optional": true
61
+ },
62
+ "react-dom": {
63
+ "optional": true
64
+ },
65
+ "react-native-pager-view": {
66
+ "optional": true
67
+ }
68
+ },
69
+ "devDependencies": {
70
+ "@gorhom/bottom-sheet": "^4.5.0",
71
+ "date-fns": "^2.23.0",
72
+ "react-native-pager-view": "^4.2.4",
73
+ "react-native-safe-area-context": "^4.0.0"
74
+ },
75
+ "react-native-builder-bob": {
76
+ "source": "./src",
77
+ "output": "./build",
78
+ "targets": [
79
+ "commonjs",
80
+ "module",
81
+ [
82
+ "typescript",
83
+ {
84
+ "project": "tsconfig.build.json",
85
+ "tsc": "../../node_modules/.bin/tsc"
86
+ }
87
+ ]
88
+ ],
89
+ "files": [
90
+ "./src",
91
+ "./build"
92
+ ]
93
+ },
94
+ "publishConfig": {
95
+ "access": "public"
96
+ }
97
+ }
98
+
99
+ yarn manifest:
100
+ No manifest
101
+
102
+ Lockfile:
103
+ No lockfile