-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(browser): add browser iframe mouse interaction (#5815)
- Loading branch information
Showing
6 changed files
with
70 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { Ref } from 'vue' | ||
import { detailSizes } from '~/composables/navigation' | ||
|
||
type ResizingListener = (isResizing: boolean) => void | ||
|
||
const resizingListeners = new Set<ResizingListener>() | ||
|
||
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 useResizing(testerRef: Ref<HTMLDivElement | undefined>) { | ||
function onResizing(isResizing: boolean) { | ||
const tester = testerRef.value | ||
if (!tester) | ||
return | ||
|
||
tester.style.pointerEvents = isResizing ? 'none' : '' | ||
} | ||
|
||
onMounted(() => { | ||
resizingListeners.add(onResizing) | ||
}) | ||
|
||
onUnmounted(() => { | ||
resizingListeners.delete(onResizing) | ||
}) | ||
|
||
return { recalculateDetailPanels } | ||
} | ||
|
||
export function useNotifyResizing() { | ||
function notifyResizing(isResizing: boolean) { | ||
for (const listener of resizingListeners) | ||
listener(isResizing) | ||
} | ||
|
||
return { notifyResizing } | ||
} |
This file contains 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
This file contains 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