update
This commit is contained in:
@@ -121,19 +121,63 @@ export function useEinstellungen() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function tastatur(e) {
|
async function umschalten() {
|
||||||
|
if (freigeschaltet.value) anzeige.value = !anzeige.value
|
||||||
|
// Ohne Host-Film kommt man so rein; lehnt der Server ab, gibt es einen
|
||||||
|
else if (!(await hostAnmelden(null))) hostLogin.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function tastatur(e) {
|
||||||
// e.code statt e.key: mit drei Zusatztasten liefert das Layout sonst
|
// e.code statt e.key: mit drei Zusatztasten liefert das Layout sonst
|
||||||
// je nach System ein anderes Zeichen
|
// je nach System ein anderes Zeichen
|
||||||
if (e.ctrlKey && e.shiftKey && e.altKey && e.code === 'KeyS') {
|
if (e.ctrlKey && e.shiftKey && e.altKey && e.code === 'KeyS') {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if (freigeschaltet.value) anzeige.value = !anzeige.value
|
umschalten()
|
||||||
// Ohne Host-Film kommt man so rein; lehnt der Server ab, gibt es einen
|
|
||||||
else if (!(await hostAnmelden(null))) hostLogin.value = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => window.addEventListener('keydown', tastatur))
|
// Am Handy gibt es keine Tastenkombination: fünf Sekunden mit einem
|
||||||
onUnmounted(() => window.removeEventListener('keydown', tastatur))
|
// Finger den Bildschirm halten tut dasselbe
|
||||||
|
const DRUCK_MS = 5000
|
||||||
|
let druck = null
|
||||||
|
let druckStart = null
|
||||||
|
|
||||||
|
function fingerAb() {
|
||||||
|
clearTimeout(druck)
|
||||||
|
druck = null
|
||||||
|
}
|
||||||
|
|
||||||
|
function fingerAuf(e) {
|
||||||
|
fingerAb()
|
||||||
|
if (e.touches.length !== 1) return
|
||||||
|
druckStart = { x: e.touches[0].clientX, y: e.touches[0].clientY }
|
||||||
|
druck = setTimeout(umschalten, DRUCK_MS)
|
||||||
|
}
|
||||||
|
|
||||||
|
function fingerBewegt(e) {
|
||||||
|
if (!druck) return
|
||||||
|
const t = e.touches[0]
|
||||||
|
// Ein bisschen Zittern ist kein Wischen
|
||||||
|
if (Math.hypot(t.clientX - druckStart.x, t.clientY - druckStart.y) > 15) fingerAb()
|
||||||
|
}
|
||||||
|
|
||||||
|
const finger = {
|
||||||
|
touchstart: fingerAuf,
|
||||||
|
touchmove: fingerBewegt,
|
||||||
|
touchend: fingerAb,
|
||||||
|
touchcancel: fingerAb,
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
window.addEventListener('keydown', tastatur)
|
||||||
|
for (const [ev, fn] of Object.entries(finger))
|
||||||
|
window.addEventListener(ev, fn, { passive: true })
|
||||||
|
})
|
||||||
|
onUnmounted(() => {
|
||||||
|
window.removeEventListener('keydown', tastatur)
|
||||||
|
for (const [ev, fn] of Object.entries(finger)) window.removeEventListener(ev, fn)
|
||||||
|
fingerAb()
|
||||||
|
})
|
||||||
|
|
||||||
return { ansicht, ohneGesehene, activeTab, quelle, suchArt, host, hostLogin, hostAnmelden }
|
return { ansicht, ohneGesehene, activeTab, quelle, suchArt, host, hostLogin, hostAnmelden }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user