LCOV - code coverage report
Current view: top level - src/platform/workflow/templates/components/thumbnails - CompareSliderThumbnail.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 44.4 % 9 4
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2           81 :   <BaseThumbnail :is-hovered="isHovered">
       3              :     <LazyImage
       4              :       :src="baseImageSrc"
       5              :       :alt="alt"
       6              :       :image-class="
       7              :         isVideoType
       8              :           ? 'w-full h-full object-cover'
       9              :           : 'max-w-full max-h-64 object-contain'
      10              :       "
      11              :     />
      12              :     <div
      13              :       data-testid="compare-slider-container"
      14              :       class="absolute inset-0"
      15              :       @mousemove="updateSliderPosition"
      16              :     >
      17              :       <LazyImage
      18              :         :src="overlayImageSrc"
      19              :         :alt="alt"
      20              :         :image-class="
      21              :           isVideoType
      22              :             ? 'w-full h-full object-cover'
      23              :             : 'max-w-full max-h-64 object-contain'
      24              :         "
      25              :         :image-style="{
      26              :           clipPath: `inset(0 ${100 - sliderPosition}% 0 0)`
      27              :         }"
      28              :       />
      29              :       <div
      30              :         data-testid="compare-slider-divider"
      31              :         class="pointer-events-none absolute inset-y-0 z-10 w-0.5 bg-white/30 backdrop-blur-sm"
      32              :         :style="{
      33              :           left: `${sliderPosition}%`
      34              :         }"
      35              :       />
      36              :     </div>
      37              :   </BaseThumbnail>
      38              : </template>
      39              : 
      40              : <script setup lang="ts">
      41              : import { ref } from 'vue'
      42              : 
      43              : import LazyImage from '@/components/common/LazyImage.vue'
      44              : import BaseThumbnail from '@/platform/workflow/templates/components/thumbnails/BaseThumbnail.vue'
      45              : 
      46         2355 : const SLIDER_START_POSITION = 50
      47              : 
      48              : const { baseImageSrc, overlayImageSrc, isHovered, isVideo } = defineProps<{
      49              :   baseImageSrc: string
      50              :   overlayImageSrc: string
      51              :   alt: string
      52              :   isHovered?: boolean
      53              :   isVideo?: boolean
      54              : }>()
      55              : 
      56           81 : const isVideoType =
      57              :   isVideo ||
      58              :   baseImageSrc?.toLowerCase().endsWith('.webp') ||
      59              :   overlayImageSrc?.toLowerCase().endsWith('.webp') ||
      60              :   false
      61              : 
      62           81 : const sliderPosition = ref(SLIDER_START_POSITION)
      63              : 
      64              : /**
      65              :  * Update slider position from a local mousemove. Scoped to currentTarget so
      66              :  * only the hovered card reads its rect — unlike useMouseInElement which
      67              :  * attaches a global mousemove listener and fires for every mounted instance.
      68              :  */
      69            0 : function updateSliderPosition(event: MouseEvent) {
      70              :   const el = event.currentTarget as HTMLElement
      71            0 :   const rect = el.getBoundingClientRect()
      72            0 :   if (rect.width === 0) return
      73              :   // Clamp to [0, 100] — subpixel rounding or stale rects on hover-in can
      74              :   // push the raw percentage slightly out of range, which would offset the
      75              :   // divider past the container or invert the overlay's clipPath.
      76            0 :   const raw = ((event.clientX - rect.left) / rect.width) * 100
      77            0 :   sliderPosition.value = Math.max(0, Math.min(100, raw))
      78              : }
      79              : </script>
        

Generated by: LCOV version 2.0-1