Jump to content
Search Community

Problem with set position x with svg

Baret test
Moderator Tag

Recommended Posts

Hello,
I'm trying to animate a random opening with a vernier caliper but I'm having a problem.
On the pen code when the two zeros are aligned the x position of the vernier is equal to zero.
The problem is that from time to time for a given opening greater than zero the vernier moves to the left in abutment and yet the value of the requested vernier position is greater than zero. I can't find out why and that's why I need your help. thank you.

Jean-Michel

See the Pen wvGzOwp by jmbaret (@jmbaret) on CodePen

Link to comment
Share on other sites

Hey Baret. Very interesting! Thanks for posting. 

 

I noticed that the values that break all follow a consistent format: they all don't have 3 decimal places. They either have 1 or two, like 133.4, 355.7, 160.25, 262.9. It seems that trailing 0s when you pass in a string cause GSAP to render the value as 0. Definitely a bug :) 

See the Pen f79bfe2904520c089bf5d7e01e849a37 by GreenSock (@GreenSock) on CodePen

 

But in general it's probably best to use numerical values, not strings, unless you also add a unit.

  • Thanks 1
Link to comment
Share on other sites

Interesting. I've never seen someone try to do that before. Since you passed in a string, it interpreted the padded zeros at the end as if you intended those to be the unit (like "px" would be in "20.1px"). I've added code to work around that condition in the next release which you can preview at https://assets.codepen.io/16327/gsap-latest-beta.min.js

  • Like 2
Link to comment
Share on other sites

Merci Jack, merci ZachSaucier, en
effet je fais un usage particulier de Greensock. C'est une très belle librairie que j'ai adoptée après de nombreuses recherches. C'est facile à utiliser et cela m'a permis de mettre en pratique les idées que j'avais. Voici ce sur quoi je travaille actuellement. Il s'agit d'une animation qui vous permet d'apprendre à lire avec un pied à coulisse. Avec GSAP je peux positionner avec un effet de facilité ou récupérer la position du vernier ce qui me permet de faire les calculs pour vérifier l'entrée de l'élève (pas dans le codepen). Très pratique également, la facilité avec laquelle je peux gérer le zoom sur le vernier quelle que soit sa position.

See the Pen XWdNREP by jmbaret (@jmbaret) on CodePen

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...