mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 08:01:20 -08:00
refactor(core): CORE-17 type input events and own interaction lifetimes
This commit is contained in:
1 parent
88aef830df
commit
a842058136
72 files changed
+31156
-1219
No files matched your search
@@ -0,0 +1,16 @@
|
||||
export function slideDirection(startX: number, startY: number, endX: number, endY: number): 0 | 1 | 2 | 3 | 4 {
|
||||
const dy = startY - endY
|
||||
const dx = endX - startX
|
||||
if (Math.abs(dx) < 2 && Math.abs(dy) < 2)
|
||||
return 0
|
||||
const angle = Math.atan2(dy, dx) * 180 / Math.PI
|
||||
if (angle >= -45 && angle < 45)
|
||||
return 4
|
||||
if (angle >= 45 && angle < 135)
|
||||
return 1
|
||||
if (angle >= -135 && angle < -45)
|
||||
return 2
|
||||
if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135))
|
||||
return 3
|
||||
return 0
|
||||
}
|
||||
Reference in new issue
Block a user