diff --git a/.eslintrc.js b/.eslintrc.js index b956de0..aaec459 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -14,6 +14,9 @@ module.exports = { env: { browser: true }, + globals: { + 'FastClick': true + }, rules: { }, overrides: [ diff --git a/README.md b/README.md index 34cabb7..9b817d6 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,14 @@ -ember-cli-fastclick -============================================================================== +# Ember CLI FastClick -[Short description of the addon.] +Drop-in FastClick support for Ember CLI apps. -Installation ------------------------------------------------------------------------------- +For more information on FastClick visit http://ftlabs.github.io/fastclick. -``` -ember install ember-cli-fastclick -``` +## Installation +This is addon is installed in one simple step: -Usage ------------------------------------------------------------------------------- + ember install ember-cli-fastclick -[Longer description of how to use the addon in apps.] - - -Contributing ------------------------------------------------------------------------------- - -### Installation - -* `git clone ` -* `cd ember-cli-fastclick` -* `yarn install` - -### Linting - -* `yarn lint:js` -* `yarn lint:js --fix` - -### Running tests - -* `ember test` – Runs the test suite on the current Ember version -* `ember test --server` – Runs the test suite in "watch mode" -* `ember try:each` – Runs the test suite against multiple Ember versions - -### Running the dummy application - -* `ember serve` -* Visit the dummy application at [http://localhost:4200](http://localhost:4200). - -For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/). - -License ------------------------------------------------------------------------------- - -This project is licensed under the [MIT License](LICENSE.md). +When you now access your app from a mobile device you should see that the 300ms +touch delay was removed and the app feels more like a native app. diff --git a/addon/initializers/fastclick.js b/addon/initializers/fastclick.js new file mode 100644 index 0000000..5d44562 --- /dev/null +++ b/addon/initializers/fastclick.js @@ -0,0 +1,11 @@ +import { schedule } from '@ember/runloop'; + +export function initialize() { + schedule('afterRender', function() { + FastClick.attach('body'); + }); +} + +export default { + initialize +}; diff --git a/app/initializers/fastclick.js b/app/initializers/fastclick.js new file mode 100644 index 0000000..90ece4c --- /dev/null +++ b/app/initializers/fastclick.js @@ -0,0 +1 @@ +export { default, initialize } from 'ember-cli-fastclick/initializers/fastclick'; diff --git a/index.js b/index.js index b5a7882..d7780eb 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,10 @@ 'use strict'; module.exports = { - name: 'ember-cli-fastclick' + name: 'ember-cli-fastclick', + + included(app) { + this._super.included(app); + app.import('node_modules/fastclick/lib/fastclick.js'); + } }; diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..f408cac --- /dev/null +++ b/jsconfig.json @@ -0,0 +1 @@ +{"compilerOptions":{"target":"es6","experimentalDecorators":true},"exclude":["node_modules","bower_components","tmp","vendor",".git","dist"]} \ No newline at end of file diff --git a/package.json b/package.json index 084f607..36df7eb 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "test:all": "ember try:each" }, "dependencies": { - "ember-cli-babel": "^6.6.0" + "ember-cli-babel": "^6.6.0", + "fastclick": "^1.0.6" }, "devDependencies": { "broccoli-asset-rev": "^2.7.0", diff --git a/tests/dummy/app/routes/index.js b/tests/dummy/app/routes/index.js index 88275ca..0ff9fe6 100644 --- a/tests/dummy/app/routes/index.js +++ b/tests/dummy/app/routes/index.js @@ -1,9 +1,9 @@ -import Ember from 'ember'; +import Route from '@ember/routing/route'; -export default Ember.Route.extend({ +export default Route.extend({ actions: { logClick() { window.console.log('Clicked'); } } -}); +}) diff --git a/tests/dummy/app/templates/index.hbs b/tests/dummy/app/templates/index.hbs index a7844af..e0a3800 100644 --- a/tests/dummy/app/templates/index.hbs +++ b/tests/dummy/app/templates/index.hbs @@ -1,5 +1,3 @@ - -{{outlet}} diff --git a/tests/unit/initializers/fastclick-test.js b/tests/unit/initializers/fastclick-test.js new file mode 100644 index 0000000..0642d03 --- /dev/null +++ b/tests/unit/initializers/fastclick-test.js @@ -0,0 +1,31 @@ +import Application from '@ember/application'; + +import { initialize } from 'dummy/initializers/fastclick'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; +import { run } from '@ember/runloop'; + +module('Unit | Initializer | fastclick', function(hooks) { + setupTest(hooks); + + hooks.beforeEach(function() { + this.TestApplication = Application.extend(); + this.TestApplication.initializer({ + name: 'initializer under test', + initialize + }); + + this.application = this.TestApplication.create({ autoboot: false }); + }); + + hooks.afterEach(function() { + run(this.application, 'destroy'); + }); + + // Replace this with your real tests. + test('it works', async function(assert) { + await this.application.boot(); + + assert.ok(true); + }); +}); diff --git a/yarn.lock b/yarn.lock index 7e1a212..fa57fc4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2556,6 +2556,10 @@ fast-sourcemap-concat@^1.4.0: source-map-url "^0.3.0" sourcemap-validator "^1.1.0" +fastclick@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/fastclick/-/fastclick-1.0.6.tgz#161625b27b1a5806405936bda9a2c1926d06be6a" + faye-websocket@~0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4"