xuijs / xui

A tiny javascript framework for mobile web apps.
http://xuijs.com
789 stars 106 forks source link

What's Everyone Using for Touch / Swipe Mangement? #61

Closed tekmonk closed 10 years ago

tekmonk commented 12 years ago

Aside from the built-in xui event management, is there a framework or module you guys are using to handle touchevents / swipes? Maybe I am overthinking this because I'm building Apps (where i need just touch), but I still want click support to test in browser.

I did modify this script for xuijs but it breaks too often with double taps and stuff https://github.com/dave1010/jquery-fast-click

That said there's nothing readily available for in xuijs swipes .... This plugin exists but it's definitely a little buggy https://github.com/xui/xui-plugins/tree/master/swipe

Is there another mobile framework out there where I can just rip a module to handle these events?

ghost commented 12 years ago

Many libraries' tap event manufacturing is incompatible with the new css style "overflow:scroll". So if using this style is important to you, I suggest you test the framework before you dive too deep.

filmaj commented 12 years ago

@tekmonk if you tried the swipe plugin and it's not working, feel free to file issues. I would be interested in giving that a shot and getting proper unit tests and whatnot going for that plugin. This is becoming a pretty common ask so I am interested in helping out.

One common theme for xui is always "what do other frameworks do?" Does jQuery or any of the other frameworks have a good solution for this in place? Can we look to that for inspiration/guidance/inclusion?

tekmonk commented 12 years ago

@will-quast-bohemian - What do you mean specifically that it's not compatible?

@filmaj - I've been looking at zepto.js. It looks to be a little heavier than xui, but its still much lighter then jquery mobile. Anyway, they have their modules broken out into different bits, so event.js and touch.js would be worth looking at.
https://github.com/madrobby/zepto/tree/master/src

My option at this point is to try to bring that functionality into xui.js (which looks out of my skillset) or move the project over to zepto entirely (doable for me but time-consuming)

filmaj commented 12 years ago

Good timing on this issue as @remy was bringing this up on the twitters recently.

He mentioned he had wanted to used this blog post on touch notation as a spec for a potential touch API. No one has really done anything (half-decent, anyways) but it's a common problem so it is worth solving.

Should we try brainstorming an API spec in this issue thread?

ghost commented 12 years ago

I have been using the XUI swipe plugin for about 2 months now in 2 apps and it seems to be working just fine as long as you dont use it in any scrolling divs. It seems that both the native 'overflow: scroll' and iscroll.js both have issues with the plugin. For example, the simpleTap event will always fire when bound to elements in an iscroll scroller that is just being scrolled. I have even tried to pass the 'preventDefaultEvents: false' option, but that doesn't help. I have just reverted to binding to click events for those places. I did add a connivence method to the plugin that allows similar code to 'something.click(...)' .

tap : function(callback) {
  this.swipe(callback, {
      swipeCapture: false,
      longTapCapture: true,
      doubleTapCapture: false,
      simpleTapCapture: true
    }
  );
}