Skip to content

Commit

Permalink
Add poster images and set preload to none for videos (#60)
Browse files Browse the repository at this point in the history
* dd poster images and set preload to none for videos

* Missed one

* Add width and height to videos

* Retake images

* Retake as PNGs using export Node

* Add controls back
  • Loading branch information
tunetheweb authored Dec 5, 2024
1 parent 9164cd6 commit 62b89eb
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 8 deletions.
Binary file added public/video/anchoring.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/video/cross-document-view-transitions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/video/field-sizing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/video/paint-order.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/video/snap-change.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/video/snap-changing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions src/components/video.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ interface Props {
src: string;
width?: number;
height?: number;
poster?: string;
preload?: string;
}
const { src, width = 720, height = 480 } = Astro.props;
const { src, width = 720, height = 480, poster = "", preload = "metadata" } = Astro.props;
---

<video
Expand All @@ -16,7 +18,10 @@ const { src, width = 720, height = 480 } = Astro.props;
muted
loop
playsinline
preload="metadata">
preload={preload}
poster={poster}
onmouseenter="event.target.setAttribute('preload','metadata')"
style=`aspect-ratio: ${width} / ${height};`>
Your browser does not support video
</video>

Expand Down
2 changes: 1 addition & 1 deletion src/features/components/anchor-positioning.astro
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const slug = slugify(title);

<p>The <code>position-area</code> property offers all sorts of options! The demo uses the logical property value <code>block-end</code>, but there's <code>center</code >, <code>button</code>, and tons more. Una made a GUI to help you visualize the options:</p>

<Video src="./video/anchoring.mp4" />
<Video src="./video/anchoring.mp4" width={1280} height={720} poster="./video/anchoring.png" preload="none" />

<div class="resources">
<p>
Expand Down
2 changes: 1 addition & 1 deletion src/features/components/field-sizing.astro
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const slug = slugify(title);
and <code>input</code> can now shrink to fit the size of the placeholder or
content value.
</p>
<Video src="./video/field-sizing.mp4" />
<Video src="./video/field-sizing.mp4" width={1242} height={698} poster="./video/field-sizing.png" preload="none" />
<p>
The following demo offers a side by side comparison of how inputs behave
without <code>field-sizing</code> and with <code>field-sizing</code>.
Expand Down
2 changes: 1 addition & 1 deletion src/features/developerexperience/paint-order.astro
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const slug = slugify(title);

<p>The following video shows how the result of the text stroke is undesirable if the text is filled white and then given a black stroke. Switch those around, so the stroke is drawn first and then filled, and the result is quite nice!</p>

<Video src="./video/paint-order.mp4" />
<Video src="./video/paint-order.mp4" width={1470} height={828} poster="./video/paint-order.png" preload="none" />

<p>The CSS to control this is one line. Set the <code>paint-order</code> to draw the stroke before the fill by specifying those keywords in that order.</p>

Expand Down
4 changes: 2 additions & 2 deletions src/features/interactions/scroll-snap-events.astro
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const slug = slugify(title);
<p>The <code>scrollsnapchange</code> event fires at a similar moment as <a href="https://developer.chrome.com/blog/scrollend-a-new-javascript-event"><code>scrollend</code></a>, when scroll has rested and the user has stopped
interacting with the scroller.</p>

<Video src="./video/snap-change.mp4" />
<Video src="./video/snap-change.mp4" width={1920} height={1082} poster="./video/snap-change.png" preload="none" />

<p>The <code>scrollsnapchanging</code>event is eager to fire, and calls the callback the moment the scroller has a new snap target. This is useful for instant UX feedback, providing a mechanism for immediate visual updates based on the user's interaction.</p>

<Video src="./video/snap-changing.mp4" />
<Video src="./video/snap-changing.mp4" width={1920} height={1082} poster="./video/snap-changing.png" preload="none" />

<Code lang="js" theme="css-variables" code={`scroller.addEventListener('scrollsnapchanging', event=> {
console.log(event.snapTargetBlock);
Expand Down
2 changes: 1 addition & 1 deletion src/features/interactions/view-transitions-mpa.astro
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const slug = slugify(title);
</p>

<figure>
<Video src="./video/cross-document-view-transitions.mp4" />
<Video src="./video/cross-document-view-transitions.mp4" width={2160} height={1216} poster="./video/cross-document-view-transitions.png" preload="none" />
<figcaption>
Recording of the <a href="https://view-transitions.chrome.dev/stack-navigator/mpa/">“Stack Navigator” demo that uses cross-document view transitions</a>
</figcaption>
Expand Down

0 comments on commit 62b89eb

Please sign in to comment.