pinafore/routes/_components/NonAutoplayGifv.html

64 lines
1.4 KiB
HTML
Raw Normal View History

2018-02-02 03:48:59 +01:00
<div class="non-autoplay-gifv" style="width: {{width}}px; height: {{height}}px;"
on:mouseover="onMouseOver(event)"
ref:node
>
{{#if playing}}
<video
2018-02-05 01:34:54 +01:00
style="background: url({{staticSrc}});"
2018-02-02 03:48:59 +01:00
class="{{class}}"
aria-label="{{label}}"
poster="{{poster}}"
src="{{src}}"
width="{{width}}"
height="{{height}}"
autoplay
muted
loop
playsinline
/>
{{else}}
2018-03-14 07:07:30 +01:00
<LazyImage
alt="{{label}}"
src="{{staticSrc}}"
fallback="{{oneTransparentPixel}}"
:width
:height
background="var(--loading-bg)"
className="{{class}}"
/>
2018-02-02 03:48:59 +01:00
{{/if}}
2018-03-10 20:28:30 +01:00
<PlayVideoIcon className="{{playing ? 'hidden' : ''}}"/>
2018-02-02 03:48:59 +01:00
</div>
<style>
.non-autoplay-gifv {
cursor: zoom-in;
2018-03-10 20:28:30 +01:00
position: relative;
}
:global(.non-autoplay-gifv .play-video-icon) {
transition: opacity 0.2s linear;
2018-02-02 03:48:59 +01:00
}
</style>
<script>
import { mouseover } from '../_utils/events'
2018-03-10 20:28:30 +01:00
import PlayVideoIcon from './PlayVideoIcon.html'
import { ONE_TRANSPARENT_PIXEL } from '../_static/media'
2018-03-14 07:07:30 +01:00
import LazyImage from './LazyImage.html'
2018-02-02 03:48:59 +01:00
export default {
methods: {
onMouseOver(mouseOver) {
this.set({playing: mouseOver})
}
},
events: {
2018-03-14 07:07:30 +01:00
mouseover
},
data: () => ({
oneTransparentPixel: ONE_TRANSPARENT_PIXEL
2018-03-10 20:28:30 +01:00
}),
components: {
2018-03-14 07:07:30 +01:00
PlayVideoIcon,
LazyImage
2018-03-10 20:28:30 +01:00
}
2018-02-02 03:48:59 +01:00
}
</script>