diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/dumbymap.mjs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index 63ba3ed..849303b 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs | |||
| @@ -285,7 +285,6 @@ export const generateMaps = async (container, callback) => { | |||
| 285 | }) | 285 | }) |
| 286 | // }}} | 286 | // }}} |
| 287 | // Layout {{{ | 287 | // Layout {{{ |
| 288 | |||
| 289 | // press key to switch layout | 288 | // press key to switch layout |
| 290 | const defaultLayout = layouts[0] | 289 | const defaultLayout = layouts[0] |
| 291 | container.setAttribute("data-layout", defaultLayout.name) | 290 | container.setAttribute("data-layout", defaultLayout.name) |
| @@ -346,15 +345,16 @@ export const generateMaps = async (container, callback) => { | |||
| 346 | const layoutObserver = new MutationObserver((mutations) => { | 345 | const layoutObserver = new MutationObserver((mutations) => { |
| 347 | const mutation = mutations.at(-1) | 346 | const mutation = mutations.at(-1) |
| 348 | const oldLayout = mutation.oldValue | 347 | const oldLayout = mutation.oldValue |
| 349 | const layout = container.getAttribute(mutation.attributeName) | 348 | const newLayout = container.getAttribute(mutation.attributeName) |
| 350 | 349 | ||
| 350 | // Apply handler for leaving/entering layouts | ||
| 351 | if (oldLayout) { | 351 | if (oldLayout) { |
| 352 | layouts.find(l => l.name === oldLayout) | 352 | layouts.find(l => l.name === oldLayout) |
| 353 | ?.leaveHandler | 353 | ?.leaveHandler |
| 354 | ?.call(this, dumbymap) | 354 | ?.call(this, dumbymap) |
| 355 | } | 355 | } |
| 356 | if (layout) { | 356 | if (newLayout) { |
| 357 | layouts.find(l => l.name === layout) | 357 | layouts.find(l => l.name === newLayout) |
| 358 | ?.enterHandler | 358 | ?.enterHandler |
| 359 | ?.call(this, dumbymap) | 359 | ?.call(this, dumbymap) |
| 360 | } | 360 | } |