milo.registry.facets.get('Drag')
Facet for components that can be dragged
Drag facet supports the following configuration parameters:
If function is specified in any parameter it will be called with the component as the context
var Drag = _.createSubclass(ComponentFacet, 'Drag');
_.extendProto(Drag, {
init: Drag$init,
start: Drag$start,
setHandle: Drag$setHandle
});
facetsRegistry.add(Drag);
module.exports = Drag;
function Drag$init() {
ComponentFacet.prototype.init.apply(this, arguments);
this._createMessageSourceWithAPI(DOMEventsSource);
this._dragData = {};
var dataTypeInfo = this.config._dataTypeInfo || '';
this._dataTypeInfo = typeof dataTypeInfo == 'function'
? dataTypeInfo
: function() { return dataTypeInfo; };
}
Option name | Type | Description |
---|---|---|
handleEl | Element |
Drag facet instance method
Sets the drag handle element of component. This element has to be dragged for the component to be dragged.
function Drag$setHandle(handleEl) {
if (! this.owner.el.contains(handleEl))
return logger.warn('drag handle should be inside element to be dragged');
this._dragHandle = handleEl;
}
function Drag$start() {
ComponentFacet.prototype.start.apply(this, arguments);
_addDragAttribute.call(this);
_createDragImage.call(this);
_toggleDragCls.call(this, false);
this.onMessages({
'mousedown': onMouseDown,
'mouseenter mouseleave mousemove': onMouseMovement,
'dragstart': onDragStart,
'drag': onDragging,
'dragend': onDragEnd
});
this.owner.onMessages({
'getstatestarted': _removeDragAttribute,
'getstatecompleted': _addDragAttribute
});
}