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

Support touch events #885

Closed
samacs opened this issue Apr 24, 2015 · 2 comments
Closed

Support touch events #885

samacs opened this issue Apr 24, 2015 · 2 comments

Comments

@samacs
Copy link

samacs commented Apr 24, 2015

I was trying to use this plugin with Ionic framework and realized that it does not support touch events. And I found it very simple to implement.

In file js/jquery.tablesorter.js around lines 1344 through 1350 just needed to add touchstart to the events bound to the headers to make it work:

.unbind( ('mousedown mouseup click sort keyup touchstart '.split(' ').join(c.namespace + ' ')).replace(/\s+/g, ' ') )
.bind( 'mousedown mouseup click sort keyup touchstart '.split(' ').join(c.namespace + ' '), function(e, external) {
...
// only recognize left clicks
if ( ( ( e.which || e.button ) !== 1 && !/sort|keyup|click|touchstart/.test(type) ) ||
@Mottie Mottie closed this as completed in 2756717 Apr 26, 2015
@Mottie
Copy link
Owner

Mottie commented Apr 26, 2015

Hi @samacs!

I thought click events were still fired on touch devices. Anyway, in anticipation of future support for pointer events I'll add three new options which will allow changing the sort triggering events:

  • pointerClick - mouse click event (not really part of the pointer events). Additional custom events can be included in this option with event names separated by spaces (e.g. 'click makeItSo')
  • pointerDown - pointer down (mouse or touch) event. This event only saves the current header cell being activated for a sort.
  • pointerUp - pointer up (mouse or touch) event. This event triggers a sort if the target of this event and the pointer down event match.

If you want to trigger a sort when the pointer down event fires, then set the pointerClick option to that event; Also set the pointerDown and pointerUp options to empty strings.

Warning: Do not set the pointerDown or pointerUp options to include multiple events of the same action. For example, if the pointerDown option is set to "mousedown pointerdown", both events fire asynchronously and since tablesorter does not check for a time interval between events, both could potentially trigger a sort making the table column appear to not sort at all (if already sorted).

@KennedyIhe
Copy link

It will be nice if this enhancement can be worked on. The tablesorter plugin and scroll widget work great, but one problem is on iPad or other touch devices, touch and drag scroll is really slow and not user friendly. I had to apply a lot of custom fixes to make it scroll smoothly.

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

No branches or pull requests

3 participants