mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-07 18:47:44 +08:00
fix: fix incorrect animation start position on mobile theme toggle
- Unified coordinate handling for mouse and touch events to ensure the animation start point accurately follows the finger position on mobile devices.
This commit is contained in:
@@ -28,7 +28,9 @@ function apply(mode) {
|
|||||||
// 更新 meta 标签
|
// 更新 meta 标签
|
||||||
const androidMeta = document.querySelector('meta[name="theme-color"]')
|
const androidMeta = document.querySelector('meta[name="theme-color"]')
|
||||||
const iosMeta = document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]')
|
const iosMeta = document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]')
|
||||||
const themeColor = getComputedStyle(document.documentElement).getPropertyValue('--background-color').trim();
|
const themeColor = getComputedStyle(document.documentElement)
|
||||||
|
.getPropertyValue('--background-color')
|
||||||
|
.trim()
|
||||||
const themeStatus = newMode === 'dark' ? 'black-translucent' : 'default'
|
const themeStatus = newMode === 'dark' ? 'black-translucent' : 'default'
|
||||||
|
|
||||||
if (androidMeta) {
|
if (androidMeta) {
|
||||||
@@ -69,8 +71,19 @@ export function setTheme(mode) {
|
|||||||
|
|
||||||
function getCircle(event) {
|
function getCircle(event) {
|
||||||
if (!import.meta.client) return undefined
|
if (!import.meta.client) return undefined
|
||||||
const x = event.clientX
|
|
||||||
const y = event.clientY
|
let x, y
|
||||||
|
if (event.touches?.length) {
|
||||||
|
x = event.touches[0].clientX
|
||||||
|
y = event.touches[0].clientY
|
||||||
|
} else if (event.changedTouches?.length) {
|
||||||
|
x = event.changedTouches[0].clientX
|
||||||
|
y = event.changedTouches[0].clientY
|
||||||
|
} else {
|
||||||
|
x = event.clientX
|
||||||
|
y = event.clientY
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
|
|||||||
Reference in New Issue
Block a user