Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
AricGamma committed Mar 18, 2024
1 parent 1e47564 commit bfe531a
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 29 deletions.
Binary file added src/assets/img/framework.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/video/main_video.mp4
Binary file not shown.
46 changes: 46 additions & 0 deletions src/directives/video-lazy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

const videos = new Map<HTMLVideoElement, DOMRect>();


function playOrPause(video: HTMLVideoElement) {
const { top, bottom } = video.getBoundingClientRect();
if (bottom < 0 || top > window.innerHeight) {
video.pause();
} else {
video.play();
}
}

const onscroll = (evt: Event) => {
for (const video of videos.keys()) {
playOrPause(video);
}
};

export default {
name: 'lazy',
option: {
mounted: (el: HTMLElement) => {
if (el instanceof HTMLVideoElement) {
videos.set(el, el.getBoundingClientRect());
el.oncanplay = () => {
videos.set(el, el.getBoundingClientRect());
playOrPause(el);
}
}
if (videos.size) {
!window.onscroll && (window.onscroll = onscroll);
}
},
unmounted: (el: HTMLElement) => {
if (el instanceof HTMLVideoElement) {
videos.delete(el);
}
if (!videos.size) {
window.onscroll = null;
}
},
}
}


5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker'
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker'
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
;(self as any).MonacoEnvironment = {
;import videoLazy from './directives/video-lazy'
(self as any).MonacoEnvironment = {
getWorker(_: any, label: string) {
if (label === 'json') {
return new jsonWorker()
Expand All @@ -31,4 +32,6 @@ const app = createApp(App)

app.use(router)

app.directive(videoLazy.name, videoLazy.option);

app.mount('#app')
53 changes: 26 additions & 27 deletions src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ const bibTex = ref(`@inproceedings{xu2023magicanimate,

<br>
<div class="main_video">
<video src="https://box.nju.edu.cn/seafhttp/files/92d85d35-e7ba-4b54-99c6-1dd52cf8966f/main_video.mp4" autoplay
muted loop controls></video>
<video v-lazy src="@/assets/video/main_video.mp4" muted loop controls></video>
</div>

<br>
Expand All @@ -85,56 +84,56 @@ const bibTex = ref(`@inproceedings{xu2023magicanimate,
<br>
<h3>Animate Human Image</h3>
<div class="grid">
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
</div>

<br>
<h3>Comparsions</h3>
<div class="grid">
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
</div>

<br>
<h3>Cross ID</h3>
<div class="panel">
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
</div>

<br>
<h3>Unseen domain</h3>
<div class="grid">
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
</div>

<br>
<h3>Combining with T2I</h3>
<div class="grid">
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" autoplay muted loop></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
<video v-lazy src="https://showlab.github.io/magicanimate/assets/teaser/t1.mp4" muted loop controls></video>
</div>

<br>
<br>
<h3>Pipeline</h3>
<h3>Framework</h3>
<div class="panel">
<img src="https://box.nju.edu.cn/seafhttp/files/1e6d3b00-c696-4bb6-8600-ffe3c5edfb5e/framework.jpg">
<img src="@/assets/img/framework.jpg">
</div>

<br>
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"esModuleInterop": true,
}
}

0 comments on commit bfe531a

Please sign in to comment.