From d7d48e70583f67a0566a803747769f05c5541ccb Mon Sep 17 00:00:00 2001 From: James Murphy Date: Fri, 19 Jun 2015 08:55:24 +1000 Subject: [PATCH 1/4] Removed EnumerableUtils --- addon/mixins/in-viewport.js | 7 +++---- tests/unit/utils/check-scroll-direction-test.js | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/addon/mixins/in-viewport.js b/addon/mixins/in-viewport.js index 4ab38cda..b77dbe9c 100644 --- a/addon/mixins/in-viewport.js +++ b/addon/mixins/in-viewport.js @@ -27,7 +27,6 @@ const { } = run; const { not } = computed; -const { forEach } = Ember.EnumerableUtils; const { classify } = Ember.String; const defaultListeners = [ @@ -72,7 +71,7 @@ export default Ember.Mixin.create({ const listeners = get(this, 'viewportListeners'); if (!get(this, 'viewportUseRAF')) { - forEach(listeners, (listener) => { + listeners.forEach((listener) => { const { context, event } = listener; this._bindListeners(context, event); }); @@ -228,7 +227,7 @@ export default Ember.Mixin.create({ }); } - forEach(listeners, (listener) => { + listeners.forEach((listener) => { const { context, event } = listener; $(context).off(`${event}.${elementId}`); }); @@ -239,7 +238,7 @@ export default Ember.Mixin.create({ _deprecateOldTriggers() { const directions = [ 'Up', 'Down', 'Left', 'Right' ]; - forEach(directions, (direction) => { + directions.forEach((direction) => { const triggerName = `didScroll${direction}`; const isListening = this.has(triggerName); deprecate( diff --git a/tests/unit/utils/check-scroll-direction-test.js b/tests/unit/utils/check-scroll-direction-test.js index e6be2bd1..5346e586 100644 --- a/tests/unit/utils/check-scroll-direction-test.js +++ b/tests/unit/utils/check-scroll-direction-test.js @@ -4,8 +4,6 @@ import { module, test } from 'qunit'; let lastPosition; -const { forEach } = Ember.EnumerableUtils; - module('checkScrollDirection', { beforeEach() { lastPosition = { @@ -25,7 +23,7 @@ test('returns the right direction', function(assert) { assert.expect(movements.length); - forEach(movements, (movement) => { + movements.forEach((movement) => { const { direction, position } = movement; const scrollDirection = checkScrollDirection(lastPosition, position); @@ -42,7 +40,7 @@ test('adjusts for sensitivity', function(assert) { assert.expect(movements.length); - forEach(movements, (movement) => { + movements.forEach((movement) => { const { direction, position } = movement; const scrollDirection = checkScrollDirection(lastPosition, position, 100); From a516e4ffd182bd83b19cf76710289f99d5f0107f Mon Sep 17 00:00:00 2001 From: Alex Navasardyan Date: Tue, 14 Jul 2015 23:38:04 -0700 Subject: [PATCH 2/4] Update to the latest ember-cli/ember --- .npmignore | 1 + Brocfile.js | 16 ---------------- bower.json | 8 ++++---- ember-cli-build.js | 17 +++++++++++++++++ package.json | 14 ++++++++------ tests/.jshintrc | 5 +++-- tests/acceptance/integration-test.js | 7 +------ tests/helpers/start-app.js | 1 - tests/unit/utils/check-scroll-direction-test.js | 1 - 9 files changed, 34 insertions(+), 36 deletions(-) delete mode 100644 Brocfile.js create mode 100644 ember-cli-build.js diff --git a/.npmignore b/.npmignore index 49996f5a..d522ca2b 100644 --- a/.npmignore +++ b/.npmignore @@ -10,5 +10,6 @@ dist/ .npmignore **/.gitkeep bower.json +ember-cli-build.js Brocfile.js testem.json diff --git a/Brocfile.js b/Brocfile.js deleted file mode 100644 index 2a682c03..00000000 --- a/Brocfile.js +++ /dev/null @@ -1,16 +0,0 @@ -/* jshint node: true */ -/* global require, module */ - -var EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); - -/* - This Brocfile specifes the options for the dummy test app of this - addon, located in `/tests/dummy` - - This Brocfile does *not* influence how the addon or the app using it - behave. You most likely want to be modifying `./index.js` or app's Brocfile -*/ - -var app = new EmberAddon(); - -module.exports = app.toTree(); diff --git a/bower.json b/bower.json index 6619a895..bb803af9 100644 --- a/bower.json +++ b/bower.json @@ -1,13 +1,13 @@ { "name": "ember-in-viewport", "dependencies": { - "ember": "1.12.0", + "ember": "1.13.3", "ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3", "ember-cli-test-loader": "ember-cli-test-loader#0.1.3", - "ember-load-initializers": "ember-cli/ember-load-initializers#0.1.4", - "ember-qunit": "0.3.3", + "ember-load-initializers": "ember-cli/ember-load-initializers#0.1.5", + "ember-qunit": "0.4.1", "ember-qunit-notifications": "0.0.7", - "ember-resolver": "~0.1.15", + "ember-resolver": "~0.1.18", "jquery": "^1.11.1", "loader.js": "ember-cli/loader.js#3.2.0", "qunit": "~1.17.1" diff --git a/ember-cli-build.js b/ember-cli-build.js new file mode 100644 index 00000000..d37d64cd --- /dev/null +++ b/ember-cli-build.js @@ -0,0 +1,17 @@ +/* global require, module */ +var EmberApp = require('ember-cli/lib/broccoli/ember-addon'); + +module.exports = function(defaults) { + var app = new EmberApp(defaults, { + // Add options here + }); + + /* + This build file specifes the options for the dummy test app of this + addon, located in `/tests/dummy` + This build file does *not* influence how the addon or the app using it + behave. You most likely want to be modifying `./index.js` or app's build file + */ + + return app.toTree(); +}; diff --git a/package.json b/package.json index f20ba490..50ac9107 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-in-viewport", - "version": "1.2.5", + "version": "1.2.6", "description": "Detect if an Ember View or Component is in the viewport @ 60FPS", "directories": { "doc": "doc", @@ -19,14 +19,16 @@ "license": "MIT", "devDependencies": { "broccoli-asset-rev": "^2.0.2", - "ember-cli": "^0.2.7", - "ember-cli-app-version": "0.3.3", + "ember-cli": "^1.13.1", + "ember-cli-app-version": "0.4.0", "ember-cli-content-security-policy": "0.4.0", "ember-cli-dependency-checker": "^1.0.0", - "ember-cli-htmlbars": "0.7.6", - "ember-cli-ic-ajax": "0.1.1", + "ember-cli-htmlbars": "0.7.9", + "ember-cli-htmlbars-inline-precompile": "^0.1.1", + "ember-cli-ic-ajax": "0.2.1", "ember-cli-inject-live-reload": "^1.3.0", - "ember-cli-qunit": "0.3.13", + "ember-cli-qunit": "0.3.15", + "ember-cli-release": "0.2.3", "ember-cli-uglify": "^1.0.1", "ember-disable-prototype-extensions": "^1.0.0", "ember-disable-proxy-controllers": "^1.0.0", diff --git a/tests/.jshintrc b/tests/.jshintrc index ea8b88f6..6ec0b7c1 100644 --- a/tests/.jshintrc +++ b/tests/.jshintrc @@ -26,7 +26,7 @@ "node": false, "browser": false, "boss": true, - "curly": false, + "curly": true, "debug": false, "devel": false, "eqeqeq": true, @@ -47,5 +47,6 @@ "strict": false, "white": false, "eqnull": true, - "esnext": true + "esnext": true, + "unused": true } diff --git a/tests/acceptance/integration-test.js b/tests/acceptance/integration-test.js index e2cd5889..36eae515 100644 --- a/tests/acceptance/integration-test.js +++ b/tests/acceptance/integration-test.js @@ -1,14 +1,11 @@ import Ember from 'ember'; import { module, - test, - skip + test } from 'qunit'; import startApp from '../helpers/start-app'; -import { lookupComponent } from '../helpers/utils/lookup'; let application; -const { run } = Ember; module('Acceptance: Integration', { beforeEach() { @@ -25,8 +22,6 @@ test('Component is active when in viewport', function(assert) { visit('/'); andThen(() => { - const component = lookupComponent(application, 'foo-bar'); - assert.ok(find('.fooBar.active').length); }); }); diff --git a/tests/helpers/start-app.js b/tests/helpers/start-app.js index 39eed65d..5949d536 100644 --- a/tests/helpers/start-app.js +++ b/tests/helpers/start-app.js @@ -1,6 +1,5 @@ import Ember from 'ember'; import Application from '../../app'; -import Router from '../../router'; import config from '../../config/environment'; export default function startApp(attrs) { diff --git a/tests/unit/utils/check-scroll-direction-test.js b/tests/unit/utils/check-scroll-direction-test.js index 5346e586..ec01e5d2 100644 --- a/tests/unit/utils/check-scroll-direction-test.js +++ b/tests/unit/utils/check-scroll-direction-test.js @@ -1,4 +1,3 @@ -import Ember from 'ember'; import checkScrollDirection from 'ember-in-viewport/utils/check-scroll-direction'; import { module, test } from 'qunit'; From 9398fb70700446ca601772009de8415b241b512b Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Fri, 14 Aug 2015 23:05:50 -0400 Subject: [PATCH 3/4] Update ember-cli and dependencies Removes deprecated scroll trigger. --- .travis.yml | 1 - addon/mixins/in-viewport.js | 59 ++++++++++--------------------------- bower.json | 10 +++---- package.json | 23 ++++++++------- 4 files changed, 32 insertions(+), 61 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e0e86e0..8197d316 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: node_js node_js: - "0.12" - - "iojs" sudo: false diff --git a/addon/mixins/in-viewport.js b/addon/mixins/in-viewport.js index b77dbe9c..2f08bb81 100644 --- a/addon/mixins/in-viewport.js +++ b/addon/mixins/in-viewport.js @@ -4,42 +4,29 @@ import canUseRAF from 'ember-in-viewport/utils/can-use-raf'; import isInViewport from 'ember-in-viewport/utils/is-in-viewport'; import checkScrollDirection from 'ember-in-viewport/utils/check-scroll-direction'; -const get = Ember.get; -const set = Ember.set; - const { + Mixin, setProperties, - deprecate, - computed, merge, typeOf, assert, - run, on, - $ + $, + get, + set, + run: { scheduleOnce, debounce, bind, next }, + computed: { not } } = Ember; - -const { - scheduleOnce, - debounce, - bind, - next -} = run; - -const { not } = computed; -const { classify } = Ember.String; - const defaultListeners = [ { context: window, event: 'scroll.scrollable' }, { context: window, event: 'resize.resizable' }, { context: document, event: 'touchmove.scrollable' } ]; - const rAFIDS = {}; const lastDirection = {}; const lastPosition = {}; -export default Ember.Mixin.create({ +export default Mixin.create({ viewportExited: not('viewportEntered').readOnly(), _setInitialState: on('init', function() { @@ -63,7 +50,6 @@ export default Ember.Mixin.create({ return; } - this._deprecateOldTriggers(); this._setInitialViewport(window); this._addObserverIfNotSpying(); this._bindScrollDirectionListener(window, get(this, 'viewportScrollSensitivity')); @@ -120,21 +106,20 @@ export default Ember.Mixin.create({ assert('You must pass a valid context element to _triggerDidScrollDirection', $contextEl); assert('sensitivity cannot be 0', sensitivity); - const elementId = get(this, 'elementId'); - const viewportEntered = get(this, 'viewportEntered'); + const elementId = get(this, 'elementId'); + const viewportEntered = get(this, 'viewportEntered'); const lastDirectionForEl = lastDirection[elementId]; - const lastPositionForEl = lastPosition[elementId]; + const lastPositionForEl = lastPosition[elementId]; const newPosition = { top: $contextEl.scrollTop(), left: $contextEl.scrollLeft() }; - const scrollDirection = checkScrollDirection(lastPositionForEl, newPosition, sensitivity); + const scrollDirection = checkScrollDirection(lastPositionForEl, newPosition, sensitivity); const directionChanged = scrollDirection !== lastDirectionForEl; if (scrollDirection && directionChanged && viewportEntered) { this.trigger('didScroll', scrollDirection); - this.trigger(`didScroll${classify(scrollDirection)}`, scrollDirection); lastDirection[elementId] = scrollDirection; } @@ -142,9 +127,9 @@ export default Ember.Mixin.create({ }, _triggerDidAccessViewport(hasEnteredViewport = false) { - const viewportEntered = get(this, 'viewportEntered'); - const didEnter = !viewportEntered && hasEnteredViewport; - const didLeave = viewportEntered && !hasEnteredViewport; + const viewportEntered = get(this, 'viewportEntered'); + const didEnter = !viewportEntered && hasEnteredViewport; + const didLeave = viewportEntered && !hasEnteredViewport; let triggeredEventName = ''; if (didEnter) { @@ -178,8 +163,7 @@ export default Ember.Mixin.create({ _debouncedEventHandler(methodName, ...args) { assert('You must pass a methodName to _debouncedEventHandler', methodName); - const validMethodString = typeOf(methodName) === 'string'; - assert('methodName must be a string', validMethodString); + assert('methodName must be a string', typeOf(methodName) === 'string'); debounce(this, () => { this[methodName](...args); @@ -233,18 +217,5 @@ export default Ember.Mixin.create({ }); this._unbindScrollDirectionListener(window); - }, - - _deprecateOldTriggers() { - const directions = [ 'Up', 'Down', 'Left', 'Right' ]; - - directions.forEach((direction) => { - const triggerName = `didScroll${direction}`; - const isListening = this.has(triggerName); - deprecate( - `[ember-in-viewport] ${triggerName} is deprecated, please use \`didScroll(direction)\` instead.`, - !isListening - ); - }); } }); diff --git a/bower.json b/bower.json index bb803af9..aa0fe495 100644 --- a/bower.json +++ b/bower.json @@ -1,15 +1,15 @@ { "name": "ember-in-viewport", "dependencies": { - "ember": "1.13.3", + "ember": "1.13.7", "ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3", "ember-cli-test-loader": "ember-cli-test-loader#0.1.3", "ember-load-initializers": "ember-cli/ember-load-initializers#0.1.5", - "ember-qunit": "0.4.1", + "ember-qunit": "0.4.9", "ember-qunit-notifications": "0.0.7", "ember-resolver": "~0.1.18", - "jquery": "^1.11.1", - "loader.js": "ember-cli/loader.js#3.2.0", - "qunit": "~1.17.1" + "jquery": "^1.11.3", + "loader.js": "ember-cli/loader.js#3.2.1", + "qunit": "~1.18.0" } } diff --git a/package.json b/package.json index 50ac9107..3f23e9fd 100644 --- a/package.json +++ b/package.json @@ -18,22 +18,23 @@ "author": "Lauren Tan", "license": "MIT", "devDependencies": { - "broccoli-asset-rev": "^2.0.2", - "ember-cli": "^1.13.1", - "ember-cli-app-version": "0.4.0", + "broccoli-asset-rev": "^2.1.2", + "ember-cli": "1.13.8", + "ember-cli-app-version": "0.5.0", "ember-cli-content-security-policy": "0.4.0", - "ember-cli-dependency-checker": "^1.0.0", + "ember-cli-dependency-checker": "^1.0.1", "ember-cli-htmlbars": "0.7.9", - "ember-cli-htmlbars-inline-precompile": "^0.1.1", + "ember-cli-htmlbars-inline-precompile": "^0.2.0", "ember-cli-ic-ajax": "0.2.1", - "ember-cli-inject-live-reload": "^1.3.0", - "ember-cli-qunit": "0.3.15", + "ember-cli-inject-live-reload": "^1.3.1", + "ember-cli-qunit": "^1.0.0", "ember-cli-release": "0.2.3", - "ember-cli-uglify": "^1.0.1", + "ember-cli-sri": "^1.0.3", + "ember-cli-uglify": "^1.2.0", "ember-disable-prototype-extensions": "^1.0.0", "ember-disable-proxy-controllers": "^1.0.0", - "ember-export-application-global": "^1.0.2", - "ember-suave": "0.1.9", + "ember-export-application-global": "^1.0.3", + "ember-suave": "1.0.0", "ember-try": "0.0.6" }, "keywords": [ @@ -46,7 +47,7 @@ "scrollspy" ], "dependencies": { - "ember-cli-babel": "^5.0.0" + "ember-cli-babel": "^5.1.3" }, "ember-addon": { "configPath": "tests/dummy/config", From 803beb0fb5c63b08782c32e340aef61266a90560 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 17 Aug 2015 09:57:08 -0400 Subject: [PATCH 4/4] Version bump to 2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3f23e9fd..dcfdab20 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-in-viewport", - "version": "1.2.6", + "version": "2.0.0", "description": "Detect if an Ember View or Component is in the viewport @ 60FPS", "directories": { "doc": "doc",