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-08-31 23:35:26 +00:00
|
|
|
ref:node
|
2018-08-23 04:00:53 +00:00
|
|
|
/>
|
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 { classname } from '../_utils/classname'
|
|
|
|
|
2018-02-01 02:20:30 +00:00
|
|
|
export default {
|
2018-08-23 04:00:53 +00:00
|
|
|
async oncreate () {
|
|
|
|
try {
|
2018-08-31 23:35:26 +00:00
|
|
|
await decodeImage(this.refs.node)
|
2018-08-23 04:00:53 +00:00
|
|
|
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-31 23:35:26 +00:00
|
|
|
this.set({ mouseOver })
|
2018-02-01 02:20:30 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
events: {
|
|
|
|
mouseover
|
2018-08-23 04:00:53 +00:00
|
|
|
},
|
|
|
|
data: () => ({
|
|
|
|
alt: '',
|
2018-08-31 23:35:26 +00:00
|
|
|
title: '',
|
|
|
|
mouseOver: false
|
2018-08-23 04:00:53 +00:00
|
|
|
}),
|
|
|
|
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-08-31 23:35:26 +00:00
|
|
|
)),
|
|
|
|
displaySrc: ({ src, staticSrc, mouseOver }) => (mouseOver ? src : staticSrc)
|
2018-02-01 02:20:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|