Drag. Multi.js

Mootools Drag.Base class extension which adds support for modifying multiple css properties of different elements simultaneously.  Contains Drag.Multi.

License

MIT-style license.

Copyright

copyright © 2007 Yevgen Gorshkov

Summary
Drag. Multi.jsMootools Drag.Base class extension which adds support for modifying multiple css properties of different elements simultaneously.
Drag. MultiModify multiple css properties of multiple elements based on the position of the mouse.
Properties
addAdd element to modify its css properties based on the position of the mouse.
removeStop all transformations for the passed element.
detachStop transformations described by the argument.

Drag. Multi

Modify multiple css properties of multiple elements based on the position of the mouse.

Arguments

optionsThe options object.

Options

handlerequired, the $(element) to act as the handle for the draggable elements.
onStartoptional, function to execute when the user starts to drag (on mousedown);
onBeforeStartoptional, function to execute when the user starts to drag (on mousedown) but before initial properties values are calculated;
onCompleteoptional, function to execute when the user completes the drag.
onSnapoptional, function to execute when the distance between staring point and current mouse position exceeds snap option value
onDragoptional, function to execute at every step of the drag
snapoptional, the distance you have to drag before the element starts to respond to the drag. defaults to false

Example

var drag = new Drag.Multi({
handle: $('handle'),

onBeforeStart: function(){
var size = $(document.body).getSize().scrollSize;
this.shade = new Element('div', {
styles: {
position: 'absolute',
top: 0,
left: 0,
width: size.x,
height: size.y,
cursor: 'move',
'z-index': 100
}
}).inject(document.body);
},

onStart: function(){
$each(arguments, function(el){
el.addClass('ondrag');
});
},

onComplete: function(){
this.shade.remove();
$each(arguments, function(el){
el.removeClass('ondrag');
});
}

});

drag.add($('object'), {
'x': {
limit: [0,440],
style: 'margin-left'
},
'y': {
limit: [0, 198],
style: 'margin-top'
}
});
Summary
Properties
addAdd element to modify its css properties based on the position of the mouse.
removeStop all transformations for the passed element.
detachStop transformations described by the argument.

Properties

add

Add element to modify its css properties based on the position of the mouse.

Returns

Bind object.

Arguments

elthe $(element) to apply the transformations to.
optionsThe options object.
bindThe Bind object (see <Bind> below).

Options

xoptional, the Modifier object (see below).
yoptional, the Modifier object (see below).

Modifier

stylerequired, the style you want to modify when the mouse moves in an horizontal direction.
directionoptional, 1 corresponds to positive direction (style change according to move movement), -1 inverse direction. defaults to 1.
limitoptional, array with start and end limit for style value.
gridoptional, distance in px for snap-to-grid dragging.
fnoptional, object with two properties - direct and inverse functions
{
step: function(start, current, direction){ return direction * current - start; },
inverse: function(start, current, direction){ return (start + current) / direction; }
}

Bind

xoptional, Bind object; change $(element) modifier value according to changes in Bind object.
yoptional, Bind object; change $(element) modifier value according to changes in Bind object.

remove

Stop all transformations for the passed element.

Arguments

elthe $(element) to stop transformations for.

detach

Stop transformations described by the argument.

Arguments

modBind object returned by Drag.Multi::add
Modify multiple css properties of multiple elements based on the position of the mouse.
Add element to modify its css properties based on the position of the mouse.