I have an app which needs to handle gestures like swipe
and tap
on mobile devices. I am using ember-gestures
addon to achieve that.
Mixing this additional code in a component and adding event handlers is important on mobile devices but completely useless on desktop devices.
How can one mix a mixin conditionally? I would like to detect the device and conditionally mix the mixin if the code is running on a mobile device.
Sample Code:
import Ember from 'ember';
import RecognizerMixin from 'ember-gestures/mixins/recognizers';
export default Ember.Component.extend(RecognizerMixin, {
recognizers: 'swipe',
swipe(e) {
//mobile swipe event
}
});
Aucun commentaire:
Enregistrer un commentaire