Skip to content

Commit

Permalink
Destructuring Ember, add ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbieTheWagner committed Aug 12, 2016
1 parent 3e58aed commit ff0fe7a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 106 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var path = require('path');

module.exports = {
extends: [
require.resolve('ember-cli-eslint/coding-standard/ember-application.js')
]
};
32 changes: 0 additions & 32 deletions .jshintrc

This file was deleted.

7 changes: 4 additions & 3 deletions addon/mixins/reset-scroll.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Ember from 'ember';
const { $, Mixin } = Ember;

export default Ember.Mixin.create({
export default Mixin.create({
/**
* Scroll to top when route is entered.
*/
activate(...args) {
this._super(...args);
Ember.$(window).scrollTop(0);
},
$(window).scrollTop(0);
}
});
37 changes: 19 additions & 18 deletions addon/mixins/scroll-operator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ember from 'ember';
const { $, Mixin, run } = Ember;

export default Ember.Mixin.create({
export default Mixin.create({
_scrollingTimeout: 100,

/**
Expand Down Expand Up @@ -50,31 +51,19 @@ export default Ember.Mixin.create({
this._super(...args);

if (controller) {
Ember.run.schedule('afterRender', null, () => {
Ember.$(window).scrollTop(controller.getWithDefault('currentPosition', 0));
run.schedule('afterRender', null, () => {
$(window).scrollTop(controller.getWithDefault('currentPosition', 0));
this._attachEvents();
});
}
},

_attachEvents() {
const onScroll = () => {
Ember.run.debounce(this, this._setScrollTop, this._scrollingTimeout);
run.debounce(this, this._setScrollTop, this._scrollingTimeout);
};
Ember.$(document).on('touchmove.scrollable', onScroll);
Ember.$(window).on('scroll.scrollable', onScroll);
},

_detachEvents() {
Ember.$(document).off('.scrollable');
Ember.$(window).off('.scrollable');
},

/**
* Set currentPosition to $(window).scrollTop value.
*/
_setScrollTop() {
this.set('controller.currentPosition', Ember.$(window).scrollTop());
$(document).on('touchmove.scrollable', onScroll);
$(window).on('scroll.scrollable', onScroll);
},

/**
Expand All @@ -84,4 +73,16 @@ export default Ember.Mixin.create({
_didTransitionViaBackOrForward(transition) {
return transition && transition.sequence > 1 && transition.hasOwnProperty('urlMethod');
},

_detachEvents() {
$(document).off('.scrollable');
$(window).off('.scrollable');
},

/**
* Set currentPosition to $(window).scrollTop value.
*/
_setScrollTop() {
this.set('controller.currentPosition', $(window).scrollTop());
}
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"ember-cli": "2.7.0",
"ember-cli-app-version": "^1.0.0",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-eslint": "1.7.0",
"ember-cli-htmlbars": "^1.0.3",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-inject-live-reload": "^1.4.0",
"ember-cli-jshint": "^1.0.0",
"ember-cli-qunit": "^2.0.0",
"ember-cli-release": "^0.2.9",
"ember-cli-sri": "^2.1.0",
Expand Down
3 changes: 3 additions & 0 deletions tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: '../node_modules/ember-cli-eslint/coding-standard/ember-testing.js'
};
52 changes: 0 additions & 52 deletions tests/.jshintrc

This file was deleted.

0 comments on commit ff0fe7a

Please sign in to comment.