Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

translate property with relative percentage do not work #214

Closed
shirohana opened this issue Jul 30, 2017 · 5 comments
Closed

translate property with relative percentage do not work #214

shirohana opened this issue Jul 30, 2017 · 5 comments
Assignees
Milestone

Comments

@shirohana
Copy link

Hello,

As title, here's my code:

anime({
  targets: el,
  translateX: '-=100%'  // <- It became to '-100px' in fact
})

Is it a bug or expected behavior?

@juliangarnier juliangarnier added this to the 2.1.0 milestone Sep 10, 2017
@juliangarnier juliangarnier self-assigned this Sep 10, 2017
@juliangarnier
Copy link
Owner

Thanks for pointing this.
Fixed in next release!

@syropian
Copy link

This doesn't seem to be working for me in the latest version. If I have an element with like so:

.my-el {
  transform: translateY(20%);
}

and do something like

anime({
  targets: ".my-el",
  translateY: "-=5%"
})

i expect it to have a translateY of 15%, but instead it sets it to translateY(-5%)

@trych
Copy link

trych commented Jan 10, 2020

I have the same problem.

.my-el {
  transform: translateX(-40%);
}
anime({
  targets: ".my-el",
  translateX: "-=60%"
})

Target starts animating at translateX(0) and translates to translate(-60%) instead of going from translate(-40%) to translate(-100%) as expected. Is this something that broke in recent releases?

Edit: Btw, for consecutive calls, it seems to work correctly. So somehow anime.js seems to mess up reading the initial value under certain circumstances. After that it works.

@syropian did you ever get this to work?

@aderchox
Copy link

It's not working for me either. Here's a (an ugly) workaround I'll share for future readers until this gets fixed (hopefully).

Just specify which values are going to be animated (e.g., the translateX value) and then just add its initial value as a variable on the root element, then get and set it with your anime.js just as you could target any other JavaScript variables (i.e.: link). I tried this and it works.

@stephen-97
Copy link

Still not working for me too. @trych
Thank you for the tip @aderchox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants