Jump to content
Search Community

count absolute position of wrapped element

one2gov test
Moderator Tag

Go to solution Solved by one2gov,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I am trying to make element follow coordinates of animated element in animated div wrap. The element i am trying to place is a rectangle, and coordinates  I am trying to take  from is blue ball. The blue ball has relative coordinates inside his wrapper. And wrapper div doesn't give me his wrapper._gsTransform.x. How else can I count absolute position of wrapped element?

 

TweenMax.to(box2, 15, {x :550, y: 550,onUpdate:function(){
    TweenMax.set(box, {x:ball._gsTransform.x+231, y:ball._gsTransform.y-232})}});

See the Pen ?editors=0110 by one2gov (@one2gov) on CodePen

Link to comment
Share on other sites

  • Solution

Actually there is no problem in getting ._gsTransform.x for parent div, just should set variables right 

var border = document.getElementById("border") 

instead of 

var border = document.querySelectorAll(".border");

and

<div id="border">

instead of 

<div class="border">

The other problem is that i am careless, but i think i just have to consult with my developers about it..

  • Like 1
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...