Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

Commit

Permalink
fix: error when client{X/Y} was 0
Browse files Browse the repository at this point in the history
  • Loading branch information
TheComputerM committed Sep 10, 2020
1 parent 1f581c0 commit dbf2eae
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ export function RippleStart(e, options = {}) {
e.stopImmediatePropagation();
const opts = { ...defaults, ...options };

const isTouchEvent = e.touches ? !!e.touches[0] : false;
// Parent element
const target = e.touches ? e.touches[0].currentTarget : e.currentTarget;
const target = isTouchEvent ? e.touches[0].currentTarget : e.currentTarget;

// Create ripple
const ripple = document.createElement('div');
Expand Down Expand Up @@ -56,8 +57,8 @@ export function RippleStart(e, options = {}) {
rippleStyle.top = `${targetRect.height / 2}px`;
rippleStyle.left = `${targetRect.width / 2}px`;
} else {
const distY = e.clientY || e.touches[0].clientY;
const distX = e.clientX || e.touches[0].clientX;
const distY = isTouchEvent ? e.touches[0].clientY : e.clientY;
const distX = isTouchEvent ? e.touches[0].clientX : e.clientX;
rippleStyle.top = `${distY - targetRect.top}px`;
rippleStyle.left = `${distX - targetRect.left}px`;
}
Expand Down

0 comments on commit dbf2eae

Please sign in to comment.