2018-08-23 04:00:53 +00:00
|
|
|
<img
|
|
|
|
class={computedClass}
|
|
|
|
aria-hidden={ariaHidden}
|
|
|
|
{alt}
|
|
|
|
{title}
|
|
|
|
{width}
|
|
|
|
{height}
|
|
|
|
src={displaySrc}
|
|
|
|
on:mouseover="onMouseOver(event)"
|
|
|
|
/>
|
2018-02-01 02:20:30 +00:00
|
|
|
<style>
|
|
|
|
.non-autoplay-zoom-in {
|
|
|
|
cursor: zoom-in;
|
|
|
|
}
|
2018-03-17 01:48:24 +00:00
|
|
|
.non-autoplay-zoom-in.is-link {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2018-02-01 02:20:30 +00:00
|
|
|
</style>
|
|
|
|
<script>
|
2018-08-23 04:00:53 +00:00
|
|
|
import { mouseover } from '../_utils/events'
|
|
|
|
import { decodeImage } from '../_utils/decodeImage'
|
|
|
|
import { ONE_TRANSPARENT_PIXEL } from '../_static/media'
|
|
|
|
import { classname } from '../_utils/classname'
|
|
|
|
|
2018-02-01 02:20:30 +00:00
|
|
|
export default {
|
2018-08-23 04:00:53 +00:00
|
|
|
async oncreate () {
|
|
|
|
let { staticSrc } = this.get()
|
|
|
|
try {
|
|
|
|
await decodeImage(staticSrc)
|
|
|
|
this.set({ displaySrc: staticSrc })
|
|
|
|
this.fire('imgLoad')
|
|
|
|
} catch (e) {
|
|
|
|
this.fire('imgLoadError', e)
|
|
|
|
}
|
|
|
|
},
|
2018-02-01 02:20:30 +00:00
|
|
|
methods: {
|
2018-04-20 04:38:01 +00:00
|
|
|
onMouseOver (mouseOver) {
|
2018-08-23 04:00:53 +00:00
|
|
|
let { src, staticSrc, displaySrc } = this.get()
|
|
|
|
if (displaySrc !== ONE_TRANSPARENT_PIXEL) {
|
|
|
|
this.set({ displaySrc: mouseOver ? src : staticSrc })
|
|
|
|
}
|
2018-02-01 02:20:30 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
events: {
|
|
|
|
mouseover
|
2018-08-23 04:00:53 +00:00
|
|
|
},
|
|
|
|
data: () => ({
|
|
|
|
displaySrc: ONE_TRANSPARENT_PIXEL,
|
|
|
|
alt: '',
|
|
|
|
title: ''
|
|
|
|
}),
|
|
|
|
computed: {
|
2018-08-30 04:42:57 +00:00
|
|
|
computedClass: ({ className, src, staticSrc, isLink }) => (classname(
|
2018-08-23 04:00:53 +00:00
|
|
|
className,
|
|
|
|
src !== staticSrc && 'non-autoplay-zoom-in',
|
|
|
|
isLink && 'is-link'
|
|
|
|
))
|
2018-02-01 02:20:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|