Skip to content

Commit

Permalink
Tweak parameter order
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Apr 21, 2015
1 parent e50c604 commit 953e770
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
* setDragImage and IE
* helpers for test context
* make sure we don't screw server rendering (NoopBackend?)
* early invariants for common mistakes (e.g. missing context?)
* early invariants for common mistakes (e.g. missing context, missing methods?)
* fix hot reloading
* what do we do about DragImagePreloader?
* should we allow gif drag previews? see: safari
Expand Down
4 changes: 2 additions & 2 deletions examples/_drag-around-custom/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ const styles = {
};

const BoxTarget = {
drop(props, monitor, boxTargetId, component) {
drop(props, monitor, component) {
const delta = monitor.getDifferenceFromInitialOffset();
const item = monitor.getItem();

let left = Math.round(item.left + delta.x);
let top = Math.round(item.top + delta.y);
if (component.props.snapToGrid) {
if (props.snapToGrid) {
[left, top] = snapToGrid(left, top);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/_drag-around-naive/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const styles = {
};

const BoxTarget = {
drop(props, monitor, dropTargetId, component) {
drop(props, monitor, component) {
const item = monitor.getItem();
const delta = monitor.getDifferenceFromInitialOffset();
const left = Math.round(item.left + delta.x);
Expand Down
24 changes: 13 additions & 11 deletions src/ComponentDragSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,33 @@ export default class ComponentDragSource extends DragSource {
return true;
}

canDrag(...args) {
canDrag(monitor, id) {
if (this.spec.canDrag) {
return this.spec.canDrag.call(null, this.props, ...args);
return this.spec.canDrag.call(null, this.props, monitor);
} else {
return super.canDrag(...args);
return super.canDrag(monitor, id);
}
}

isDragging(...args) {
isDragging(monitor, id) {
if (this.spec.isDragging) {
return this.spec.isDragging.call(null, this.props, ...args);
return this.spec.isDragging.call(null, this.props, monitor);
} else {
return super.isDragging(...args);
return super.isDragging(monitor, id);
}
}

beginDrag(...args) {
return this.spec.beginDrag.call(null, this.props, ...args, this.getComponentRef());
beginDrag(monitor, id) {
const component = this.getComponentRef();
return this.spec.beginDrag.call(null, this.props, monitor, component, id);
}

endDrag(...args) {
endDrag(monitor, id) {
if (this.spec.endDrag) {
return this.spec.endDrag.call(null, this.props, ...args, this.getComponentRef());
const component = this.getComponentRef();
return this.spec.endDrag.call(null, this.props, monitor, component, id);
} else {
return super.endDrag(...args);
return super.endDrag(monitor, id);
}
}
}
20 changes: 11 additions & 9 deletions src/ComponentDropTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,29 @@ export default class ComponentDropTarget extends DropTarget {
return true;
}

canDrop(...args) {
canDrop(monitor, id) {
if (this.spec.canDrop) {
return this.spec.canDrop.call(null, this.props, ...args);
return this.spec.canDrop.call(null, this.props, monitor);
} else {
return super.canDrop(...args);
return super.canDrop(monitor, id);
}
}

hover(...args) {
hover(monitor, id) {
if (this.spec.hover) {
return this.spec.hover.call(null, this.props, ...args, this.getComponentRef());
const component = this.getComponentRef();
return this.spec.hover.call(null, this.props, monitor, component, id);
} else {
return super.hover(...args);
return super.hover(monitor, id);
}
}

drop(...args) {
drop(monitor, id) {
if (this.spec.drop) {
return this.spec.drop.call(null, this.props, ...args, this.getComponentRef());
const component = this.getComponentRef();
return this.spec.drop.call(null, this.props, monitor, component, id);
} else {
return super.drop(...args);
return super.drop(monitor, id);
}
}
}

0 comments on commit 953e770

Please sign in to comment.