nanka iroiro

This commit is contained in:
syuilo
2020-02-08 23:52:40 +09:00
parent 78c2535c3c
commit 2f6b0b142a
5 changed files with 213 additions and 232 deletions

View File

@ -0,0 +1,23 @@
export function focusPrev(el: Element | null, self = false) {
if (el == null) return;
if (!self) el = el.previousElementSibling;
if (el) {
if (el.hasAttribute('tabindex')) {
(el as HTMLElement).focus();
} else {
focusPrev(el.previousElementSibling, true);
}
}
}
export function focusNext(el: Element | null, self = false) {
if (el == null) return;
if (!self) el = el.nextElementSibling;
if (el) {
if (el.hasAttribute('tabindex')) {
(el as HTMLElement).focus();
} else {
focusPrev(el.nextElementSibling, true);
}
}
}