animatedClassName: Animated Class-name
This little script replaces the effect you expect from an anim-gif and cycles class-names instead. Animation frames can be re-used more creatively and other stylesheet effects can be added.
Cycling Background-positions
The first example cycles through 4 numbered class-names, each changing the background image into a new animation frame.
All the animation frames are stored in one big image containing all steps. This should eliminate any issues with caching.
Cycling Layered Effects
The example below cycles through a dozen class-names, changing the opacity of a layer covering a static background.
Since fading is very browser-specific, this example might not work consistently.
Animated Menu Items
The next example is an animated menu bar. The background shifts when the mouse is moved over the menu items, but the animation doesn't loop.
Triggered Animations
The most complex involves clicking the following buttons to trigger different animations in a single target element.
- Lorem Ipsum
- Dolor Sit Amet
- Molesti
A Folding Menu
The animation effect can be combined with existing folding effects to create a more attractive result.
The menu opens and closes with :hover construction in the stylesheet, but the animation is added using this scripted behaviour.
Required Files
-
jQuery Addon Script: jquery.classbehaviours.animatedclassname.js
- Prerequisite Script: jquery.classbehaviours.js
- Example Markup: animatedClassName.html
- Example Stylesheet: animatedClassName.css
- Example Image: animatedClassName.png
Comments on this Article