Comments (12)
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.
Can you use the transform-origin
CSS property (https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin) to accomplish this?
from anime.
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.
@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.
@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.
@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.
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.
@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.
@juliangarnier I don't want to animate transform-origin
. I have a div
element somewhere in the page. I use anime
's translate
s 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.
Sorry but that looks more like a CSS problem than a bug related to the library.
from anime.
I found the problem. The order of anime
's argument attributes matters. For more info, see #63.
from anime.
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)
- Search bar in documentation. HOT 4
- A dedicated section for setup and installation guide. HOT 3
- if use translate and scale for the same time,it will be strange HOT 1
- changeComplete is not called when a big lag happens at the very start
- JAVASCRIPT Nested OBJECT HOT 1
- Animation does not continue after pause and reversal HOT 2
- Speed up the duration during reverse playback
- Unable to use anime.js with node and express HOT 11
- Feature: ability to set innerHTML beyond numeric values HOT 1
- Spider-weeb app
- Bug report: spring-based motion not completing (Vanilla JS, HTML, CSS) HOT 4
- How to run animation on same element but with different text ? HOT 3
- can you run a for each loop in the targets? or refresh where the target is pointing to with the loopComplete callback?
- Just a question about line drawing in the docs HOT 2
- Why a cant use play/pause buttons? HOT 1
- Why cant I connect anime? HOT 1
- Does anime have a feature that can be used to implement horizontal scrolling? HOT 1
- anime.seek(0) not working HOT 3
- Anime V4 HOT 2
- Duration property problem when I use an event
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from anime.