-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(browser): add browser iframe mouse interaction #5815
Changes from 3 commits
c9296bf
d8289fd
690d88c
0da26c4
af9480b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { detailSizes } from '~/composables/navigation' | ||
|
||
export type ResizingListener = (isResizing: boolean) => void | ||
|
||
const resizingSymbol = Symbol.for('resizing') | ||
|
||
export function recalculateDetailPanels() { | ||
const iframe = document.querySelector('#tester-ui iframe[data-vitest]')! | ||
const panel = document.querySelector('#details-splitpanes')! | ||
const panelWidth = panel.clientWidth | ||
const iframeWidth = iframe.clientWidth | ||
const iframePercent = Math.min((iframeWidth / panelWidth) * 100, 95) | ||
const detailsPercent = 100 - iframePercent | ||
detailSizes.value = [iframePercent, detailsPercent] | ||
} | ||
|
||
export function registerResizingListener(listener: ResizingListener) { | ||
inject<(listener: ResizingListener) => void>(resizingSymbol)?.(listener) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't this just a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm going to configure it globally (like navigation conposable), vitest ui is just a spa, dont need inject/provide There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This listener is the callback called from the index.vue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean the type is repeated, you already defined it on the top |
||
} | ||
|
||
export function provideResizing() { | ||
const listeners = new Set<ResizingListener>() | ||
|
||
function addResizeListener(listener: ResizingListener) { | ||
listeners.add(listener) | ||
} | ||
|
||
function notifyResizing(isResizing: boolean) { | ||
for (const listener of listeners) | ||
listener(isResizing) | ||
} | ||
|
||
provide(resizingSymbol, addResizeListener) | ||
|
||
return { notifyResizing } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably move that to line 190