Skip to content

Commit

Permalink
Revert DSC linting, circle, etc (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbieTheWagner committed Apr 12, 2018
1 parent 9311ac0 commit 3638109
Show file tree
Hide file tree
Showing 22 changed files with 1,739 additions and 2,119 deletions.
110 changes: 0 additions & 110 deletions .circleci/config.yml

This file was deleted.

43 changes: 41 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,48 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
plugins: [
'ember'
],
extends: [
'dollarshaveclub/ember'
'eslint:recommended',
'plugin:ember/recommended'
],
env: {
browser: true
},
root: true
rules: {
},
overrides: [
// node files
{
files: [
'index.js',
'testem.js',
'ember-cli-build.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
'app/**',
'addon/**',
'tests/dummy/app/**'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
},
env: {
browser: false,
node: true
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here
})
}
]
};
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "4"

sudo: false
dist: trusty

addons:
chrome: stable

cache:
yarn: true

env:
global:
# See https://git.io/vdao3 for details.
- JOBS=1
matrix:
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-lts-2.16
- EMBER_TRY_SCENARIO=ember-lts-2.18
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH

install:
- yarn install --no-lockfile --non-interactive

script:
- yarn lint:js
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup
68 changes: 34 additions & 34 deletions addon/index.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
import Mixin from '@ember/object/mixin'
import { get, computed } from '@ember/object'
import { inject } from '@ember/service'
import { getOwner } from '@ember/application'
import Mixin from '@ember/object/mixin';
import { get, computed } from '@ember/object';
import { inject } from '@ember/service';
import { getOwner } from '@ember/application';

export default Mixin.create({
scheduler: inject('scheduler'),
service: inject('router-scroll'),

isFastBoot: computed(function () {
const fastboot = getOwner(this).lookup('service:fastboot')
return fastboot ? fastboot.get('isFastBoot') : false
isFastBoot: computed(function() {
const fastboot = getOwner(this).lookup('service:fastboot');
return fastboot ? fastboot.get('isFastBoot') : false;
}),

willTransition (...args) {
this._super(...args)
willTransition(...args) {
this._super(...args);

if (get(this, 'isFastBoot')) { return }
if (get(this, 'isFastBoot')) { return; }

get(this, 'service').update()
get(this, 'service').update();
},

didTransition (transitions, ...args) {
this._super(transitions, ...args)
didTransition(transitions, ...args) {
this._super(transitions, ...args);

if (get(this, 'isFastBoot')) { return }
if (get(this, 'isFastBoot')) { return; }

this.get('scheduler').scheduleWork('afterContentPaint', () => {
this.updateScrollPosition(transitions)
})
this.updateScrollPosition(transitions);
});
},

updateScrollPosition (transitions) {
const lastTransition = transitions[transitions.length - 1]
const url = get(lastTransition, 'handler._router.currentURL')
const hashElement = url ? document.getElementById(url.split('#').pop()) : null
updateScrollPosition(transitions) {
const lastTransition = transitions[transitions.length - 1];
const url = get(lastTransition, 'handler.router.currentURL');
const hashElement = url ? document.getElementById(url.split('#').pop()) : null;

let scrollPosition
let scrollPosition;

if (url && url.indexOf('#') > -1 && hashElement) {
scrollPosition = { x: hashElement.offsetLeft, y: hashElement.offsetTop }
if(url && url.indexOf('#') > -1 && hashElement) {
scrollPosition = { x: hashElement.offsetLeft, y: hashElement.offsetTop };
} else {
scrollPosition = get(this, 'service.position')
scrollPosition = get(this, 'service.position');
}
const scrollElement = get(this, 'service.scrollElement')
const scrollElement = get(this, 'service.scrollElement');

const preserveScrollPosition = get(lastTransition, 'handler.controller.preserveScrollPosition')
const preserveScrollPosition = get(lastTransition, 'handler.controller.preserveScrollPosition');

if (!preserveScrollPosition) {
if (scrollElement === 'window') {
window.scrollTo(scrollPosition.x, scrollPosition.y)
} else if (scrollElement.charAt(0) === '#') {
const element = document.getElementById(scrollElement.substring(1))
if ('window' === scrollElement) {
window.scrollTo(scrollPosition.x, scrollPosition.y);
} else if ('#' === scrollElement.charAt(0)) {
const element = document.getElementById(scrollElement.substring(1));

if (element) {
element.scrollLeft = scrollPosition.x
element.scrollTop = scrollPosition.y
element.scrollLeft = scrollPosition.x;
element.scrollTop = scrollPosition.y;
}
}
}
},
})
}
});
Loading

0 comments on commit 3638109

Please sign in to comment.