Jump to content
Search Community

Global Var not being Passed to local onComplete - onStart etc.

jh-thank-you 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

GreenSock Community,

 

I hope all is well.

 

The ISSUE - Global Var not being Passed to local onComplete - onStart etc.

 

Has anyone else experience this issue? Or is it something I am doing wrong? See below.

 

It's not a GSAP issue, as far as I can tell... I created a simplified Codepen using just jQuery for testing. Here are the links:

 

Codepen with GSAP - https://codepen.io/jh-thank-you/pen/pedXxO

Codepen without GSAP - 

See the Pen QpaWbg by jh-thank-you (@jh-thank-you) on CodePen

 

Snippet from my Stack Overflow post:

 

Here is the breakdown:

  • Correct password submission only works on first run through. UPDATE NOW WORKS
  • Cancel button only works only works on first run through. UPDATE NOW WORKS
  • Open password overlay whenever the box is clicked (this works).
  • Wrong password submission message continually loops (this works).

UPDATE - Fixed by replacing lockedModal.remove(); with $(".locked-modal").remove(); - I'm not sure why the original version did not work since the var was created on a global level.

 

 

Thanks for any help/advice.

See the Pen pedXxO by jh-thank-you (@jh-thank-you) on CodePen

Link to comment
Share on other sites

Hi,

 

With all the updates listed I'm not sure if you still need help.

I tried the demo and all the interactions seemed to work fine even after replacing line 37 with 

lockedModal.remove();

as instructed in the comments.

 

I'll assume you got it all working unless we hear more. Nice job.

Link to comment
Share on other sites

Carl,

 

Thanks for the speedy reply.

 

Strange... I was banging my head into a wall over this for days... 

 

The GSAP version now works with the var or not... the only other thing I changed was wrapping the color change in a setTimeout vs a 

promise().done().queue(function() {...

    - not sure why it's working to be honest... this is the way my code was structured from the start and the reason why I started to strip things down to find the problem.

 

Just tested again... The non-GSAP version if put the var in place, it will only cycle through once. I know this is not a GSAP problem but could you tell me why? I 'm learning as I go... I want to understand what my mistake is.

 

Also, I wanted to compliment your teammates (Blake and Dipscom) they have helped/taught me a lot over the last several months. I owe them and this forum/articles a lot of thanks.

 

 

I really appreciate the help, mentor, mentality, that seems to be a core tenent of the GreenSock team!

Link to comment
Share on other sites

Very glad to hear you are appreciating the helpful, friendly vibe we all try hard to maintain. We were all beginners once.

 

Unfortunately, I really don't know why the global var was not being accessed properly other than "some sort of scope issue" which is really just a guess.

This stuff can get tricky pretty quick and take time to track down. Not my strong suit.

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