mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
Fix hover scrubber error in Firefox (#5243)
This commit is contained in:
parent
5407596e0d
commit
b897de3e5e
1 changed files with 8 additions and 3 deletions
|
|
@ -1,6 +1,9 @@
|
|||
import React, { useMemo } from "react";
|
||||
import cx from "classnames";
|
||||
|
||||
// #5231: TouchEvent is not defined on all browsers
|
||||
const touchEventDefined = window.TouchEvent !== undefined;
|
||||
|
||||
interface IHoverScrubber {
|
||||
totalSprites: number;
|
||||
activeIndex: number | undefined;
|
||||
|
|
@ -24,7 +27,7 @@ export const HoverScrubber: React.FC<IHoverScrubber> = ({
|
|||
let x = 0;
|
||||
if (e.nativeEvent instanceof MouseEvent) {
|
||||
x = e.nativeEvent.offsetX;
|
||||
} else if (e.nativeEvent instanceof TouchEvent) {
|
||||
} else if (touchEventDefined && e.nativeEvent instanceof TouchEvent) {
|
||||
x =
|
||||
e.nativeEvent.touches[0].clientX -
|
||||
e.currentTarget.getBoundingClientRect().x;
|
||||
|
|
@ -47,7 +50,8 @@ export const HoverScrubber: React.FC<IHoverScrubber> = ({
|
|||
|
||||
if (
|
||||
(e instanceof MouseEvent && relatedTarget !== e.target) ||
|
||||
(e instanceof TouchEvent &&
|
||||
(touchEventDefined &&
|
||||
e instanceof TouchEvent &&
|
||||
document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY))
|
||||
)
|
||||
return;
|
||||
|
|
@ -70,7 +74,8 @@ export const HoverScrubber: React.FC<IHoverScrubber> = ({
|
|||
|
||||
if (
|
||||
(e instanceof MouseEvent && relatedTarget !== e.target) ||
|
||||
(e instanceof TouchEvent &&
|
||||
(touchEventDefined &&
|
||||
e instanceof TouchEvent &&
|
||||
document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY))
|
||||
)
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue