ember-sortable 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## v2.4.0 (2021-11-10)
|
|
2
|
+
|
|
3
|
+
#### :rocket: Enhancement
|
|
4
|
+
* [#445](https://github.com/adopted-ember-addons/ember-sortable/pull/445) Use direct imports from `@ember/runloop` ([@charlesfries](https://github.com/charlesfries))
|
|
5
|
+
|
|
6
|
+
#### Committers: 2
|
|
7
|
+
- Charles Fries ([@charlesfries](https://github.com/charlesfries))
|
|
8
|
+
- Faith Or ([@faith-or](https://github.com/faith-or))
|
|
9
|
+
|
|
1
10
|
* Merge pull request #430 from jacojoubert/refactor-disabled (364fc80)
|
|
2
11
|
* (51ea46f)
|
|
3
12
|
* Merge pull request #444 from snewcomer/sn/deprecate-components (b70d5cd)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A } from '@ember/array';
|
|
2
2
|
import Component from '@ember/component';
|
|
3
3
|
import { set, get, computed, defineProperty } from '@ember/object';
|
|
4
|
-
import {
|
|
4
|
+
import { next, schedule, scheduleOnce, later } from '@ember/runloop';
|
|
5
5
|
import layout from '../templates/components/sortable-group';
|
|
6
6
|
import {
|
|
7
7
|
isEnterKey,
|
|
@@ -183,7 +183,7 @@ export default Component.extend({
|
|
|
183
183
|
|
|
184
184
|
this.set('isRetainingFocus', true);
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
scheduleOnce('render', () => {
|
|
187
187
|
this.element.focus();
|
|
188
188
|
this.set('isRetainingFocus', false);
|
|
189
189
|
});
|
|
@@ -234,7 +234,7 @@ export default Component.extend({
|
|
|
234
234
|
}
|
|
235
235
|
this._announceAction(ANNOUNCEMENT_ACTION_TYPES.MOVE, delta);
|
|
236
236
|
// Guarantees that the before the UI is fully rendered before we move again.
|
|
237
|
-
|
|
237
|
+
scheduleOnce('render', () => {
|
|
238
238
|
this._move(sortedIndex, newSortedIndex);
|
|
239
239
|
this._updateHandleVisualIndicators(item, true);
|
|
240
240
|
|
|
@@ -411,16 +411,16 @@ export default Component.extend({
|
|
|
411
411
|
|
|
412
412
|
delete this._itemPosition;
|
|
413
413
|
|
|
414
|
-
|
|
414
|
+
schedule('render', () => {
|
|
415
415
|
items.invoke('freeze');
|
|
416
416
|
});
|
|
417
417
|
|
|
418
|
-
|
|
418
|
+
schedule('afterRender', () => {
|
|
419
419
|
items.invoke('reset');
|
|
420
420
|
});
|
|
421
421
|
|
|
422
|
-
|
|
423
|
-
|
|
422
|
+
next(() => {
|
|
423
|
+
schedule('render', () => {
|
|
424
424
|
items.invoke('thaw');
|
|
425
425
|
});
|
|
426
426
|
});
|
|
@@ -480,7 +480,7 @@ export default Component.extend({
|
|
|
480
480
|
this.confirmKeyboardSelection();
|
|
481
481
|
|
|
482
482
|
this.set('isRetainingFocus', true);
|
|
483
|
-
|
|
483
|
+
scheduleOnce('render', () => this._focusItem(itemElement));
|
|
484
484
|
} else if (isEscapeKey(event)) {
|
|
485
485
|
// cancel will reset the _selectedItem, so caching it here before we remove it.
|
|
486
486
|
const _selectedItemElement = this.get('_selectedItem.element');
|
|
@@ -488,7 +488,7 @@ export default Component.extend({
|
|
|
488
488
|
this.cancelKeyboardSelection();
|
|
489
489
|
|
|
490
490
|
this.set('isRetainingFocus', true);
|
|
491
|
-
|
|
491
|
+
scheduleOnce('render', () => {
|
|
492
492
|
const moves = this.get('moves');
|
|
493
493
|
if (moves && moves.length > 0) {
|
|
494
494
|
const sortedItems = this.get('sortedItems');
|
|
@@ -582,7 +582,7 @@ export default Component.extend({
|
|
|
582
582
|
announcer.textContent = message;
|
|
583
583
|
|
|
584
584
|
// Reset the message after the message is announced.
|
|
585
|
-
|
|
585
|
+
later(() => {
|
|
586
586
|
announcer.textContent = '';
|
|
587
587
|
}, 1000);
|
|
588
588
|
},
|
|
@@ -2,7 +2,7 @@ import { Promise, defer } from 'rsvp';
|
|
|
2
2
|
import Component from '@ember/component';
|
|
3
3
|
import { defineProperty } from '@ember/object';
|
|
4
4
|
import { or, readOnly } from '@ember/object/computed';
|
|
5
|
-
import { run, throttle } from '@ember/runloop';
|
|
5
|
+
import { run, throttle, bind, scheduleOnce, later } from '@ember/runloop';
|
|
6
6
|
import { DEBUG } from '@glimmer/env';
|
|
7
7
|
import scrollParent from '../system/scroll-parent';
|
|
8
8
|
import ScrollContainer from '../system/scroll-container';
|
|
@@ -297,7 +297,7 @@ export default Component.extend({
|
|
|
297
297
|
startEvent.preventDefault();
|
|
298
298
|
startEvent.stopPropagation();
|
|
299
299
|
|
|
300
|
-
this._prepareDragListener =
|
|
300
|
+
this._prepareDragListener = bind(this, this._prepareDrag, startEvent);
|
|
301
301
|
|
|
302
302
|
DRAG_ACTIONS.forEach(event => window.addEventListener(event, this._prepareDragListener));
|
|
303
303
|
|
|
@@ -507,7 +507,7 @@ export default Component.extend({
|
|
|
507
507
|
@private
|
|
508
508
|
*/
|
|
509
509
|
_scheduleApplyPosition() {
|
|
510
|
-
|
|
510
|
+
scheduleOnce('render', this, '_applyPosition');
|
|
511
511
|
},
|
|
512
512
|
|
|
513
513
|
/**
|
|
@@ -617,7 +617,7 @@ export default Component.extend({
|
|
|
617
617
|
});
|
|
618
618
|
} else {
|
|
619
619
|
const duration = this.get('isAnimated') ? this.get('transitionDuration') : 200;
|
|
620
|
-
transitionPromise = new Promise((resolve) =>
|
|
620
|
+
transitionPromise = new Promise((resolve) => later(resolve, duration));
|
|
621
621
|
}
|
|
622
622
|
|
|
623
623
|
if (DEBUG) {
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "../utils/keyboard";
|
|
12
12
|
import {ANNOUNCEMENT_ACTION_TYPES} from "../utils/constant";
|
|
13
13
|
import { defaultA11yAnnouncementConfig } from "../utils/defaults";
|
|
14
|
-
import {
|
|
14
|
+
import { next, schedule, scheduleOnce, later } from '@ember/runloop';
|
|
15
15
|
import {inject as service} from '@ember/service';
|
|
16
16
|
|
|
17
17
|
const NO_MODEL = {};
|
|
@@ -140,7 +140,7 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
140
140
|
|
|
141
141
|
this.isRetainingFocus = true;
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
scheduleOnce('render', () => {
|
|
144
144
|
this.element.focus();
|
|
145
145
|
this.isRetainingFocus = false;
|
|
146
146
|
});
|
|
@@ -221,7 +221,7 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
221
221
|
this.confirmKeyboardSelection();
|
|
222
222
|
|
|
223
223
|
this.isRetainingFocus = true;
|
|
224
|
-
|
|
224
|
+
scheduleOnce('render', () => this._focusItem(itemElement));
|
|
225
225
|
} else if (isEscapeKey(event)) {
|
|
226
226
|
// cancel will reset the selectedItem, so caching it here before we remove it.
|
|
227
227
|
const _selectedItemElement = selectedItem.element;
|
|
@@ -229,7 +229,7 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
229
229
|
this.cancelKeyboardSelection();
|
|
230
230
|
|
|
231
231
|
this.isRetainingFocus = true;
|
|
232
|
-
|
|
232
|
+
scheduleOnce('render', () => {
|
|
233
233
|
const moves = this.moves;
|
|
234
234
|
if (moves && moves.length > 0) {
|
|
235
235
|
const sortedItems = this.sortedItems;
|
|
@@ -262,7 +262,7 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
262
262
|
}
|
|
263
263
|
this._announceAction(ANNOUNCEMENT_ACTION_TYPES.MOVE, delta);
|
|
264
264
|
// Guarantees that the before the UI is fully rendered before we move again.
|
|
265
|
-
|
|
265
|
+
scheduleOnce('render', () => {
|
|
266
266
|
this._move(sortedIndex, newSortedIndex);
|
|
267
267
|
this._updateHandleVisualIndicators(item, true);
|
|
268
268
|
|
|
@@ -344,7 +344,7 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
344
344
|
announcer.textContent = message;
|
|
345
345
|
|
|
346
346
|
// Reset the message after the message is announced.
|
|
347
|
-
|
|
347
|
+
later(() => {
|
|
348
348
|
announcer.textContent = '';
|
|
349
349
|
}, 1000);
|
|
350
350
|
}
|
|
@@ -675,16 +675,16 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
675
675
|
|
|
676
676
|
delete this._firstItemPosition;
|
|
677
677
|
|
|
678
|
-
|
|
678
|
+
schedule('render', () => {
|
|
679
679
|
items.forEach(item => item.freeze());
|
|
680
680
|
});
|
|
681
681
|
|
|
682
|
-
|
|
682
|
+
schedule('afterRender', () => {
|
|
683
683
|
items.forEach(item => item.reset());
|
|
684
684
|
});
|
|
685
685
|
|
|
686
|
-
|
|
687
|
-
|
|
686
|
+
next(() => {
|
|
687
|
+
schedule('render', () => {
|
|
688
688
|
items.forEach(item => item.thaw());
|
|
689
689
|
});
|
|
690
690
|
});
|
|
@@ -4,7 +4,7 @@ import {action, set} from '@ember/object';
|
|
|
4
4
|
import {reads} from '@ember/object/computed';
|
|
5
5
|
import {or} from '@ember/object/computed';
|
|
6
6
|
import {DRAG_ACTIONS, ELEMENT_CLICK_ACTION, END_ACTIONS} from "../utils/constant";
|
|
7
|
-
import { run, throttle } from '@ember/runloop';
|
|
7
|
+
import { run, throttle, bind, scheduleOnce, later } from '@ember/runloop';
|
|
8
8
|
import { DEBUG } from '@glimmer/env';
|
|
9
9
|
import {getX, getY} from "../utils/coordinate";
|
|
10
10
|
import ScrollContainer from "../system/scroll-container";
|
|
@@ -321,7 +321,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
321
321
|
startEvent.preventDefault();
|
|
322
322
|
startEvent.stopPropagation();
|
|
323
323
|
|
|
324
|
-
this._prepareDragListener =
|
|
324
|
+
this._prepareDragListener = bind(this, this._prepareDrag, startEvent);
|
|
325
325
|
|
|
326
326
|
DRAG_ACTIONS.forEach(event => window.addEventListener(event, this._prepareDragListener));
|
|
327
327
|
|
|
@@ -528,7 +528,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
528
528
|
@private
|
|
529
529
|
*/
|
|
530
530
|
_scheduleApplyPosition() {
|
|
531
|
-
|
|
531
|
+
scheduleOnce('render', this, '_applyPosition');
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
/**
|
|
@@ -638,7 +638,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
638
638
|
});
|
|
639
639
|
} else {
|
|
640
640
|
const duration = this.isAnimated ? this.transitionDuration : 200;
|
|
641
|
-
transitionPromise = new Promise((resolve) =>
|
|
641
|
+
transitionPromise = new Promise((resolve) => later(resolve, duration));
|
|
642
642
|
}
|
|
643
643
|
|
|
644
644
|
if (DEBUG) {
|