Skip to content

Commit

Permalink
Merge pull request adopted-ember-addons#21 from jgwhite/glimmer-compat
Browse files Browse the repository at this point in the history
Glimmer
  • Loading branch information
jgwhite committed May 11, 2015
2 parents 786e255 + 3c83d55 commit 28c9d5c
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
16 changes: 15 additions & 1 deletion addon/components/sortable-group.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';
import layout from '../templates/components/sortable-group';
const { $, A, Component, computed, get, set } = Ember;
const { $, A, Component, computed, get, set, run } = Ember;
const a = A;

export default Component.extend({
Expand Down Expand Up @@ -98,6 +98,20 @@ export default Component.extend({

delete this._itemPosition;

run.schedule('render', () => {
items.invoke('freeze');
});

run.schedule('afterRender', () => {
items.invoke('reset');
});

run.next(() => {
run.schedule('render', () => {
items.invoke('thaw');
});
});

this.sendAction('onChange', models);
}
});
34 changes: 33 additions & 1 deletion addon/mixins/sortable-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default Mixin.create({
}

return this._y;
}),
}).volatile(),

/**
Height of the item including margins.
Expand Down Expand Up @@ -165,6 +165,38 @@ export default Mixin.create({
this._startDrag(event);
},

/**
@method freeze
*/
freeze() {
let el = this.$();
if (!el) { return; }

this.$().css({ transition: 'none' });
this.$().height(); // Force-apply styles
},

/**
@method reset
*/
reset() {
let el = this.$();
if (!el) { return; }

delete this._y;
el.css({ transform: '' });
},

/**
@method thaw
*/
thaw() {
let el = this.$();
if (!el) { return; }

el.css({ transition: '' });
},

/**
@method _startDrag
@private
Expand Down
7 changes: 5 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ember-sortable",
"dependencies": {
"ember": "1.11.1",
"ember": "canary",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
"ember-data": "1.0.0-beta.16.1",
Expand All @@ -12,5 +12,8 @@
"jquery": "^1.11.1",
"loader.js": "ember-cli/loader.js#3.2.0",
"qunit": "~1.17.1"
},
"resolutions": {
"ember": "canary"
}
}
}
5 changes: 4 additions & 1 deletion tests/unit/components/sortable-group-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
} from 'ember-qunit';
import Ember from 'ember';
const a = Ember.A;
const { run } = Ember;

moduleForComponent('sortable-group');

Expand Down Expand Up @@ -121,7 +122,9 @@ test('commit', function(assert) {
onChange: 'reorder'
});

component.commit();
run(() => {
component.commit();
});

assert.deepEqual(targetObject.newOrder, ['foo', 'bar', 'baz'],
'expected target to receive models in order');
Expand Down

0 comments on commit 28c9d5c

Please sign in to comment.