Skip to content

Commit

Permalink
Added dragImage config to drag facet
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoniangreen committed Mar 3, 2015
1 parent 5502bb0 commit dcc4fb9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "milo",
"version": "0.2.1",
"version": "0.2.2",
"homepage": "https://github.com/milojs/milo",
"authors": [
"MOL Technical <[email protected]>"
Expand Down
14 changes: 14 additions & 0 deletions lib/components/c_facets/Drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function Drag$setHandle(handleEl) {
function Drag$start() {
ComponentFacet.prototype.start.apply(this, arguments);
_addDragAttribute.call(this);
_createDragImage.call(this);

this.onMessages({
'mousedown': onMouseDown,
Expand Down Expand Up @@ -103,6 +104,15 @@ function _removeDragAttribute() {
}


function _createDragImage() {
var dragImage = this.config.dragImage;
if (dragImage) {
this._dragElement = new Image();
this._dragElement.src = dragImage.url;
}
}


function onMouseDown(eventType, event) {
this.__mouseDownTarget = event.target;
if (targetInDragHandle.call(this)) {
Expand All @@ -127,6 +137,10 @@ function onDragStart(eventType, event) {
return;
}

var dragImage = this.config.dragImage;
if (dragImage)
event.dataTransfer.setDragImage(this._dragElement, dragImage.x || 0, dragImage.y || 0);

var owner = this.owner;
var dt = new DragDrop(event);

Expand Down
2 changes: 1 addition & 1 deletion lib/milo.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ _.extend(milo, {
Component: require('./components/c_class'),
Command: require('./command'),
registry: require('./registry'),
milo_version: '0.2.1',
milo_version: '0.2.2',
createComponentClass: require('./util/create_component_class'),
destroy: destroy
});
Expand Down
21 changes: 17 additions & 4 deletions milo.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mol-milo",
"version": "0.2.1",
"version": "0.2.2",
"description": "Browser/nodejs reactive programming and data driven DOM manipulation with modular components.",
"keywords": [
"framework",
Expand Down

0 comments on commit dcc4fb9

Please sign in to comment.