Skip to content

Commit

Permalink
Initialize FastClick
Browse files Browse the repository at this point in the history
  • Loading branch information
lawitschka committed Sep 10, 2018
1 parent 4afa2ef commit 01b4c16
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 51 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module.exports = {
env: {
browser: true
},
globals: {
'FastClick': true
},
rules: {
},
overrides: [
Expand Down
52 changes: 8 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <repository-url>`
* `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.
11 changes: 11 additions & 0 deletions addon/initializers/fastclick.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { schedule } from '@ember/runloop';

export function initialize() {
schedule('afterRender', function() {
FastClick.attach('body');
});
}

export default {
initialize
};
1 change: 1 addition & 0 deletions app/initializers/fastclick.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default, initialize } from 'ember-cli-fastclick/initializers/fastclick';
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -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');
}
};
1 change: 1 addition & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"compilerOptions":{"target":"es6","experimentalDecorators":true},"exclude":["node_modules","bower_components","tmp","vendor",".git","dist"]}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions tests/dummy/app/routes/index.js
Original file line number Diff line number Diff line change
@@ -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');
}
}
});
})
2 changes: 0 additions & 2 deletions tests/dummy/app/templates/index.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<button type="button" name="button" {{action 'logClick'}}>
Click me!
</button>

{{outlet}}
31 changes: 31 additions & 0 deletions tests/unit/initializers/fastclick-test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 01b4c16

Please sign in to comment.