Fix touch events.

This commit is contained in:
Olly Smith 2014-06-15 21:01:21 +01:00
parent bce2c80fde
commit 2df090ee48
3 changed files with 7 additions and 5 deletions

View File

@ -59,8 +59,7 @@ class Morris.Grid extends Morris.EventEmitter
@el.bind 'touchstart touchmove touchend', (evt) => @el.bind 'touchstart touchmove touchend', (evt) =>
touch = evt.originalEvent.touches[0] or evt.originalEvent.changedTouches[0] touch = evt.originalEvent.touches[0] or evt.originalEvent.changedTouches[0]
offset = @el.offset() offset = @el.offset()
@fire 'hover', touch.pageX - offset.left, touch.pageY - offset.top @fire 'hovermove', touch.pageX - offset.left, touch.pageY - offset.top
touch
@el.bind 'click', (evt) => @el.bind 'click', (evt) =>
offset = @el.offset() offset = @el.offset()
@ -87,6 +86,9 @@ class Morris.Grid extends Morris.EventEmitter
window.clearTimeout @timeoutId window.clearTimeout @timeoutId
@timeoutId = window.setTimeout @resizeHandler, 100 @timeoutId = window.setTimeout @resizeHandler, 100
# Disable tap highlight on iOS.
@el.css('-webkit-tap-highlight-color', 'rgba(0,0,0,0)')
@postInit() if @postInit @postInit() if @postInit
# Default options # Default options

View File

@ -127,8 +127,7 @@ Licensed under the BSD-2-Clause License.
var offset, touch; var offset, touch;
touch = evt.originalEvent.touches[0] || evt.originalEvent.changedTouches[0]; touch = evt.originalEvent.touches[0] || evt.originalEvent.changedTouches[0];
offset = _this.el.offset(); offset = _this.el.offset();
_this.fire('hover', touch.pageX - offset.left, touch.pageY - offset.top); return _this.fire('hovermove', touch.pageX - offset.left, touch.pageY - offset.top);
return touch;
}); });
this.el.bind('click', function(evt) { this.el.bind('click', function(evt) {
var offset; var offset;
@ -160,6 +159,7 @@ Licensed under the BSD-2-Clause License.
return _this.timeoutId = window.setTimeout(_this.resizeHandler, 100); return _this.timeoutId = window.setTimeout(_this.resizeHandler, 100);
}); });
} }
this.el.css('-webkit-tap-highlight-color', 'rgba(0,0,0,0)');
if (this.postInit) { if (this.postInit) {
this.postInit(); this.postInit();
} }

2
morris.min.js vendored

File diff suppressed because one or more lines are too long