Jump to content
GreenSock

_d3CipH3R_

Animation doesn't seem to work

Recommended Posts

Hi All,

 

I've recently seen a javascript animation created on codepen:

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

 

Problem is it doesn't work. I've tried creating it on codepen and locally on my pc. But it doesn't work. Are these features still available?

Link to comment
Share on other sites

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

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

 

Sorry about that. Here's the link:

See the Pen nxHui by _d3CipH3R_ (@_d3CipH3R_) on CodePen

Link to comment
Share on other sites

I've downloaded it on my pc. It works well, Thanks. Wasn't aware about that "share" feature on codepen.

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

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

Ha, don't worry! That'll be the last time you forget that one, eh ;)

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