Jump to content
Search Community

Animation doesn't seem to work

_d3CipH3R_ 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

hmm, the link you provided works fine.

Are you saying that it's just your version that doesn't work?

 

Please read / watch this : http://forums.greensock.com/topic/9002-read-this-first-how-to-create-a-codepen-demo/

 

To see how to fork and/or create a CodePen that loads the GSAP file TweenMax.min.js

 

Also, by clicking the "share" button on a CodePen you download a local zip.

 

My guess is that you are not doing that properly, but its hard to tell without seeing an example.

Link to comment
Share on other sites

in your version it appears you were editing some comments and left some extra text in on line 16. Shown below in red

 

masterTimeline.add(box1Timeline) of 0

 

Thanks, I noticed that when comparing my code.

 

Another thing which I am not familiar with is the following code on:

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

 

I am aware that this is method chaining.

I've tried placing it within the <head> but it doesn't work.

It only works when I place the script after the HTML code. Why is this so?

Link to comment
Share on other sites

If you place executable code in the head, it will run before the body (and your elements) have loaded, so will run, but won't find any #box elements to animate, so will do nothing.

 

Either place the code in a script tag at the end of your page, after your elements, or use an onLoad handler, most commonly done these days using jQuery:

$(function(){

// your code that will run when the page has loaded

});

You can place this code before your elements if you need to, as it will be run after the page has loaded. (This is JavaScript learning, not GreenSock learning)

 

Do remember to load jQuery (using a script tag, usually in the head) before you reference $ (jQuery) !

  • Like 2
Link to comment
Share on other sites

If you place executable code in the head, it will run before the body (and your elements) have loaded, so will run, but won't find any #box elements to animate, so will do nothing.

 

Either place the code in a script tag at the end of your page, after your elements, or use an onLoad handler, most commonly done these days using jQuery:

$(function(){

// your code that will run when the page has loaded

});

You can place this code before your elements if you need to, as it will be run after the page has loaded. (This is JavaScript learning, not GreenSock learning)

 

Do remember to load jQuery (using a script tag, usually in the head) before you reference $ (jQuery) !

 

Adding the jQuery ready/Javascripts onLoad event completely skipped my mind. I'm not to sure how I missed that out. Fundamentally, I had forgotten to call the code using some kind of event handler, which is basically like holding your cup under a closed tap and trying to figure out why the water isn't flowing. I pretty much feel like a complete idiot right now :ph34r:.

 

Thanks for pointing that out.

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