Skip to content

Commit

Permalink
Fix touch events.
Browse files Browse the repository at this point in the history
  • Loading branch information
oesmith committed Jun 15, 2014
1 parent bce2c80 commit 2df090e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/morris.grid.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class Morris.Grid extends Morris.EventEmitter
@el.bind 'touchstart touchmove touchend', (evt) =>
touch = evt.originalEvent.touches[0] or evt.originalEvent.changedTouches[0]
offset = @el.offset()
@fire 'hover', touch.pageX - offset.left, touch.pageY - offset.top
touch
@fire 'hovermove', touch.pageX - offset.left, touch.pageY - offset.top

@el.bind 'click', (evt) =>
offset = @el.offset()
Expand All @@ -87,6 +86,9 @@ class Morris.Grid extends Morris.EventEmitter
window.clearTimeout @timeoutId
@timeoutId = window.setTimeout @resizeHandler, 100

# Disable tap highlight on iOS.
@el.css('-webkit-tap-highlight-color', 'rgba(0,0,0,0)')

@postInit() if @postInit

# Default options
Expand Down
4 changes: 2 additions & 2 deletions morris.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ Licensed under the BSD-2-Clause License.
var offset, touch;
touch = evt.originalEvent.touches[0] || evt.originalEvent.changedTouches[0];
offset = _this.el.offset();
_this.fire('hover', touch.pageX - offset.left, touch.pageY - offset.top);
return touch;
return _this.fire('hovermove', touch.pageX - offset.left, touch.pageY - offset.top);
});
this.el.bind('click', function(evt) {
var offset;
Expand Down Expand Up @@ -160,6 +159,7 @@ Licensed under the BSD-2-Clause License.
return _this.timeoutId = window.setTimeout(_this.resizeHandler, 100);
});
}
this.el.css('-webkit-tap-highlight-color', 'rgba(0,0,0,0)');
if (this.postInit) {
this.postInit();
}
Expand Down
Loading

0 comments on commit 2df090e

Please sign in to comment.