Activate your free membership today | Log-in

Thursday, May 27th, 2010

towel.js: momentum drag, simple code

Category: JavaScript, Library, MooTools

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

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

Related Content:

Posted by Dion Almaer at 6:37 am
Comment here

+++--
3.8 rating from 5 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.