Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swipe and vertical-swipe #58

Open
sir-dunxalot opened this issue Jul 14, 2016 · 7 comments
Open

Swipe and vertical-swipe #58

sir-dunxalot opened this issue Jul 14, 2016 · 7 comments

Comments

@sir-dunxalot
Copy link

Cool library!

Currently the default recognizers don't support horizontal and vertical swiping. For example, recognizers: 'vertical-swipe swipe', results in just horizontal swipe event firing and recognizers: 'swipe vertical-swipe ', result in just vertical swipe events firing.

I'm hoping to be able write my own recognizer for a four-way swipe but I would expect the default recognizers to be compatible with one another.

@sir-dunxalot
Copy link
Author

sir-dunxalot commented Jul 14, 2016

My attempt to implement horizontal and vertical swiping listeners on the same component went as follows:

// my-project/app/ember-gestures/recognizers/four-way-swipe.js
export default {
  include: [],
  exclude: [],
  options: { threshold: 25 },
  recognizer: 'swipe'
};

And my component...

import RecognizerMixin from 'ember-gestures/mixins/recognizers';

const { $, computed } = Ember;

export default Ember.Component.extend(
  RecognizerMixin, {

  recognizers: 'four-way-swipe',

  swipeDown() {},
  swipeLeft() {},
  swipeRight() {},
  swipeUp() {},
}

Unfortunately, none of the methods above are called. At least two are called when I replace recognizers with recognizers: 'swipe', (runs swipeLeft() and swipeRight()) or recognizers: 'vertical-swipe', (runs swipeUp() and swipeDown()).

Is there a shared compatibility issue here or are we looking at two separate issues? Maybe the code outlined in this comment is just me misunderstanding the documentation but I want to keep the thread in one place until we confirm that.

@sir-dunxalot
Copy link
Author

Coming full circle, my solution way to name the recognizer swipe. It seems that this library only supports given recognizer names because the event listened for is inherited from the recognizer name.

As such:

// my-project/app/ember-gestures/recognizers/swipe.js
export default {
  include: [],
  exclude: [],
  options: { threshold: 25 },
  recognizer: 'swipe'
};

With: recognizers: 'four-way-swipe', worked for me.

I hope this helps someone in a similar situation.

@runspired
Copy link
Collaborator

@sir-dunxalot there's a secret hidden property that lets you inherit but rename, vertical-swipe uses it.

You should have been able to do recognizers: 'swipe vertical-swipe', that you couldn't suggests I need to revisit how they declare support for each other.

@choclaudio
Copy link

Any news on this @sir-dunxalot

@jorgelainfiesta
Copy link

I couldn't really replicate the solution exposed by @sir-dunxalot, but I was able to use swipeDown and swipeLeft by registering only the 'swipe' recognizer in the component by having a local swipe recognizers in app/ember-gestures/recognizers/four-way-swipe.js

@choclaudio
Copy link

Hi @jorgelainfiesta yes, I did the same, and it works like a charm, should have written it here so cudos for your initiative!

@RobbieTheWagner
Copy link
Member

Just coming through to clean up some of these lingering issues. @jorgelainfiesta @choclaudio are the solutions you guys used something we should update in this addon or document or does everything work as advertised now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants