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

get continues position (x,y) from moving SVG object #855

Open
bartatgithub opened this issue May 8, 2023 · 2 comments
Open

get continues position (x,y) from moving SVG object #855

bartatgithub opened this issue May 8, 2023 · 2 comments

Comments

@bartatgithub
Copy link

bartatgithub commented May 8, 2023

Is your feature request related to a problem? Please describe.
The problem is that I cannot find anywhere in the documentation how to obtain continuous position (x,y) of a moving object. And to further use this position (x,y) in another Javascript. So I assume this is not (yet) implemented in Anime.js.

Describe the solution you'd like
A way to continuously obtain the position (x,y) of a moving object and a way to use this in another Javascript.
For now to be used specifically in the SVG Motion path example of yours but would be useful in different projects using Anime.js.

Describe alternatives you've considered
Tried using basic Javascript to obtain the position of the animated div but doesn't work so far.

Thanks to help me out on this!

@manake
Copy link

manake commented Jun 7, 2023

Why basic JavaScript to obtain position doesn't work? It should work.

Please post a code example.

// jQuery:
let positionLeft = $('.box').css('left');

// Plain JavaScript:
let box = document.querySelector('.box').getBoundingClientRect();

You can also animate plain object with anime.js and in update() set CSS.

@bartatgithub
Copy link
Author

Hello

Sorry for late reply, meanwhile I had already obtained what I urgently needed with 'vector.js'.

Will definitely try your suggestion here one of these days.

Strange though that this should be done via a 'document.querySelector' on the element?
Shouldn't it be directly readable via a function that reads the position via your library?

Thanks!

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

No branches or pull requests

2 participants