Git Product home page Git Product logo

Comments (12)

juliangarnier avatar juliangarnier commented on May 6, 2024 1

You can animate the transform-origin property like any other css properties:

Like this:

anime({
  targets: 'div',
  transformOrigin: ['0px 0px', '100px 50px']
});

And a running demo here: http://codepen.io/juliangarnier/pen/WxWaWE

from anime.

alexchantastic avatar alexchantastic commented on May 6, 2024

Can you use the transform-origin CSS property (https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin) to accomplish this?

from anime.

oscarotero avatar oscarotero commented on May 6, 2024

Transforms on SVG elements are a bit painfull in IE You can see an explanation here:
https://css-tricks.com/transforms-on-svg-elements/

from anime.

mkermani144 avatar mkermani144 commented on May 6, 2024

@oscarotero Thanks for your reply, but the concept of this issue is neither about SVGs nor about IE. I only want to scale some <img> or <div> elements in Firefox or Chrome.

from anime.

oscarotero avatar oscarotero commented on May 6, 2024

@mkermani144 Ok, so transform-origin is your solution.
Anyway, I'd love to have a cross-browser way working with html and svg elements like GSAP

from anime.

mkermani144 avatar mkermani144 commented on May 6, 2024

@alexchantastic @oscarotero No, transform-origin doesn't work for me.
Look at this code: http://codepen.io/mkermani144/full/NAVQpO/ . However transform-origin is set to the center of the page for each rectangle, after clicking they don't use the specified origin.

from anime.

oscarotero avatar oscarotero commented on May 6, 2024

transform-origin is relative to the element you want to transform. By default is center center or 50% 50%, so it's relative to the centered point of the element. I'd use translate in addition to scale, to move the element to the center of the window after scale it.

from anime.

mkermani144 avatar mkermani144 commented on May 6, 2024

@oscarotero Yes, I know transform-origin is at the center of element by default. I even set it to be at the center of the element for certainty, but the problem still exists.

from anime.

mkermani144 avatar mkermani144 commented on May 6, 2024

@juliangarnier I don't want to animate transform-origin. I have a div element somewhere in the page. I use anime's translates to move that div to the center of the page. I also want to scale that div when it is at the center of the page and with transform-origin set to center of the page too. But as I mentioned, the behavior of scale is unexpected.
http://codepen.io/mkermani144/full/Pzgpbx/

from anime.

juliangarnier avatar juliangarnier commented on May 6, 2024

Sorry but that looks more like a CSS problem than a bug related to the library.

from anime.

mkermani144 avatar mkermani144 commented on May 6, 2024

I found the problem. The order of anime's argument attributes matters. For more info, see #63.

from anime.

juliangarnier avatar juliangarnier commented on May 6, 2024

Yes and like I said in #63, this is the expected behaviour of CSS transforms.
But i'm glad that you found the problem!

from anime.

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.