update
This commit is contained in:
@@ -15,9 +15,20 @@ const props = defineProps({
|
||||
fortschritt: { type: Object, default: () => ({ total: 0, absolviert: 0, verstanden: 0, gemeistert: 0 }) },
|
||||
})
|
||||
|
||||
import { computed } from 'vue'
|
||||
import { computed, onMounted, onUnmounted } from 'vue'
|
||||
|
||||
defineEmits(['close', 'prev', 'next', 'statusChanged'])
|
||||
const emit = defineEmits(['close', 'prev', 'next', 'statusChanged'])
|
||||
|
||||
// ←/→ blättern zum vorigen/nächsten Baustein — außer beim Tippen in Feldern.
|
||||
function onKey(e) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey) return
|
||||
const el = document.activeElement
|
||||
if (el && (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.isContentEditable)) return
|
||||
if (e.key === 'ArrowLeft' && props.hasPrev) { e.preventDefault(); emit('prev') }
|
||||
else if (e.key === 'ArrowRight' && props.hasNext) { e.preventDefault(); emit('next') }
|
||||
}
|
||||
onMounted(() => window.addEventListener('keydown', onKey))
|
||||
onUnmounted(() => window.removeEventListener('keydown', onKey))
|
||||
|
||||
const pct = (n) => (100 * n / (props.fortschritt.total || 1)) + '%'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user