Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Motion/Transition 컴포넌트에서 scale 애니메이션을 사용 가능하게 한다. #923

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/vibrant-motion/src/lib/Motion/Motion.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Animated } from 'react-native';
import { useInterpolation } from '@vibrant-ui/core';
import { useSafeDeps } from '@vibrant-ui/utils';
import { NATIVE_SUPPORT_ANIMATION_PROPERTIES, easings } from '../constants';
import { transformMotionProps } from '../props/transform';
import { handleTransformStyle } from '../utils/handleTransformStyle';
import { withMotionVariation } from './MotionProps';

Expand All @@ -23,7 +22,7 @@ export const Motion = withMotionVariation(
style = {},
...restProps
}) => {
const { interpolation } = useInterpolation(transformMotionProps);
const { interpolation } = useInterpolation();
const onEndRef = useSafeDeps(onEnd);

const useNativeDriver = useRef(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { Animated } from 'react-native';
import { useInterpolation } from '@vibrant-ui/core';
import { useSafeDeps } from '@vibrant-ui/utils';
import { NATIVE_SUPPORT_ANIMATION_PROPERTIES, easings } from '../constants';
import { transformMotionProps } from '../props/transform';
import { handleTransformStyle } from '../utils/handleTransformStyle';
import { withTransitionVariation } from './TransitionProp';

export const Transition = withTransitionVariation(
({ innerRef, children, style = {}, animation, duration = 500, easing = 'easeOutQuad', onEnd, ...restProps }) => {
const { interpolation } = useInterpolation(transformMotionProps);
const { interpolation } = useInterpolation();
const reverse = useRef(false);
const isFirstRender = useRef(true);
const onEndRef = useSafeDeps(onEnd);
Expand Down
1 change: 0 additions & 1 deletion packages/vibrant-motion/src/lib/props/transform/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { transformMotionProps } from './transform';
export type { TransformMotionProps } from './type';
15 changes: 0 additions & 15 deletions packages/vibrant-motion/src/lib/props/transform/transform.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/vibrant-motion/src/lib/props/transform/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export type TransformMotionProps = {
x?: ResponsiveValue<number | `${number}%`>;
y?: ResponsiveValue<number | `${number}%`>;
rotate?: ResponsiveValue<string>;
scale?: ResponsiveValue<number>;
};
5 changes: 3 additions & 2 deletions packages/vibrant-motion/src/lib/utils/handleTransformStyle.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { isDefined } from '@vibrant-ui/utils';

export const handleTransformStyle = (style: Record<string, any>) => {
const { x, y, rotate, ...restStyle } = style;
const { x, y, rotate, scale, ...restStyle } = style;

if (isDefined(x) || isDefined(y) || isDefined(rotate)) {
if (isDefined(x) || isDefined(y) || isDefined(rotate) || isDefined(scale)) {
return {
...restStyle,
transform: {
...(isDefined(x) ? { translateX: x } : {}),
...(isDefined(y) ? { translateY: y } : {}),
...(isDefined(rotate) ? { rotate } : {}),
...(isDefined(scale) ? { scale } : {}),
},
};
}
Expand Down
Loading