1

I am using react-motion for CSS transfrom in react. this bellow code scales my desired output from top left corner.

<Motion defaultStyle={{ x: 0 }} style={{ x: spring(360) }}>
    {(value) => {
        return (
            <div
                style={{
                    width: value.x,
                    height: value.x,
                    animation: `scale 5s infinite`,
                    transform: `scale(1,1)`,
                }}
            >
                {" "}
                <this.ComponentName post={post} view={view} />
            </div>
        );
    }}
</Motion>

How can i make it scale from center?

Guilherme Samuel
  • 459
  • 6
  • 11
Rafi Ud Daula Refat
  • 2,187
  • 19
  • 28

1 Answers1

1

I have come to a solution. It can be done with a few changes but a tricky one.

<Motion defaultStyle={{ x: 0 }} style={{ x: spring(1) }} >
{value => {return <div style={{
  animation: `scale 5s infinite`,
  transform: `scale(${value.x})`,
}}
> <this.ComponentName post={post} view={view}/></div>}}

Rafi Ud Daula Refat
  • 2,187
  • 19
  • 28