Thursday, May 27th, 2010
towel.js: momentum drag, simple code
<>p>
Scato Eggen, in honor of Towel Day in the Netherlands, has released an open source framework called towel.js.
towel.js is an extension for Mootools, designed to make event-based code easier to write and even more important: easier to read.
At the hart of towel.js is a modular helper system called towel, including two helpers called UI and FX. These helpers produce objects that can be linked together: one object detects whether the mouse button is pressed, the other one changes style attributes. By linking these objects together a whole range of effects can be created and added to a page.
To create a simple momentum effect you only have to wire up code such as this:
-
-
$ready().add(function() {
-
var dragable = $('example-skid-dragable');
-
-
var down = $towel(dragable).ui.down();
-
var follow = $towel(dragable).fx.follow();
-
var skid = $towel(dragable).phys.skid();
-
-
down.add(follow);
-
down.not().add(skid);
-
});
-
Related Content:











Leave a comment