Skip to content

Commit

Permalink
Make touch-ripple properly react to touch events
Browse files Browse the repository at this point in the history
Fixes mui#542.
  • Loading branch information
pomerantsev committed Apr 16, 2015
1 parent 98b048f commit 90f98ec
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/js/ripples/touch-ripple.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ var TouchRipple = React.createClass({
},

_handleTouchEnd: function(e) {
// Prevent mouse events from firing on touch-enabled devices.
if (e.cancelable) {
e.preventDefault();
}
this.end();
},

Expand All @@ -130,8 +134,9 @@ var TouchRipple = React.createClass({
var elHeight = el.offsetHeight;
var elWidth = el.offsetWidth;
var offset = Dom.offset(el);
var pageX = e.pageX == undefined ? e.nativeEvent.pageX : e.pageX;
var pageY = e.pageY == undefined ? e.nativeEvent.pageY : e.pageY;
var isTouchEvent = e.touches && e.touches.length;
var pageX = isTouchEvent ? e.touches[0].pageX : e.pageX;
var pageY = isTouchEvent ? e.touches[0].pageY : e.pageY;
var pointerX = pageX - offset.left;
var pointerY = pageY - offset.top;
var topLeftDiag = this._calcDiag(pointerX, pointerY);
Expand Down

0 comments on commit 90f98ec

Please sign in to comment.