Jump to content
Search Community

Uncaught Cannot tween a null target

dada78 test
Moderator Tag

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

Hi guys,

 

2 things:

 

1_ I can't figure out why the console is throwing this error: "Uncaught Cannot tween a null target." after the dummy data has loaded.

Any insight on this?

 

2_ Also in the fadeOutUnselected function on line 38, on line 42 I am trying to animate the variable selectedId to position y:0. I tried placing it as a global variable to be accessible from other functions but I can't figure out how to rewrite it so that variable selectedId becomes available within my timeline functions?

 

Thanks for looking into this!

See the Pen b50de869b75b32e220956bb36052733b by dada78 (@dada78) on CodePen

Link to comment
Share on other sites

1) You're inserting a function call into a timeline on line 25 like this: 

.add(horizontalBar)

but your function signature expects 2 arguments:

function horizontalBar(bar, percentage) {
    var tl = new TimelineMax();
    tl.to(bar, 1, {width: percentage+"%"}) 
    return tl;
}

Thus "bar" is undefined when the function gets called, meaning you're creating a tween of a null object. 

 

2) I'm not entirely sure I understand your goal or why declaring the variable outside your function scope wasn't working for you, so I'll let someone else take a stab at helping you on this one. I'm out of time and almost falling asleep ;) 

 

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