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): use tap interaction on touch screens

rpone13728d8e1326
diff --git a/docs/.vitepress/theme/components/SemanticVideoDemo.vue b/docs/.vitepress/theme/components/SemanticVideoDemo.vue
index da94a0e7..745890d5 100644
--- a/docs/.vitepress/theme/components/SemanticVideoDemo.vue
+++ b/docs/.vitepress/theme/components/SemanticVideoDemo.vue
@@ -9,6 +9,7 @@ import {
import { goodBetterBestMedia, resolveDemoMedia } from "./demo-media";
import { demoPointerIsInside } from "./demo-pointer";
import { wordAtTime } from "./demo-word-timing";
+import { useSourcePanelInteraction } from "./source-panel-interaction";
import {
semanticVideoDemos,
type DemoId,
@@ -520,11 +521,28 @@ function startPlayback() {
}
function syncSourceHoverState() {
+ if (!sourceUsesHover.value) {
+ resumeSourceFollow();
+ return;
+ }
const sourceHovered = demoPointerIsInside(sourcePanelElement.value);
if (!sourceHovered) clearInspection();
sourceFollowEnabled.value = !sourceHovered;
}
+const {
+ sourceUsesHover,
+ handleSourcePointerMove,
+ handleSourcePointerDown,
+ handleSourceClick,
+ handleSourceWheel,
+ handleSourcePointerLeave,
+} = useSourcePanelInteraction(sourcePanelElement, {
+ active: () => props.active,
+ expand: stopSourceFollow,
+ collapse: resumeSourceFollow,
+});
+
watch(
[() => displayedLines.value.map((entry) => entry.key).join("|"), sourceFollowEnabled, sourceSelections],
() => void nextTick().then(updateLayoutGeometry),
@@ -569,7 +587,7 @@ onBeforeUnmount(() => {
<template>
<section class="svml-demo semantic-video-demo" aria-label="SVML 交互式实时渲染预览">
<header v-if="props.showHeading" class="demo-heading">
- <h2>悬停标记范围,查看对应画面</h2>
+ <h2><span class="hover-interaction-copy">悬停标记范围,查看对应画面</span><span class="touch-interaction-copy">点击标记范围,查看对应画面</span></h2>
</header>
<div class="demo-shell real-demo-shell">
@@ -577,10 +595,11 @@ onBeforeUnmount(() => {
ref="sourcePanelElement"
class="source-panel"
:class="{ 'source-following': sourceFollowEnabled }"
- @pointermove="stopSourceFollow"
- @pointerdown="stopSourceFollow"
- @wheel="stopSourceFollow"
- @pointerleave="resumeSourceFollow"
+ @pointermove="handleSourcePointerMove"
+ @pointerdown="handleSourcePointerDown"
+ @click="handleSourceClick"
+ @wheel="handleSourceWheel"
+ @pointerleave="handleSourcePointerLeave"
>
<div ref="sourceMeasureElement" class="source-measure" aria-hidden="true">
<div
@@ -594,7 +613,9 @@ onBeforeUnmount(() => {
</div>
</div>
<div class="source-follow-hint">
- {{ sourceFollowEnabled ? "移入查看所有源码" : "移出查看精简视图" }}
+ {{ sourceUsesHover
+ ? (sourceFollowEnabled ? "移入查看所有源码" : "移出查看精简视图")
+ : (sourceFollowEnabled ? "点击代码查看所有源码" : "点击空白处返回精简视图") }}
</div>
<div ref="codeScrollElement" class="code-scroll" aria-label="SVML source code">
<svg
diff --git a/docs/.vitepress/theme/components/SvmlDemoCarousel.vue b/docs/.vitepress/theme/components/SvmlDemoCarousel.vue
index 4e4f8daa..8d19ca6f 100644
--- a/docs/.vitepress/theme/components/SvmlDemoCarousel.vue
+++ b/docs/.vitepress/theme/components/SvmlDemoCarousel.vue
@@ -132,7 +132,7 @@ onBeforeUnmount(() => { activationId += 1; });
@pointerleave="clearDemoPointer"
>
<header class="demo-heading carousel-heading">
- <h2>悬停标记范围,查看对应画面</h2>
+ <h2><span class="hover-interaction-copy">悬停标记范围,查看对应画面</span><span class="touch-interaction-copy">点击标记范围,查看对应画面</span></h2>
</header>
<div class="demo-carousel-stage">
diff --git a/docs/.vitepress/theme/components/SvmlPlayground.vue b/docs/.vitepress/theme/components/SvmlPlayground.vue
index 5f2246de..de6c2f4b 100644
--- a/docs/.vitepress/theme/components/SvmlPlayground.vue
+++ b/docs/.vitepress/theme/components/SvmlPlayground.vue
@@ -11,6 +11,7 @@ import { demoPointerIsInside } from "./demo-pointer";
import { createDemoTimeline } from "./demo-timeline";
import { wordAtTime } from "./demo-word-timing";
import { wordCues as rawWordCues, type WordCue } from "./regen-ranking-cues";
+import { useSourcePanelInteraction } from "./source-panel-interaction";
import {
buildFoldedSourceView,
buildFullSourceView,
@@ -666,10 +667,15 @@ function resumeSourceFollow() {
}
function handleDemoPointerMove(event: PointerEvent) {
+ if (!sourceUsesHover.value) return;
const target = event.target instanceof Element ? event.target : null;
if (!target?.closest(".source-panel")) resumeSourceFollow();
}
+function handleDemoPointerLeave() {
+ if (sourceUsesHover.value) clearInspection();
+}
+
function renderFrame(timestamp: number) {
if (!props.active) {
animationFrame = 0;
@@ -727,11 +733,28 @@ function startPlayback() {
}
function syncSourceHoverState() {
+ if (!sourceUsesHover.value) {
+ resumeSourceFollow();
+ return;
+ }
const sourceHovered = demoPointerIsInside(sourcePanelElement.value);
if (!sourceHovered) clearInspection();
sourceFollowEnabled.value = !sourceHovered;
}
+const {
+ sourceUsesHover,
+ handleSourcePointerMove,
+ handleSourcePointerDown,
+ handleSourceClick,
+ handleSourceWheel,
+ handleSourcePointerLeave,
+} = useSourcePanelInteraction(sourcePanelElement, {
+ active: () => props.active,
+ expand: stopSourceFollow,
+ collapse: resumeSourceFollow,
+});
+
function updateSourceViewportRows() {
const container = codeScrollElement.value;
if (!container) return;
@@ -804,22 +827,23 @@ onBeforeUnmount(() => {
<template>
<section class="svml-demo" aria-label="SVML 交互式实时渲染预览">
<header v-if="props.showHeading" class="demo-heading">
- <h2>悬停标记范围,查看对应画面</h2>
+ <h2><span class="hover-interaction-copy">悬停标记范围,查看对应画面</span><span class="touch-interaction-copy">点击标记范围,查看对应画面</span></h2>
</header>
<div
class="demo-shell real-demo-shell"
@pointermove="handleDemoPointerMove"
- @mouseleave="clearInspection"
+ @mouseleave="handleDemoPointerLeave"
>
<div
ref="sourcePanelElement"
class="source-panel"
:class="{ 'source-following': sourceFollowEnabled }"
- @pointermove="stopSourceFollow"
- @pointerdown="stopSourceFollow"
- @wheel="stopSourceFollow"
- @pointerleave="resumeSourceFollow"
+ @pointermove="handleSourcePointerMove"
+ @pointerdown="handleSourcePointerDown"
+ @click="handleSourceClick"
+ @wheel="handleSourceWheel"
+ @pointerleave="handleSourcePointerLeave"
>
<div ref="sourceMeasureElement" class="source-measure" aria-hidden="true">
<div
@@ -833,7 +857,9 @@ onBeforeUnmount(() => {
</div>
</div>
<div class="source-follow-hint">
- {{ sourceFollowEnabled ? "移入查看所有源码" : "移出查看精简视图" }}
+ {{ sourceUsesHover
+ ? (sourceFollowEnabled ? "移入查看所有源码" : "移出查看精简视图")
+ : (sourceFollowEnabled ? "点击代码查看所有源码" : "点击空白处返回精简视图") }}
</div>
<div ref="codeScrollElement" class="code-scroll" aria-label="SVML source code">
<svg
diff --git a/docs/.vitepress/theme/components/source-panel-interaction.ts b/docs/.vitepress/theme/components/source-panel-interaction.ts
new file mode 100644
index 00000000..47495dd7
--- /dev/null
+++ b/docs/.vitepress/theme/components/source-panel-interaction.ts
@@ -0,0 +1,68 @@
+import { onBeforeUnmount, onMounted, ref, type Ref } from "vue";
+
+type SourcePanelInteractionOptions = {
+ active?: () => boolean;
+ expand: (event?: MouseEvent) => void;
+ collapse: () => void;
+};
+
+export function useSourcePanelInteraction(
+ panel: Ref<HTMLElement | null>,
+ options: SourcePanelInteractionOptions,
+) {
+ const sourceUsesHover = ref(true);
+ let hoverQuery: MediaQueryList | null = null;
+
+ function syncPointerMode() {
+ sourceUsesHover.value = hoverQuery?.matches ?? true;
+ if (!sourceUsesHover.value) options.collapse();
+ }
+
+ function handleSourcePointerMove(event: PointerEvent) {
+ if (sourceUsesHover.value) options.expand(event);
+ }
+
+ function handleSourcePointerDown(event: PointerEvent) {
+ if (sourceUsesHover.value) options.expand(event);
+ }
+
+ function handleSourceClick(event: MouseEvent) {
+ if (!sourceUsesHover.value) options.expand(event);
+ }
+
+ function handleSourceWheel(event: WheelEvent) {
+ if (sourceUsesHover.value) options.expand(event);
+ }
+
+ function handleSourcePointerLeave() {
+ if (sourceUsesHover.value) options.collapse();
+ }
+
+ function handleOutsidePointerDown(event: PointerEvent) {
+ if (sourceUsesHover.value || options.active?.() === false) return;
+ const target = event.target;
+ if (target instanceof Node && panel.value?.contains(target)) return;
+ options.collapse();
+ }
+
+ onMounted(() => {
+ hoverQuery = window.matchMedia("(hover: hover) and (pointer: fine)");
+ syncPointerMode();
+ hoverQuery.addEventListener("change", syncPointerMode);
+ document.addEventListener("pointerdown", handleOutsidePointerDown, true);
+ });
+
+ onBeforeUnmount(() => {
+ hoverQuery?.removeEventListener("change", syncPointerMode);
+ document.removeEventListener("pointerdown", handleOutsidePointerDown, true);
+ });
+
+ return {
+ sourceUsesHover,
+ handleSourcePointerMove,
+ handleSourcePointerDown,
+ handleSourceClick,
+ handleSourceWheel,
+ handleSourcePointerLeave,
+ };
+}
diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css
index 3709bc70..50eecdb3 100644
--- a/docs/.vitepress/theme/style.css
+++ b/docs/.vitepress/theme/style.css
@@ -119,6 +119,7 @@ body { letter-spacing: -0.012em; }
.svml-demo { width: 100%; margin: 16px auto 0; }
.demo-heading { margin: 0 0 24px; }
.demo-heading h2 { margin: 0; border: 0; padding: 0; font-size: clamp(26px, 3vw, 40px); letter-spacing: -.045em; }
+.touch-interaction-copy { display: none; }
.eyebrow { font-family: var(--vp-font-family-mono); color: #ec4899; font-size: 11px; letter-spacing: .16em; }
.demo-shell { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); min-height: 670px; overflow: hidden; border: 1px solid #262626; border-radius: 16px; background: #0a0a0a; }
.source-panel, .preview-panel { min-width: 0; }
@@ -302,6 +303,11 @@ body { letter-spacing: -0.012em; }
.feature-strip article + article { border-top: 1px solid rgba(255,255,255,.12); border-left: 0; }
}
+@media (hover: none), (pointer: coarse) {
+ .hover-interaction-copy { display: none; }
+ .touch-interaction-copy { display: inline; }
+}
+
@media (max-width: 520px) {
.VPHome .VPHomeHero .container, .VPHome .vp-doc.container { padding-inline: 16px; }
.VPHome .vp-doc.container { width: 100%; }