Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

fix(docs): restore source hover after carousel switch

rponeaf6d2dec089c
diff --git a/docs/.vitepress/theme/components/SemanticVideoDemo.vue b/docs/.vitepress/theme/components/SemanticVideoDemo.vue
index 2e8f7509..802411e9 100644
--- a/docs/.vitepress/theme/components/SemanticVideoDemo.vue
+++ b/docs/.vitepress/theme/components/SemanticVideoDemo.vue
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
import { goodBetterBestMedia, resolveDemoMedia } from "./demo-media";
+import { demoPointerIsInside } from "./demo-pointer";
import {
semanticVideoDemos,
type DemoId,
@@ -81,6 +82,7 @@ const visibleLogoCount = ref(0);
const audioEnabled = ref(false);
const sourceViewportRows = ref(27);
const sourceLineRows = ref<number[]>(sourceLines.map(() => 1));
+const sourcePanelElement = ref<HTMLElement | null>(null);
const codeScrollElement = ref<HTMLElement | null>(null);
const sourceMeasureElement = ref<HTMLElement | null>(null);
const playheadElement = ref<HTMLElement | null>(null);
@@ -494,9 +496,16 @@ function startPlayback() {
syncState(programTime, true);
syncBaseVideos(true);
syncOverlayVideos(true);
+ syncSourceHoverState();
animationFrame = requestAnimationFrame(renderFrame);
}
+function syncSourceHoverState() {
+ const sourceHovered = demoPointerIsInside(sourcePanelElement.value);
+ if (!sourceHovered) clearInspection();
+ sourceFollowEnabled.value = !sourceHovered;
+}
+
watch(
[() => displayedLines.value.map((entry) => entry.key).join("|"), sourceFollowEnabled, sourceSelections],
() => void nextTick().then(updateLayoutGeometry),
@@ -545,6 +554,7 @@ onBeforeUnmount(() => {
<div class="demo-shell real-demo-shell">
<div
+ ref="sourcePanelElement"
class="source-panel"
:class="{ 'source-following': sourceFollowEnabled }"
@pointermove="stopSourceFollow"
diff --git a/docs/.vitepress/theme/components/SvmlDemoCarousel.vue b/docs/.vitepress/theme/components/SvmlDemoCarousel.vue
index d63485e3..caa728ad 100644
--- a/docs/.vitepress/theme/components/SvmlDemoCarousel.vue
+++ b/docs/.vitepress/theme/components/SvmlDemoCarousel.vue
@@ -5,6 +5,7 @@ import {
preloadDemoMedia,
type DemoMediaManifest,
} from "./demo-media";
+import { clearDemoPointer, updateDemoPointer } from "./demo-pointer";
import SemanticVideoDemo from "./SemanticVideoDemo.vue";
import SvmlPlayground from "./SvmlPlayground.vue";
@@ -99,7 +100,12 @@ onBeforeUnmount(() => { activationId += 1; });
</script>
<template>
- <div class="svml-demo-carousel" :aria-busy="isLoading">
+ <div
+ class="svml-demo-carousel"
+ :aria-busy="isLoading"
+ @pointermove="updateDemoPointer"
+ @pointerleave="clearDemoPointer"
+ >
<header class="demo-heading carousel-heading">
<h2>悬停标记范围,查看对应画面</h2>
</header>
diff --git a/docs/.vitepress/theme/components/SvmlPlayground.vue b/docs/.vitepress/theme/components/SvmlPlayground.vue
index 29ee53a1..47326dc1 100644
--- a/docs/.vitepress/theme/components/SvmlPlayground.vue
+++ b/docs/.vitepress/theme/components/SvmlPlayground.vue
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
import { rankingMedia, resolveDemoMedia } from "./demo-media";
+import { demoPointerIsInside } from "./demo-pointer";
import { wordCues, type WordCue } from "./regen-ranking-cues";
import {
buildFoldedSourceView,
@@ -194,6 +195,7 @@ const sourceViewportRows = ref(27);
const sourceLineRows = ref<number[]>(lines.map(() => 1));
const audioEnabled = ref(false);
const stageElement = ref<HTMLElement | null>(null);
+const sourcePanelElement = ref<HTMLElement | null>(null);
const codeScrollElement = ref<HTMLElement | null>(null);
const sourceMeasureElement = ref<HTMLElement | null>(null);
const activeIconElement = ref<HTMLElement | null>(null);
@@ -716,9 +718,16 @@ function startPlayback() {
syncDiscreteState(programTime, true);
syncBaseVideos(true);
updateContinuousVisuals(programTime);
+ syncSourceHoverState();
animationFrame = requestAnimationFrame(renderFrame);
}
+function syncSourceHoverState() {
+ const sourceHovered = demoPointerIsInside(sourcePanelElement.value);
+ if (!sourceHovered) clearInspection();
+ sourceFollowEnabled.value = !sourceHovered;
+}
+
function updateSourceViewportRows() {
const container = codeScrollElement.value;
if (!container) return;
@@ -799,6 +808,7 @@ onBeforeUnmount(() => {
@mouseleave="clearInspection"
>
<div
+ ref="sourcePanelElement"
class="source-panel"
:class="{ 'source-following': sourceFollowEnabled }"
@pointermove="stopSourceFollow"
diff --git a/docs/.vitepress/theme/components/demo-pointer.ts b/docs/.vitepress/theme/components/demo-pointer.ts
new file mode 100644
index 00000000..bf99f740
--- /dev/null
+++ b/docs/.vitepress/theme/components/demo-pointer.ts
@@ -0,0 +1,20 @@
+let pointerX: number | null = null;
+let pointerY: number | null = null;
+
+export function updateDemoPointer(event: PointerEvent) {
+ pointerX = event.clientX;
+ pointerY = event.clientY;
+}
+
+export function clearDemoPointer() {
+ pointerX = null;
+ pointerY = null;
+}
+
+export function demoPointerIsInside(element: HTMLElement | null) {
+ if (!element) return false;
+ if (pointerX !== null && pointerY !== null) {
+ return element.contains(document.elementFromPoint(pointerX, pointerY));
+ }
+ return element.matches(":hover");
+}