Skip to content

Commit

Permalink
add support for touch events
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancahill committed Oct 23, 2015
1 parent 3db47d7 commit dd6febe
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion split.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ var Split = function (ids, options) {
// Get the relative position of the event from the first side of the
// pair.

var offset = e[clientAxis] - this.start;
if ('touches' in e) {
var offset = e.touches[0][clientAxis] - this.start;
} else {
var offset = e[clientAxis] - this.start;
}

// If within snapOffset of min or max, set offset to min or max

Expand Down Expand Up @@ -254,6 +258,11 @@ var Split = function (ids, options) {
parent.addEventListener('mousemove', drag.bind(pair));
parent.addEventListener('mouseleave', stopDragging.bind(pair));

gutter.addEventListener('touchstart', startDragging.bind(pair));
parent.addEventListener('touchend', stopDragging.bind(pair));
parent.addEventListener('touchcancel', stopDragging.bind(pair));
parent.addEventListener('touchmove', drag.bind(pair));

parent.insertBefore(gutter, el);

pair.gutter = gutter;
Expand Down

0 comments on commit dd6febe

Please sign in to comment.