Thursday, May 27th, 2010

towel.js: momentum drag, simple code

Category: JavaScript, Library, MooTools

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:

javascript

  1. $ready().add(function() {
  2.     var dragable = $('example-skid-dragable');
  3.  
  4.     var down = $towel(dragable).ui.down();
  5.     var follow = $towel(dragable).fx.follow();
  6.     var skid = $towel(dragable).phys.skid();
  7.  
  8.     down.add(follow);
  9.     down.not().add(skid);
  10. });

Posted by Dion Almaer at 6:37 am
Comment here

+++--
3.9 rating from 8 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.