Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
bobdobbs

Simple test failing without errors

Recommended Posts

I'm just getting started with gsap. I've created a simple script, but for some reason I can't get it to actually do anything. I'm getting zero results in both firefox and chrome on linux.

 

What am I doing wrong?

 

Here is the html source...

<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta charset="UTF-8" />
    <title>greensock test</title>
    <meta name="description" content="gsap test" />
    <link rel="stylesheet" type="text/css"  href="/css/test.css" />
    
    <script type="text/javascript" src="/js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="/js/TweenLite.min.js"></script>
    <script type="text/javascript" src="/js/gsap-test.js"></script>
    
  </head>
  
  <body id="">
    <div id="outer-wrapper">
      
      <header id="page-header">
      </header>  <!-- page-header ends -->
      
      <section id="main-content">
	<h1>GSAP Animation Library Test</h1>

        <section id="testing"> 
	  <p>Lets see what he can do with Tweenlite</p>
        </section>

      </section>  <!-- main-content ends -->
      
      <footer id="page-footer">
      </footer>  
      
    </div>  <!-- outer-wrapper ends -->
  </body>
</html>

And here is my js:

 $(document).ready(function() {

     $("p").click(function (){
	 
	 var $target = $(this) ;
	 
	 TweenLite.to(
	     $target , 1, {backgroundColor:"#000"} 
	 ) ;

	 console.log("clicked");

     })

     
 });

All the libraries load. Firebug returns no errors. When I click the <p> element, I get the console message, but nothing else.

 

Link to post
Share on other sites

Hi and welcome to the forums.
 
Mainly your problem is that you're trying to tween a css property without including the css plugin. To solve this you can either load the plugin or use TweenMax (which among other goodies includes the css plugin).

//Load the plugin as well as TweenLite 
<script type="text/javascript" src="/js/TweenLite.min.js"></script>
<script type="text/javascript" src="/js/CSSPlugin.min.js"></script>
//Load TweenMax
<script type="text/javascript" src="/js/TweenMax.min.js"></script>

And like that you're test should work fine.

 

Hope this helps,

Cheers,

Rodrigo.

Link to post
Share on other sites

Hi Rodrigo.

 

Thanks for the tip!

I'm now includeing the file CSSPlugin.

 

However, I still seem to have the same problem: no result, and now errors.

 

I edited my script to animate the width of the target element. That worked.

However, I still can't seem to animate the background colour.

Link to post
Share on other sites

Hi Bob Dobbs,

 

Welcome to the forums. Rodrigo is exactly right, you just have to load the CSSPlugin with TweenLite OR load TweenMax.

 

If you haven't been through the Jump Start, give it a look: http://www.greensock.com/jump-start-js/

 

You can download a bunch of helpful starter files. We recently added all the Jump Start examples to codepen to make it real easy to experiment with GSAP code:

http://codepen.io/collection/ifybJ

Link to post
Share on other sites

Hi Bob,

 

If you want, just upload a zip of your html, css and js. We'll take a look.

Link to post
Share on other sites

Ah! Problem solved!

 

I was animating the background colour from one value to the same value!

 

So, the animation was actually working. It just wasn't visible.

 

Doh!

Link to post
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.

×