Making window widgets push other widgets around on a screen

Launching off our foundation from the previous recipe, we now get ready to have window widgets magically switch places. This will act like a game of musical chairs where when one widget moves into the place of a second, the second takes the place of the first. And unlike musical chairs, no widget loses and has to sit down until the next round.

How to do it...

The structure of the Drag.Move() object is the same. Added in this recipe is the functionality of the onEnter and onLeave events. Note how the hitters now have a class added upon entering and that class removed upon leaving to create a highlight effect. This tells the user they have dragged an item to a hittable zone.

$$('.widget').each(function(el) ...

Get MooTools 1.3 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.