LCOV - code coverage report
Current view: top level - src/renderer/core/layout/transform - TransformPane.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 17 17
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2          874 :   <div
       3              :     ref="transformPaneRef"
       4              :     data-testid="transform-pane"
       5              :     class="ph-no-capture pointer-events-none absolute inset-0 size-full will-change-auto"
       6              :   >
       7              :     <TooltipProvider
       8              :       :delay-duration="settingStore.get('LiteGraph.Node.TooltipDelay')"
       9              :       :skip-delay-duration="0"
      10              :     >
      11              :       <slot />
      12              :     </TooltipProvider>
      13              :   </div>
      14              : </template>
      15              : 
      16              : <script setup lang="ts">
      17              : import { computed, useTemplateRef, watch } from 'vue'
      18              : 
      19              : import TooltipProvider from '@comfyorg/design-system/tooltip/TooltipProvider'
      20              : import type { LGraphCanvas } from '@/lib/litegraph/src/litegraph'
      21              : import { useSettingStore } from '@/platform/settings/settingStore'
      22              : import { onCanvasFrame } from '@/lib/litegraph/src/canvas/canvasFrame'
      23              : import { useTransformSettling } from '@/renderer/core/layout/transform/useTransformSettling'
      24              : import { useTransformState } from '@/renderer/core/layout/transform/useTransformState'
      25              : 
      26              : interface TransformPaneProps {
      27              :   canvas?: LGraphCanvas
      28              : }
      29              : 
      30          874 : const props = defineProps<TransformPaneProps>()
      31              : 
      32          874 : const settingStore = useSettingStore()
      33              : 
      34          874 : const { transformStyle, syncWithCanvas } = useTransformState()
      35              : 
      36              : const canvasElement = computed(() => props.canvas?.canvas)
      37          874 : const { isTransforming: isInteracting } = useTransformSettling(canvasElement, {
      38              :   settleDelay: 256
      39              : })
      40              : 
      41          874 : const transformPaneRef = useTemplateRef('transformPaneRef')
      42              : 
      43              : /**
      44              :  * Apply transform style and will-change class via direct DOM mutation
      45              :  * instead of reactive template bindings (:style / :class).
      46              :  *
      47              :  * These values change every animation frame during zoom or pan.
      48              :  * If they were bound in the template, Vue would diff the entire
      49              :  * TransformPane vnode—including all child node slots—on every frame,
      50              :  * causing expensive vdom patch work across the full node list.
      51              :  * Mutating the DOM directly limits the update to a single element.
      52              :  */
      53              : 
      54          874 : watch([transformStyle, transformPaneRef], ([newStyle, el]) => {
      55         1802 :   if (el) {
      56         1795 :     Object.assign(el.style, newStyle)
      57              :   }
      58              : })
      59          874 : watch([isInteracting, transformPaneRef], ([interacting, el]) => {
      60          859 :   if (el) {
      61          859 :     el.classList.toggle('will-change-transform', interacting)
      62          859 :     el.classList.toggle('will-change-auto', !interacting)
      63              :   }
      64              : })
      65              : 
      66          874 : watch(
      67              :   () => props.canvas,
      68              :   (canvas, _, onCleanup) => {
      69          874 :     if (!canvas) return
      70          874 :     syncWithCanvas(canvas)
      71          874 :     onCleanup(onCanvasFrame(canvas, 'present', () => syncWithCanvas(canvas)))
      72              :   },
      73              :   { immediate: true }
      74              : )
      75              : </script>
        

Generated by: LCOV version 2.0-1