Skip to content

Commit e29782d

Browse files
committed
A bunch of improvements
- Renamed as-scrollable component file to scrollable in the library - Created a mixin and consumed in the component - Using Trackpad Scroll Emulator from npm
1 parent 1cdd608 commit e29782d

File tree

6 files changed

+51
-30
lines changed

6 files changed

+51
-30
lines changed

addon/components/as-scrollable.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

addon/components/scrollable.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Ember from 'ember';
2+
import InboundActionsMixin from 'ember-component-inbound-actions/inbound-actions';
3+
import ScrollableMixin from '../mixins/scrollable';
4+
import layout from '../templates/components/scrollable';
5+
6+
export default Ember.Component.extend(InboundActionsMixin, ScrollableMixin, {
7+
layout
8+
});

addon/mixins/scrollable.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Ember from 'ember';
2+
3+
const {
4+
run: { scheduleOnce }
5+
} = Ember;
6+
7+
export default Ember.Mixin.create({
8+
classNameBindings: [':as-scrollable', ':tse-scrollable', 'horizontal'],
9+
10+
horizontal: false,
11+
autoHide: true,
12+
13+
didInsertElement() {
14+
this._super(...arguments);
15+
16+
scheduleOnce('afterRender', this, this._setupTrackpadScrollEmulator);
17+
},
18+
19+
willDestroyElement() {
20+
this._super(...arguments);
21+
22+
this._destroyTrackpadScrollEmulator();
23+
},
24+
25+
_setupTrackpadScrollEmulator() {
26+
this.$().TrackpadScrollEmulator({ wrapContent: false, autoHide: this.get('autoHide') });
27+
},
28+
29+
_destroyTrackpadScrollEmulator() {
30+
this.$().TrackpadScrollEmulator('destroy');
31+
},
32+
33+
actions: {
34+
recalculate() {
35+
this.$().TrackpadScrollEmulator('recalculate');
36+
}
37+
}
38+
});

app/components/as-scrollable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import AsScrollable from 'ember-scrollable/components/as-scrollable';
1+
import ScrollableComponent from 'ember-scrollable/components/scrollable';
22

3-
export default AsScrollable;
3+
export default ScrollableComponent;

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"ember-cli": "2.6.0-beta.3",
2424
"ember-cli-app-version": "^1.0.0",
2525
"ember-cli-dependency-checker": "^1.2.0",
26-
"ember-cli-htmlbars": "^1.0.3",
2726
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
2827
"ember-cli-inject-live-reload": "^1.4.0",
2928
"ember-cli-jshint": "^1.0.0",
@@ -45,9 +44,10 @@
4544
],
4645
"dependencies": {
4746
"ember-cli-babel": "^5.1.6",
48-
"ember-component-inbound-actions": "1.0.1",
47+
"ember-cli-htmlbars": "^1.0.3",
4948
"ember-cli-node-assets": "0.1.3",
50-
"trackpad-scroll-emulator": "taras/trackpad-scroll-emulator#dd5e916727e63ea2f1bf1ccad4099c99ab7303fc"
49+
"ember-component-inbound-actions": "1.0.1",
50+
"trackpad-scroll-emulator": "git://github.com/taras/trackpad-scroll-emulator.git#dd5e916727e63ea2f1bf1ccad4099c99ab7303fc"
5151
},
5252
"ember-addon": {
5353
"configPath": "tests/dummy/config"

0 commit comments

Comments
 (0)