From d9f635806667510003f09dce77a7a6ede4e94825 Mon Sep 17 00:00:00 2001 From: Scott Messinger Date: Wed, 22 Mar 2017 10:51:51 -0400 Subject: [PATCH 01/16] Reduce calls to .height() in slot.js --- addon/utils/slot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addon/utils/slot.js b/addon/utils/slot.js index 42a44e8e..19657346 100644 --- a/addon/utils/slot.js +++ b/addon/utils/slot.js @@ -153,7 +153,7 @@ export default class Slot { if (node.isDestroyed || node.isDestroying) { return; } - node.$().css({ width: '', height: '', transform: '' }).height(); + node.$().css({ width: '', height: '', transform: '' }); } /** @@ -164,7 +164,7 @@ export default class Slot { if (node.isDestroyed || node.isDestroying) { return; } - node.$().css('transition', 'none').height(); + node.$().css('transition', 'none'); } thaw() { @@ -172,7 +172,7 @@ export default class Slot { if (node.isDestroyed || node.isDestroying) { return; } - node.$().css('transition', '').height(); + node.$().css('transition', ''); } /** From 48f3a9e97a204643abff3e863a1917081cf5567d Mon Sep 17 00:00:00 2001 From: Scott Messinger Date: Thu, 11 May 2017 19:06:51 -0400 Subject: [PATCH 02/16] Fix deoptimization in v8 Line 134 caused a `Bad value context for arguments value`. I think babel transpiles the default argument in a way that doesn't help v8. The other idea is we're calling it with either 2 or 3 arguments which also might lead to the deopt. --- addon/utils/arrangement.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/utils/arrangement.js b/addon/utils/arrangement.js index 41573da9..2ee814cf 100644 --- a/addon/utils/arrangement.js +++ b/addon/utils/arrangement.js @@ -98,7 +98,7 @@ export default class Arrangement { } walkTree(func) { - walk(this.root, func); + walk(this.root, func, [0]); } walkPath(path, func) { @@ -131,7 +131,7 @@ export default class Arrangement { } } -function walk(slot, func, path = [0]) { +function walk(slot, func, path) { func(slot, path); slot.children.forEach((child, index) => { From cb2ccd920117c3adfaf01d0773d6ea5ab533dcdd Mon Sep 17 00:00:00 2001 From: Scott Messinger Date: Thu, 11 May 2017 19:26:58 -0400 Subject: [PATCH 03/16] Wrap onUpdate in requestAnimationFrame --- addon/utils/gesture.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/addon/utils/gesture.js b/addon/utils/gesture.js index cf85d27c..86541853 100644 --- a/addon/utils/gesture.js +++ b/addon/utils/gesture.js @@ -43,6 +43,7 @@ export default class Gesture { this.y = 0; this.listeners = []; this.isDestroyed = false; + this.isInAnimationFrame = false; } /** @@ -116,7 +117,7 @@ export default class Gesture { this.ox = event.pageX; this.oy = event.pageY; - this.on('mousemove', e => this.move(e)); + this.on('mousemove', e => debounce(this.move(e)); this.on('mouseup', () => this.stop()); } @@ -175,7 +176,14 @@ export default class Gesture { this.dx = this.x - this.ox; this.dy = this.y - this.oy; - this.onUpdate(this); + if (this.isInAnimationFrame === false){ + this.isInAnimationFrame = true; + window.requestAnimationFrame(() => { + this.onUpdate(this); + this.isInAnimationFrame = false; + }); + }; + } /** @@ -192,6 +200,7 @@ export default class Gesture { } } + /** @method waitingStop */ From 304110e328d2254ec23ccf66995b010cbffc6f28 Mon Sep 17 00:00:00 2001 From: Scott Messinger Date: Thu, 11 May 2017 19:37:00 -0400 Subject: [PATCH 04/16] Fix typo --- addon/utils/gesture.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/utils/gesture.js b/addon/utils/gesture.js index 86541853..f7acccf9 100644 --- a/addon/utils/gesture.js +++ b/addon/utils/gesture.js @@ -117,7 +117,7 @@ export default class Gesture { this.ox = event.pageX; this.oy = event.pageY; - this.on('mousemove', e => debounce(this.move(e)); + this.on('mousemove', e => this.move(e)); this.on('mouseup', () => this.stop()); } From f34b5529c264b149a3f8c547d255a11ae16ed09f Mon Sep 17 00:00:00 2001 From: Scott Messinger Date: Thu, 11 May 2017 19:49:48 -0400 Subject: [PATCH 05/16] Only update if onUpdate exists --- addon/utils/gesture.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/utils/gesture.js b/addon/utils/gesture.js index f7acccf9..59728ae3 100644 --- a/addon/utils/gesture.js +++ b/addon/utils/gesture.js @@ -179,7 +179,7 @@ export default class Gesture { if (this.isInAnimationFrame === false){ this.isInAnimationFrame = true; window.requestAnimationFrame(() => { - this.onUpdate(this); + if (this.onUpdate) this.onUpdate(this); this.isInAnimationFrame = false; }); }; From f2389a510994bef2feb660b627e138e81663dca6 Mon Sep 17 00:00:00 2001 From: Scott Messinger Date: Fri, 19 May 2017 15:34:48 -0400 Subject: [PATCH 06/16] Return if there is no document (e.g. in node) For running in Ember Fastboot --- addon/utils/transitionend.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addon/utils/transitionend.js b/addon/utils/transitionend.js index 60d21d60..ef6232ae 100644 --- a/addon/utils/transitionend.js +++ b/addon/utils/transitionend.js @@ -1,6 +1,9 @@ // Thanks to http://davidwalsh.name/css-animation-callback function whichTransitionEvent() { + if (typeof document === "undefined") { + return ""; + }; var t; var el = document.createElement('fake-element'); var transitions = { From 76ba9662fed82a2670518136fe1edf229c6bfd18 Mon Sep 17 00:00:00 2001 From: Scott Messinger Date: Tue, 13 Mar 2018 15:40:30 -0400 Subject: [PATCH 07/16] Fix error --- addon/utils/transition-duration.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/utils/transition-duration.js b/addon/utils/transition-duration.js index 30716c09..23112ec3 100644 --- a/addon/utils/transition-duration.js +++ b/addon/utils/transition-duration.js @@ -11,6 +11,7 @@ export default function transitionDuration(el) { $(el).height(); // force re-flow let value = $(el).css('transition'); + if (value === null || value === undefined) return 0; let match = value.match(/(all|transform) ([\d\.]+)([ms]*)/); if (match) { From 9669bb059a7cb9f5a57a5c34010532625921ef6f Mon Sep 17 00:00:00 2001 From: Scott Ames-Messinger Date: Wed, 30 May 2018 11:31:45 -0400 Subject: [PATCH 08/16] Update babel --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bd91f524..ce9bf66d 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "sortable" ], "dependencies": { - "ember-cli-babel": "^5.1.5", + "ember-cli-babel": "^6.6", "ember-cli-htmlbars": "^1.0.1", "ember-new-computed": "^1.0.2" }, From 0775afedde10cf4dd6856ac152b51b72845a3e07 Mon Sep 17 00:00:00 2001 From: Scott Ames-Messinger Date: Wed, 30 May 2018 17:20:50 -0400 Subject: [PATCH 09/16] Remove ember-new-computed --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index ce9bf66d..11058077 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,7 @@ ], "dependencies": { "ember-cli-babel": "^6.6", - "ember-cli-htmlbars": "^1.0.1", - "ember-new-computed": "^1.0.2" + "ember-cli-htmlbars": "^1.0.1" }, "ember-addon": { "configPath": "tests/dummy/config", From da8fa433ff985e4a7b326c906926c29a334ddaa7 Mon Sep 17 00:00:00 2001 From: Scott Ames-Messinger Date: Fri, 22 Jun 2018 18:25:22 -0400 Subject: [PATCH 10/16] Remove reference ember-new-computed --- addon/components/sortable-group.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/components/sortable-group.js b/addon/components/sortable-group.js index f3ad3de3..61032c9b 100644 --- a/addon/components/sortable-group.js +++ b/addon/components/sortable-group.js @@ -1,6 +1,6 @@ import Ember from 'ember'; import layout from '../templates/components/sortable-group'; -import computed from 'ember-new-computed'; +import { computed } from '@ember/object'; const { A, Component, get, set, run } = Ember; const a = A; const NO_MODEL = {}; From 840e0907314bd05394769215aa779f628b6d3c4a Mon Sep 17 00:00:00 2001 From: Scott Ames-Messinger Date: Fri, 22 Jun 2018 18:26:14 -0400 Subject: [PATCH 11/16] Remove reference to ember-new-computed --- addon/mixins/sortable-item.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/mixins/sortable-item.js b/addon/mixins/sortable-item.js index 4b6e1fe7..cef80be2 100644 --- a/addon/mixins/sortable-item.js +++ b/addon/mixins/sortable-item.js @@ -1,5 +1,5 @@ import Ember from 'ember'; -import computed from 'ember-new-computed'; +import { computed } from '@ember/object'; const { Mixin, $, run } = Ember; const { Promise } = Ember.RSVP; From e5221a7d71d4ec6739d758a610b63c857e4a9dc0 Mon Sep 17 00:00:00 2001 From: Scott Ames-Messinger Date: Fri, 9 Nov 2018 11:14:33 -0500 Subject: [PATCH 12/16] Upgrade ember-cli-babel --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 11058077..430b0c62 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "sortable" ], "dependencies": { - "ember-cli-babel": "^6.6", + "ember-cli-babel": "^7.1", "ember-cli-htmlbars": "^1.0.1" }, "ember-addon": { From 5d0c52005bb3e0aeb2e3da71fdef17ba70ca8fe5 Mon Sep 17 00:00:00 2001 From: Scott Ames-Messinger Date: Fri, 9 Nov 2018 11:45:10 -0500 Subject: [PATCH 13/16] downgrade ember-cli-babel --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 430b0c62..90815ca9 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "sortable" ], "dependencies": { - "ember-cli-babel": "^7.1", + "ember-cli-babel": "^6.6.0", "ember-cli-htmlbars": "^1.0.1" }, "ember-addon": { From 6a61bd6dc9a107a234308902bcecc0c656bc2578 Mon Sep 17 00:00:00 2001 From: Scott Ames-Messinger Date: Thu, 22 Aug 2019 10:14:57 -0400 Subject: [PATCH 14/16] Check for element before reading or writing the css --- addon/mixins/sortable-item.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/addon/mixins/sortable-item.js b/addon/mixins/sortable-item.js index cef80be2..993338d4 100644 --- a/addon/mixins/sortable-item.js +++ b/addon/mixins/sortable-item.js @@ -103,6 +103,7 @@ export default Mixin.create({ */ isAnimated: computed(function() { let el = this.$(); + if (el === undefined || el === null) return false; let property = el.css('transition-property'); return /all|transform/.test(property); @@ -115,6 +116,7 @@ export default Mixin.create({ */ transitionDuration: computed(function() { let el = this.$(); + if (el === undefined || el === null) return 0; let rule = el.css('transition-duration'); let match = rule.match(/([\d\.]+)([ms]*)/); @@ -140,7 +142,9 @@ export default Mixin.create({ x: computed({ get() { if (this._x === undefined) { - let marginLeft = parseFloat(this.$().css('margin-left')); + let el = this.$() + if (el === undefined || el === null) return 0; + let marginLeft = parseFloat(el.css('margin-left')); this._x = this.element.scrollLeft + this.element.offsetLeft - marginLeft; } @@ -182,6 +186,7 @@ export default Mixin.create({ */ width: computed(function() { let el = this.$(); + if (el === undefined || el === null) return 0; let width = el.outerWidth(true); width += getBorderSpacing(el).horizontal; @@ -196,6 +201,7 @@ export default Mixin.create({ */ height: computed(function() { let el = this.$(); + if (el === undefined || el === null) return 0; let height = el.outerHeight(); let marginBottom = parseFloat(el.css('margin-bottom')); @@ -401,7 +407,9 @@ export default Mixin.create({ if (groupDirection === 'x') { let x = this.get('x'); - let dx = x - this.element.offsetLeft + parseFloat(this.$().css('margin-left')); + let el = this.$() + if (el === undefined || el === null) return 0; + let dx = x - this.element.offsetLeft + parseFloat(el.css('margin-left')); this.$().css({ transform: `translateX(${dx}px)` @@ -410,8 +418,9 @@ export default Mixin.create({ if (groupDirection === 'y') { let y = this.get('y'); let dy = y - this.element.offsetTop; - - this.$().css({ + let el = this.$() + if (el === undefined || el === null) return 0; + el.css({ transform: `translateY(${dy}px)` }); } @@ -539,7 +548,7 @@ function getX(event) { */ function getBorderSpacing(el) { el = $(el); - + if (el === undefined || el === null) return 0; let css = el.css('border-spacing'); // '0px 0px' let [horizontal, vertical] = css.split(' '); From 65743e6189b4a24133b181d450b31363e5b3cf92 Mon Sep 17 00:00:00 2001 From: Scott Ames-Messinger Date: Thu, 22 Aug 2019 10:28:15 -0400 Subject: [PATCH 15/16] Abort if it's destroyed or destroying --- addon/mixins/sortable-item.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/mixins/sortable-item.js b/addon/mixins/sortable-item.js index 993338d4..4662848e 100644 --- a/addon/mixins/sortable-item.js +++ b/addon/mixins/sortable-item.js @@ -494,6 +494,7 @@ export default Mixin.create({ @private */ _complete() { + if (this.isDestroyed || this.isDestroying) return; this.sendAction('onDragStop', this.get('model')); this.set('isDropping', false); this.set('wasDropped', true); From c5dad12087d9f29762dc9608abf6d81591e2ce32 Mon Sep 17 00:00:00 2001 From: Matthew Weidner <17693586+mweidner037@users.noreply.github.com> Date: Thu, 24 Apr 2025 11:36:50 -0500 Subject: [PATCH 16/16] Apply fix for newer Firefox from https://github.com/adopted-ember-addons/ember-sortable/pull/606 --- addon/mixins/sortable-item.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/mixins/sortable-item.js b/addon/mixins/sortable-item.js index 4662848e..bc5eb1ef 100644 --- a/addon/mixins/sortable-item.js +++ b/addon/mixins/sortable-item.js @@ -551,7 +551,8 @@ function getBorderSpacing(el) { el = $(el); if (el === undefined || el === null) return 0; let css = el.css('border-spacing'); // '0px 0px' - let [horizontal, vertical] = css.split(' '); + const [horizontal, initialVertical] = css.split(" "); + const vertical = initialVertical === undefined ? horizontal : initialVertical; return { horizontal: parseFloat(horizontal),