ember-mobile / ember-cli-fastclick

Simple FastClick support for Ember apps
MIT License
37 stars 12 forks source link

Does this work for 2.0 and {{actions}}? #3

Closed cbetta closed 8 years ago

cbetta commented 8 years ago

Does this work for Ember 2.0 and higher? Does this work for ember actions (not just clicks on links)?

lawitschka commented 8 years ago

Yes, works with Ember 2.x and actions

cbetta commented 8 years ago

Ok, still seems slow to me somehow. Any idea how I can confirm if it's working for me correctly?

lawitschka commented 8 years ago

I just tried it out in the lib's dummy app by adding a button which triggers a route action.

index.hbs

<button type="button" name="button" {{action 'logClick'}}>
  Click me!
</button>

index.js

import Ember from 'ember';

export default Ember.Route.extend({
  actions: {
    logClick() {
      window.console.log('Clicked');
    }
  }
});

Opening the app in Chrome, browsing through the sources, you will find the FastClick library in localhost:4200/assets/bower_components/fastclick/lib/fastclick.js. The method where the magic happens is onTouchEnd(). I just placed a breakpoint in line 606, in the following if block:

// localhost:4200/assets/bower_components/fastclick/lib/fastclick.js
if (!this.needsClick(targetElement)) {
  event.preventDefault();
  this.sendClick(targetElement, event);
}

When activating Emulate touch screen in the Developer Tools, execution stops at the breakpoint. When it is disabled, it does not stop, thus the click event is handled by the browser and not FastClick.

That is the way you can confirm, that it is working. At least, that is, what I just found out. Looked into how to confirm it is working for the first time. Before I luckily could always feel the difference.

cbetta commented 8 years ago

Awesome, tnx!