@neko-os/ui 0.0.11 → 0.0.12
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/abstractions/AnimatedView.native.js +1 -1
- package/dist/modifiers/animations/animatedEffects.web.js +1 -1
- package/package.json +1 -1
- package/src/abstractions/AnimatedView.native.js +1 -2
- package/src/modifiers/animations/animatedEffects.js +0 -1
- package/src/modifiers/animations/animatedEffects.web.js +54 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";var _jsxFileName="/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/abstractions/AnimatedView.native.js";import
|
|
1
|
+
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";var _jsxFileName="/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/abstractions/AnimatedView.native.js";import Animated from'react-native-reanimated';import{jsx as _jsx}from"react/jsx-runtime";export function AbsAnimatedView(_ref){var children=_ref.children,style=_ref.style,_ref$animatedStyles=_ref.animatedStyles,animatedStyles=_ref$animatedStyles===void 0?[]:_ref$animatedStyles;return _jsx(Animated.View,{style:[style].concat(_toConsumableArray(animatedStyles)),children:children});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";var _excluded=["open","onClose","lazy","unmountOnClose"];import{pipe}from'ramda';import{useSharedValue}from'react-native-reanimated';import React from'react';import{useFadeEffect}from"./fadeEffect";import{useScaleEffect}from"./scaleEffect";import{useSlideEffect}from"./slideEffect";export function useAnimatedEffects(_ref){var _ref2=_slicedToArray(_ref,2),values=_ref2[0],_ref2$=_ref2[1],_ref2$$open=_ref2$.open,open=_ref2$$open===void 0?true:_ref2$$open,onClose=_ref2$.onClose,_ref2$$lazy=_ref2$.lazy,lazy=_ref2$$lazy===void 0?false:_ref2$$lazy,_ref2$$unmountOnClose=_ref2$.unmountOnClose,unmountOnClose=_ref2$$unmountOnClose===void 0?false:_ref2$$unmountOnClose,props=_objectWithoutProperties(_ref2$,_excluded);var unmountTimerRef=React.useRef();var _React$useState=React.useState(0),_React$useState2=_slicedToArray(_React$useState,2),totalDuration=_React$useState2[0],setTotalDuration=_React$useState2[1];var _React$useState3=React.useState(open||!lazy),_React$useState4=_slicedToArray(_React$useState3,2),hasOpened=_React$useState4[0],setHasOpened=_React$useState4[1];var _React$useState5=React.useState(open||!lazy),_React$useState6=_slicedToArray(_React$useState5,2),render=_React$useState6[0],setRender=_React$useState6[1];var useRegisterEffect=function useRegisterEffect(effect){React.useEffect(function(){if(!(effect!=null&&effect.duration))return;setTotalDuration(function(v){return v>effect.duration?v:effect.duration;});},[]);};var translate=useSharedValue(0);React.useEffect(function(){if(open){clearTimeout(unmountTimerRef==null?void 0:unmountTimerRef.current);setHasOpened(true);setRender(true);}else if(unmountOnClose){unmountTimerRef.current=setTimeout(function(){return setRender(false);},totalDuration);}},[open]);return pipe(useFadeEffect,useSlideEffect,useScaleEffect)([Object.assign({},values,{animatedStyles:[],useRegisterEffect:useRegisterEffect,useAddTransition:function useAddTransition(){},open:open,onClose:onClose,lazy:lazy,unmountOnClose:unmountOnClose,hasOpened:hasOpened,setHasOpened:setHasOpened,render:render,setRender:setRender}),Object.assign({},props,{animatedStyles:[]})]);}
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Animated, { useAnimatedStyle } from 'react-native-reanimated'
|
|
1
|
+
import Animated from 'react-native-reanimated'
|
|
3
2
|
|
|
4
3
|
export function AbsAnimatedView({ children, style, animatedStyles = [] }) {
|
|
5
4
|
return <Animated.View style={[style, ...animatedStyles]}>{children}</Animated.View>
|
|
@@ -1,3 +1,55 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pipe } from 'ramda'
|
|
2
|
+
import { useSharedValue } from 'react-native-reanimated'
|
|
3
|
+
import React from 'react'
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
import { useFadeEffect } from './fadeEffect'
|
|
6
|
+
import { useScaleEffect } from './scaleEffect'
|
|
7
|
+
import { useSlideEffect } from './slideEffect'
|
|
8
|
+
|
|
9
|
+
export function useAnimatedEffects([values, { open = true, onClose, lazy = false, unmountOnClose = false, ...props }]) {
|
|
10
|
+
const unmountTimerRef = React.useRef()
|
|
11
|
+
const [totalDuration, setTotalDuration] = React.useState(0)
|
|
12
|
+
const [hasOpened, setHasOpened] = React.useState(open || !lazy)
|
|
13
|
+
const [render, setRender] = React.useState(open || !lazy)
|
|
14
|
+
|
|
15
|
+
const useRegisterEffect = (effect) => {
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
if (!effect?.duration) return
|
|
18
|
+
setTotalDuration((v) => (v > effect.duration ? v : effect.duration))
|
|
19
|
+
}, [])
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const translate = useSharedValue(0)
|
|
23
|
+
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
if (open) {
|
|
26
|
+
clearTimeout(unmountTimerRef?.current)
|
|
27
|
+
setHasOpened(true)
|
|
28
|
+
setRender(true)
|
|
29
|
+
} else if (unmountOnClose) {
|
|
30
|
+
unmountTimerRef.current = setTimeout(() => setRender(false), totalDuration)
|
|
31
|
+
}
|
|
32
|
+
}, [open])
|
|
33
|
+
|
|
34
|
+
return pipe(
|
|
35
|
+
useFadeEffect, //
|
|
36
|
+
useSlideEffect,
|
|
37
|
+
useScaleEffect
|
|
38
|
+
)([
|
|
39
|
+
{
|
|
40
|
+
...values,
|
|
41
|
+
animatedStyles: [],
|
|
42
|
+
useRegisterEffect,
|
|
43
|
+
useAddTransition: () => {},
|
|
44
|
+
open,
|
|
45
|
+
onClose,
|
|
46
|
+
lazy,
|
|
47
|
+
unmountOnClose,
|
|
48
|
+
hasOpened,
|
|
49
|
+
setHasOpened,
|
|
50
|
+
render,
|
|
51
|
+
setRender,
|
|
52
|
+
},
|
|
53
|
+
{ ...props, animatedStyles: [] },
|
|
54
|
+
])
|
|
55
|
+
}
|