API Docs for:
Show:

event-drag Module

Provides subscribable drag events from Node or NodeLists. Subscribing to any of the events causes the node to be plugged with Y.Plugin.Drag. The config object passed can be used to set Drag instance attributes or add additional Plugins to the Drag instance such as Y.Plugin.DDProxy.

Config properties are formatted and tested for a corresponding Y.Plugin.* as 'somePlugin' => Y.Plugin.DDSomePlugin if the property name doesn't already start with "DD". So { proxy: true } and { DDProxy: true } are functionally equivalent. Both add Y.Plugin.DDProxy to the Drag instance.

node.on('drag:start', fn, { proxy: true, data: 123 });

This adds Y.Plugin.DDProxy to the Drag instance and also set's the Drag instance's data attribute.

Passing any value will result in the Plugin being added, but if you pass an object literal as the value, it will be sent to the Plugin's constructor.

node.on('drag:end', fn, {
    constrained: { constrain2node: '#container' }
});

This adds Y.Plugin.DDConstrained to the Drag instance using the specified configuration.

A custom detach handle is returned, whose detach method unplugs the Y.Plugin.Drag from the node(s).

Supported events are:

  • drag or drag:drag
  • drag:start
  • drag:end
  • drag:mouseDown
  • drag:afterMouseDown
  • drag:removeHandle
  • drag:addHandle
  • drag:removeInvalid
  • drag:addInvalid
  • drag:align

Additionally, the default callback context is overridden to the subscribing Node unless otherwise specified during the subscription. So "this" in the callback will refer to the node. On the event object passed to subscribers, e.currentTarget is also the Node regardless of context override. The Drag instance is available from the Node as node.dd.

This module provides the following classes: