Get rid of animScale for now.
rodzic
d3e01a4865
commit
6ee909e436
|
@ -9,7 +9,6 @@ import {
|
|||
|
||||
type AnimationTransformer = (
|
||||
animPct: number,
|
||||
animScale: number,
|
||||
symbol: SvgSymbolData
|
||||
) => SvgTransform[];
|
||||
|
||||
|
@ -50,15 +49,13 @@ function pctToNegativeOneToOne(pct: number) {
|
|||
|
||||
const Y_HOVER_AMPLITUDE = 25.0;
|
||||
|
||||
const hoverTransformer: AnimationTransformer = (animPct, animScale) => {
|
||||
const hoverTransformer: AnimationTransformer = (animPct) => {
|
||||
const yHover =
|
||||
pctToNegativeOneToOne(easeInOutQuadPingPong(animPct)) *
|
||||
Y_HOVER_AMPLITUDE *
|
||||
animScale;
|
||||
pctToNegativeOneToOne(easeInOutQuadPingPong(animPct)) * Y_HOVER_AMPLITUDE;
|
||||
return [svgTranslate({ x: 0, y: yHover })];
|
||||
};
|
||||
|
||||
const spinTransformer: AnimationTransformer = (animPct, animScale, symbol) => {
|
||||
const spinTransformer: AnimationTransformer = (animPct, symbol) => {
|
||||
const origin = getBoundingBoxCenter(symbol.bbox);
|
||||
return [svgTransformOrigin(origin, [svgRotate(animPct * 360)])];
|
||||
};
|
||||
|
|
|
@ -53,21 +53,18 @@ export type CreatureSymbol = {
|
|||
export type CreatureSymbolProps = CreatureSymbol & {
|
||||
animator?: CreatureAnimator;
|
||||
animPct?: number;
|
||||
animScale?: number;
|
||||
};
|
||||
|
||||
type NestedCreatureSymbolProps = NestedCreatureSymbol & {
|
||||
parent: SvgSymbolData;
|
||||
animator: CreatureAnimator;
|
||||
animPct: number;
|
||||
animScale: number;
|
||||
};
|
||||
|
||||
type AttachedCreatureSymbolProps = AttachedCreatureSymbol & {
|
||||
parent: SvgSymbolData;
|
||||
animator: CreatureAnimator;
|
||||
animPct: number;
|
||||
animScale: number;
|
||||
};
|
||||
|
||||
function getNestingTransforms(parent: BBox, child: BBox) {
|
||||
|
@ -217,18 +214,15 @@ const NestedCreatureSymbol: React.FC<NestedCreatureSymbolProps> = ({
|
|||
return <>{children}</>;
|
||||
};
|
||||
|
||||
const CHILD_ANIM_SCALE_MULTIPLIER = 0.5;
|
||||
|
||||
export const CreatureSymbol: React.FC<CreatureSymbolProps> = (props) => {
|
||||
let ctx = useContext(CreatureContext);
|
||||
const { data, attachments, nests } = props;
|
||||
const attachmentCtx: CreatureContextType = { ...ctx, parent: data };
|
||||
const animator = props.animator ?? nullAnimator;
|
||||
const animPct = props.animPct ?? 0;
|
||||
const animScale = props.animScale ?? 1;
|
||||
const svgTransforms = useMemo(
|
||||
() => animator.getSvgTransforms(animPct, animScale, data),
|
||||
[animator, animPct, animScale, data]
|
||||
() => animator.getSvgTransforms(animPct, data),
|
||||
[animator, animPct, data]
|
||||
);
|
||||
const childAnimator = useMemo(() => animator.getChildAnimator(), [animator]);
|
||||
|
||||
|
@ -253,7 +247,6 @@ export const CreatureSymbol: React.FC<CreatureSymbolProps> = (props) => {
|
|||
{...a}
|
||||
parent={data}
|
||||
animPct={animPct}
|
||||
animScale={animScale * CHILD_ANIM_SCALE_MULTIPLIER}
|
||||
animator={childAnimator}
|
||||
/>
|
||||
))}
|
||||
|
@ -268,7 +261,6 @@ export const CreatureSymbol: React.FC<CreatureSymbolProps> = (props) => {
|
|||
{...n}
|
||||
parent={data}
|
||||
animPct={animPct}
|
||||
animScale={animScale * CHILD_ANIM_SCALE_MULTIPLIER}
|
||||
animator={childAnimator}
|
||||
/>
|
||||
))}
|
||||
|
|
Ładowanie…
Reference in New Issue