Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dgavey authored Sep 4, 2020
2 parents ce1b192 + 2f29c0e commit 608e218
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "8"
- "10"

sudo: false
dist: trusty
Expand All @@ -18,6 +18,7 @@ env:
global:
# See https://git.io/vdao3 for details.
- JOBS=1

matrix:
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ export default Ember.ArrayController.extend({
post.save();
}
}
}
});
```

Expand Down
12 changes: 11 additions & 1 deletion addon/components/draggable-object-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,23 @@ export default Component.extend(Droppable, {
}
},

mouseEnter(e) {
handleMouseEnter(e) {
let mouseEnter = this.get('onMouseEnter');
if (mouseEnter) {
mouseEnter(e);
}
},

didInsertElement() {
this._super(...arguments);
this.element.addEventListener('mouseenter', this.handleMouseEnter);
},

willDestroyElement() {
this._super(...arguments);
this.element.removeEventListener('mouseenter', this.handleMouseEnter);
},

actions: {
acceptForDrop() {
let hashId = this.get('coordinator.clickedId');
Expand Down
4 changes: 2 additions & 2 deletions addon/components/draggable-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { set } from '@ember/object';
import { wrapper } from 'ember-drag-drop/utils/proxy-unproxy-objects';

export default Component.extend({
dragCoordinator: service(),
dragCoordinator: service('drag-coordinator'),
overrideClass: 'draggable-object',
classNameBindings: [':js-draggableObject','isDraggingObject:is-dragging-object:', 'overrideClass'],
attributeBindings: ['dragReady:draggable'],
Expand All @@ -26,7 +26,7 @@ export default Component.extend({
proxyContent: computed('content', function() {
return wrapper(this.get('content'));
}),


init() {
this._super(...arguments);
Expand Down
2 changes: 1 addition & 1 deletion addon/components/object-bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function removeOne(arr,obj) {
var l2 = arr.get('length');

if (l-1 !== l2) {
throw "bad length " + l + " " + l2;
throw new Error("bad length " + l + " " + l2);
}
}

Expand Down
2 changes: 1 addition & 1 deletion addon/components/sortable-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service';
import { A } from '@ember/array';

export default Component.extend( {
dragCoordinator: service(),
dragCoordinator: service('drag-coordinator'),
overrideClass: 'sortable-objects',
classNameBindings: ['overrideClass'],
enableSort: true,
Expand Down
19 changes: 15 additions & 4 deletions addon/services/drag-coordinator.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,37 @@ export default Service.extend({
const currentOffsetItem = this.get('currentOffsetItem');
const pos = this.relativeClientPosition(emberObject.element, event);
const hasSameSortingScope = this.get('currentDragItem.sortingScope') === emberObject.get('sortingScope');
let moveDirection = false;
let moveDirections = [];

if (!this.get('lastEvent')) {
this.set('lastEvent', event);
}

if (event.clientY < this.get('lastEvent').clientY) {
moveDirection = 'up';
moveDirections.push('up');
}

if (event.clientY > this.get('lastEvent').clientY) {
moveDirection = 'down';
moveDirections.push('down');
}

if (event.clientX < this.get('lastEvent').clientX) {
moveDirections.push('left');
}

if (event.clientX > this.get('lastEvent').clientX) {
moveDirections.push('right');
}

this.set('lastEvent', event);

if (!this.get('isMoving') && this.get('currentDragEvent')) {
if (event.target !== this.get('currentDragEvent').target && hasSameSortingScope) { //if not dragging over self
if (currentOffsetItem !== emberObject) {
if (pos.py > 0.33 && moveDirection === 'up' || pos.py > 0.33 && moveDirection === 'down') {
if (pos.py < 0.67 && moveDirections.indexOf('up') >= 0 ||
pos.py > 0.33 && moveDirections.indexOf('down') >= 0 ||
pos.px < 0.67 && moveDirections.indexOf('left') >= 0 ||
pos.px > 0.33 && moveDirections.indexOf('right') >= 0) {

this.moveElements(emberObject);
this.set('currentOffsetItem', emberObject);
Expand Down
2 changes: 1 addition & 1 deletion app/models/obj-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default EmberObject.extend({
getObj: function(key) {
var res = this.get('content')[key];
if (!res) {
throw "no obj for key "+key;
throw new Error("no obj for key "+key);
}
return res;
},
Expand Down
2 changes: 1 addition & 1 deletion test-support/helpers/drag-drop.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default } from 'ember-drag-drop/test-support/helpers/drag-drop';
export * from 'ember-drag-drop/test-support/helpers/drag-drop';
export * from 'ember-drag-drop/test-support/helpers/drag-drop';
2 changes: 1 addition & 1 deletion test-support/helpers/ember-drag-drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function drop($dragHandle, dropCssPath, dragEvent) {
let dropTarget = document.querySelector(dropCssPath);

if (dropTarget.length === 0) {
throw(`There are no drop targets by the given selector: '${dropCssPath}'`);
throw new Error(`There are no drop targets by the given selector: '${dropCssPath}'`);
}

run(() => {
Expand Down

0 comments on commit 608e218

Please sign in to comment.