refactor: event-emitter for pane lifecycle + detached/windowless glass overhaul#102
Merged
Conversation
Replace the onBeforePaneAdd/onPaneAdd/onBeforePaneRemove/onPaneRemove override hooks with an on/off/emit event system. A before-* listener vetoes by returning false; emit runs every listener and reports a veto if any returned false. Listeners are per-instance (Map of event name -> Set of listeners), fixing the cross-instance leak a shared emitter would have had.
Drop the onComplete callback; return animation.finished so callers chain .then() instead.
Rename the close-animation toggle on removeDetachedGlass and removeDetachedGlassElement (and removeWindowlessGlass) from animateClose to animate.
Convert removeDetachedGlass from an onComplete callback to a promise that resolves with the removed element (after the close animation, if any) or null when no glass matches the id. Update the close/attach actions to await it, the removeWindowlessGlass wrapper's JSDoc, and the manager tests.
Animate the modal backdrop's opacity on open and close so it transitions in sync with the glass instead of appearing/disappearing instantly.
Replace the per-element animate wrappers (animateDetachedGlassOpen/Close, animateGlassBackdropOpen) with a single animateElementByAttribute(element, attribute, onComplete) in src/animate.js, and call it directly at each site.
Defer the pot removal, bring-to-front, and restore emit until the open animation finishes, instead of firing them immediately on click.
When a modal windowless glass is opened with closeOnBackdropClick, clicking the backdrop dismisses the glass. Extracts removeWindowlessGlass to a module function so the click handler can call it without relying on `this`.
…erhaul Document action events, assembleStatic, the manager/crud animation split, windowless glass closeOnBackdropClick + backdrop transitions, and the shared animateElementByAttribute helper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch started as the pane-lifecycle event emitter (replacing the override hooks from #101) and grew to cover an action-event system and a detached/windowless-glass overhaul.
Event emitter (pane lifecycle)
src/frame/event.js— custom per-instance emitter (Mapof event name →Setof listeners, lazily created onthis). Replaces the WIPEventTargetapproach, which couldn't return listener values, had a brokenoff(), and shared one emitter across all instances.src/frame/pane.js—addPane/removePaneemitbefore-pane-add/pane-add/before-pane-remove/pane-remove; the four override stubs are removed.before-*listener vetoes by returningfalse;emitruns every listener and reports a veto if any returnedfalse(order-independent). Only an explicitfalsevetoes.src/frame/event.test.js— Vitest coverage (veto semantics, Set dedupe,off, per-instance isolation).onPane*override hooks are removed. Only the dev page consumed them;react-bwindoes not.Action events
Detached & windowless glass overhaul
detachedGlassManagerowns the full lifecycle (build + register + bring-to-front + open/close animation + backdrop teardown) for both in-window and windowless glasses.src/animate.jsanimateElementByAttribute(el, attr, onComplete)drives the[opening]/[closing]CSS animations; the per-element wrappers were removed and callers use it directly.bw-glass-backdropnow fades in/out in sync with the glass (CSS keyframes, ~0.28s).closeOnBackdropClick— newaddWindowlessGlassoption: clicking the modal backdrop dismisses the glass.Docs
docs/ARCHITECTURE.md— events (§7), API surface, and the windowless-glass/backdrop sections updated.