Inspired by its conceptual simplicity, Andrea Giammarchi ( cough, the newest Ajaxian, cough ) has revisited an old ActionScript 1.0 Image effect making it lightweight, 1.2Kb minified and gzipped, and portable, thanks to its cross-browser nature and zero libraries dependencies. Last but not least, it’s 100% JavaScript, and without canvas.

The theory is simple: expanding a div with an image as background, and moving a stretched image in the opposite direction, it is possible to adjust some pixel in order to find a match point between the last part of the expanded background and the moved image.

The practice is even more simple: a Liquid function call with a configuration object.

< View plain text > javascript

var fx = Liquid({ // image src, every supported format src:"myimage.png", // element to use as Liquid container target: document.getElementById("fx") // or $("#fx")[0] for some guy, // optional direction, left by default // accepted: left, right, bottom, top direction: "left", // optional scale factor, 2000% by default // it is how much the image should be stretched scale: 2000, // optional speed, 1 to whatever, by default 10 speed: 10, // optional callback, will be executed at the end callback:function(){alert("it's Liquid!")}, // optional onload to perform some operation // after the image has been loaded onload:function(){/*FX not started yet*/}, // optional reverse property // performed only over a precedent liquid FX reverse:true }); // fx variable will have two methods // fx.pause() // to stop the animation // fx.play() // to re-enable it after a pause // these two effects are available only // during animation time, removed // before optional callback call

Being this effect based on just 2 DOM nodes, even mobile devices such Android and iPhone can show it with a reasonable rendering time.

Here you can find the source code while to give it a try you have Demo 1, with Firefox logo, and Demo 2 , with VAIO one, thanks to its smooth lines specially suited for this effect.