Jump to content
Search Community

CSSPlugin - box-shadow

BarryS 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

Hello again,

 

Am I able to animate the box-shadow css property?

 

I had been using a seperate jQuery plugin to make a button glow when I wanted a user's eyes to be drawn to it.

 

Now I'm using the GSAP for all other animation I thought I'd ditch the other plugin, but I can't seem to recreate the glow.

 

Here are the methods I have tried so far:

 

Adding a class:

 

TweenMax.to(NextBtn, 1, {css:{className:"+=Glow"},repeat: -1, delay:2, yoyo:true, ease:Power2.easeOut});

 

Tweening the css property:

 

TweenMax.to(NextBtn, 1, {css:{boxShadow:"0px 0px 5px 2px #F00;"},repeat: -1, delay:2, yoyo:true, ease:Power2.easeOut});

 

Thanks in advance.

 

Barry

Link to comment
Share on other sites

Check out this http://jsfiddle.net/FmD2W/ it should be doing what you refer to.

 

A timeline is used to manage two class changes (adding and removing 'Glow'), however all the animation is done using CSS3 transitions. If transitions aren't supported the glow effect should simply toggle on and off.

 

If you keep a reference to the timeline, anytime you need to highlight the button you can just call

NextBtnHighlight.restart()

or

NextBtnHighlight.play(0)

 

I added a color change to the demo so there would be at least some highlight effect on non-CSS3 browsers.

 

Note: I pulled in the vendor prefixes from memory - you might want to double check these are the correct way to achieve the widest support for box-shadow and transition.

Link to comment
Share on other sites

Hi Jamie,

 

Thank you for your reply and your example. I changed the vendor prefixes a little in the jsFiddle so that the fade in effect worked in FF. The result is still not as smooth as i'd like but is a step in the right direction.

 

If you are insterested, I'm currently using this Shadow animation jQuery plugin available here:

 

http://www.bitstorm.org/jquery/shadow-animation/

 

Carl, I'll also give your solution a try too.

 

Thanks for your help,

 

Barry

Link to comment
Share on other sites

I got there in the end (I must be tired this morning as it took me ages!).

 

I knew I could repeat a timeline indefinitely like so:

var tl = new TimelineMax({repeat:-1});

But I hadnt realised until now that I could simply write tl.repeat(-1) within a function.

 

Now when I want to draw the users attention to the 'Next screen' button, I can simple call my function below which starts the timeline and repeats it.

 

function runHighlights(){

highlights.play();

highlights.repeat(-1);

};

 

I also hadnt known about insert and set as shown in your code below, so thanks for that.

 

highlights.insert(TweenLite.set(box1, {

css: { className: '+=glow' },

immediateRender: false

}), 1);

 

 

Cheers,

 

Barry

Link to comment
Share on other sites

  • 5 months later...

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