Skip to content

Commit

Permalink
feat: Motion/Transition 컴포넌트에서 scale 애니메이션을 사용 가능하게 한다. (#923)
Browse files Browse the repository at this point in the history
* refactor: remove unused transform system prop

* feat: add motion scale prop
  • Loading branch information
YimJiYoung authored Jan 3, 2024
1 parent 274ff21 commit 29a820e
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 22 deletions.
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

1 comment on commit 29a820e

@vercel
Copy link

@vercel vercel bot commented on 29a820e Jan 3, 2024

Choose a reason for hiding this comment

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

@YimJiYoung is attempting to deploy a commit to the Class101 Team on Vercel.

To accomplish this, @YimJiYoung needs to request access to the Team.

Afterwards, an owner of the Team is required to accept their membership request.

If you're already a member of the respective Vercel Team, make sure that your Personal Vercel Account is connected to your GitHub account.

Please sign in to comment.