Jump to content
GreenSock

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

timeline not detecting initial borderColor

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

Hello :)

 

I'm facing a very strange issue.

 

I am tweening the borderColor of a div, say from grey to red.. At the beginning of the tween, the border-color snaps to transparent and then animates to red from transparent.

 

It's like the timeline can't detect the initial border-color and it assumes it's transparent, and animates it from there. 

 

the initial bordercolor is injected as a <style> tag into the dom using jquery .html()..

 

I tried adding a style="border-color: grey;" on the div.. and then the tween worked! It could read the style from the div style attribute but not from the <style> tag.

 

The really strange thing is that exact same setup exists for other properties, eg background-color and i'm not facing any issues with them.. It's also only an issue with a specific div, other divs tween border-color fine. background-color on the same div, in the same <style> tag, works!

 

I've also tried to replicate this in a jsfiddle with no luck. I've been going crazy over here trying to debug this.

 

I was wondering if you have any ideas why this is happening?

Link to comment
Share on other sites

hello ... have you looked at the CSSRule Plugin?

http://api.greensock.com/js/com/greensock/plugins/CSSRulePlugin.html

var rule = CSSRulePlugin.getRule(".myClass"); //get the rule
TweenMax.to(rule, 3, {cssRule:{borderColor:"#0000FF"}});

you will need TweenMax since it includes CSSPlugin and CSSRulePlugin

 

are you running the code after you have inserted the style tag into the DOM?

 

also if you provide the link to your jsfiddle we can better help you, so we can see how your code is and the syntax your using.. thx..

Link to comment
Share on other sites

Major breakthrough :P

 

turns out this is firefox only!

 

I've simplified the jsfiddle to as much as I could and the issue still exists! check it out (in firefox 24.0) http://jsfiddle.net/9eHVQ/1/

 

 

btw your cssrule plugin looks amazing, wow i didn't know you could do that!

Link to comment
Share on other sites

try this syntax instead of borderColor:

 t.add(TweenMax.to($("#p-13-box-102 .inner-rec"), 1, { 
                  css:{
                      'borderTopColor': '#4c4c4c',
                      'borderRightColor': '#4c4c4c',
                      'borderBottomColor': '#4c4c4c',
                      'borderLeftColor': '#4c4c4c'
                   }
 } ), 1);

try this:

 

http://jsfiddle.net/9eHVQ/21/

 

this is not a TimelineMax issue, but more of a firefox browser bug.. sometimes some browsers, have issues with animating shorthand properties. Even with jQuery this is an issue with animating borderColor.. so in this case its best to animate the individual border color properties: borderTopColor, borderRightColor, borderBottomColor, borderLeftColor ... instead of borderColor

 

Its not related to the issue.. but I also noticed in your jsfiddle you had the external link for TweenMax.. so its also best to use TweenMax instead of TweenLIte in your syntax .. and you could use the CSS object for a slight speed boost

 

Oh and by the way you can thank Jack and Carl for this great Animation Platform.. they are the ones who make it so awesome!

 

hope this helps :)

  • Like 2
Link to comment
Share on other sites

Once again thanks for your help :)

 

hopefully firefox will solve this problem soon!

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