Giter VIP home page Giter VIP logo

Comments (10)

deadcoder0904 avatar deadcoder0904 commented on June 5, 2024 12

@mattgperry Can confirm, this is still a bug. I want to rotate an SVG on hover to 0deg from initial position -6deg so I wrote it like this:

<motion.svg
  initial={{
    rotate: -6,
  }}
  whileHover={{
    rotate: 0,
  }}
>
  {/*...*/}
</motion.svg>

But it automatically adds transform-origin: 87.936px 88.936px; to the browser when I didn't even specify anything.

I think it should be just 0px 0px if nothing is provided.

from motion.

joshuawootonn avatar joshuawootonn commented on June 5, 2024 7

Setting

I had the same issue. Setting this, worked for me:

style={{originX: 0.5, originY: 0.5}}

This didn't work for me but it led me to

 style={{ originX: '50%', originY: '50%' }}

which did!!

from motion.

klvnptr avatar klvnptr commented on June 5, 2024 5

I'm having the same issue. Please fix this bug.

from motion.

Victoire44 avatar Victoire44 commented on June 5, 2024 5

I had the same issue. Setting this, worked for me:

style={{originX: 0.5, originY: 0.5}}

from motion.

jameswesc avatar jameswesc commented on June 5, 2024 3

Ah I just realised setting originX to "0px", not 0, is what I want.

As it mentions in the documentation:

If set as numbers, originX and Y default to a progress value between 0 and 1.

A progress value of what though? The bounds of the object?

from motion.

dillonbhola avatar dillonbhola commented on June 5, 2024 2

This bug is in build 1.10.3.

I tried rotating a circle svg element to simulate the movement of the sun. Setting the transformOrigin of the circle gets overridden. Here is a codesandbox showing an example.

Here is what the css shows when I inspect the element in chrome.
image

Here's what I tried:

  • adding "transform-origin": "center" to the hidden and visible properties of the variant object (transformOrigin throws and error).
  • wrapping the circle element in a motion.g element and adding the transform origin style there.

from motion.

joshuawootonn avatar joshuawootonn commented on June 5, 2024 1

Setting

I had the same issue. Setting this, worked for me:

style={{originX: 0.5, originY: 0.5}}

This didn't work for me but it led me to

 style={{ originX: '50%', originY: '50%' }}

which did!!

Nevermind... 50% here sets the origin relative to the svg tag, while using a number evidently sets the origin relative to the path itself. It working earlier was just a fluke

from motion.

mattgperry avatar mattgperry commented on June 5, 2024

Fixed in 1.6.4

from motion.

jameswesc avatar jameswesc commented on June 5, 2024

Hi, I'm still having this issue when transforming motion.g elements. Even if I set my own transform origin it seems to set its own based on the bounding box of its children.

See here: https://codesandbox.io/s/determined-monad-rcidp

Expected: transform-origin to be set to originX originY

It doesn't show in the codesandbox, but I've noticed it also tries to set the transform-origin as transformOrigin which react doesn't recogniee.

from motion.

kcpru avatar kcpru commented on June 5, 2024

The bug persists exclusively on Firefox. It consistently sets the value transform-origin: 0px 0px 0px, and only applying style={{ originX: '50%', originY: '50%' }} or transform-origin: 50% 50% !important helps to achieve the desired result. Notably, the functionality works correctly on Chrome.

<motion.circle
    cx="50"
    cy="45"
    r="10"
    fill="black"
    animate={{
        y: active ? 5 : 0,
        scale: active ? 3 : 1,
    }}
/>

from motion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.