Skip to content

Commit

Permalink
fix: spread -> assign
Browse files Browse the repository at this point in the history
  • Loading branch information
nandorojo committed Mar 4, 2021
1 parent 1b93862 commit 8d0f89a
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 9 deletions.
3 changes: 2 additions & 1 deletion examples/with-expo/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// export { default } from './src/Drip.Presence'
// export { default } from './src/Moti.ExitBeforeEnter'
// export { default } from './src/Moti.Loop'
export { default } from './src/Moti.Skeleton'
// export { default } from './src/Moti.Skeleton'
export { default } from './src/Moti.Sequence'
// export { default } from './src/Moti.HelloWorld'
// export { default } from './src/Moti.Variants'
51 changes: 51 additions & 0 deletions examples/with-expo/src/Moti.Sequence.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React, { useReducer } from 'react'
import { StyleSheet, Pressable } from 'react-native'
import { View } from 'moti'

function Shape() {
return (
<View
from={{
opacity: 0,
scale: 0.5,
}}
animate={{
opacity: [1, 0, 1],
scale: [1, 2, 1],
}}
transition={{
type: 'timing',
}}
delay={300}
style={styles.shape}
/>
)
}

export default function HelloWorld() {
const [visible, toggle] = useReducer((s) => !s, true)

return (
<Pressable onPress={toggle} style={styles.container}>
{visible && <Shape />}
</Pressable>
)
}

const styles = StyleSheet.create({
shape: {
justifyContent: 'center',
height: 250,
width: 250,
borderRadius: 25,
marginRight: 10,
backgroundColor: 'black',
},
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'row',
backgroundColor: '#9c1aff',
},
})
16 changes: 8 additions & 8 deletions packages/core/src/use-map-animate-to-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export default function useMapAnimateToStyle<Animate>({
transition,
delay: defaultDelay,
state,
stylePriority = 'state',
stylePriority = 'animate',
onDidAnimate,
exit,
}: MotiProps<Animate>) {
Expand Down Expand Up @@ -254,9 +254,9 @@ export default function useMapAnimateToStyle<Animate>({

let mergedStyles: Animate = {} as Animate
if (stylePriority === 'state') {
mergedStyles = { ...animateStyle, ...variantStyle }
mergedStyles = Object.assign({}, animateStyle, variantStyle)
} else {
mergedStyles = { ...variantStyle, ...animateStyle }
mergedStyles = Object.assign(variantStyle, animateStyle)
}

if (isExiting && exitStyle) {
Expand Down Expand Up @@ -360,7 +360,8 @@ export default function useMapAnimateToStyle<Animate>({
.map((step) => {
let stepDelay = delayMs
let stepValue = step
let stepConfig = { ...config }
// let stepConfig = { ...config }
let stepConfig = Object.assign({}, config)
let stepAnimation = animation
if (typeof step === 'object') {
// TODO this should spread from step, but reanimated won't allow this on JS thread?
Expand All @@ -375,10 +376,9 @@ export default function useMapAnimateToStyle<Animate>({
animation,
} = animationConfig(key, transition)

stepConfig = {
...stepConfig,
// ...customConfig
}
stepConfig = Object.assign({}, stepConfig)
// TODO test, does this work?
// stepConfig = Object.assign({}, stepConfig, customConfig)
stepAnimation = animation
if (delay != null) {
stepDelay = delay
Expand Down

1 comment on commit 8d0f89a

@vercel
Copy link

@vercel vercel bot commented on 8d0f89a Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.