diff --git a/src/image/index.js b/src/image/index.js index 9e51555..97db2ed 100644 --- a/src/image/index.js +++ b/src/image/index.js @@ -7,6 +7,7 @@ import { css, html, Component, styleMap } from '@bd/core' import '../icon/index.js' import './preview.js' + class Image extends Component { static props = { src: '', @@ -23,7 +24,7 @@ class Image extends Component { attribute: false } } - status = 'loading' + static styles = css` :host { position: relative; @@ -47,6 +48,9 @@ class Image extends Component { align-items: center; } ` + + status = 'loading' + onError() { this.status = 'error' this.$refs.wrapper.removeChild(this.$refs.img) @@ -76,6 +80,7 @@ class Image extends Component { cursor: previewSrcList.length ? 'pointer' : 'default' }) let $slot = '' + if (status === 'loading') { $slot = html`` } else if (status === 'error') { @@ -83,6 +88,7 @@ class Image extends Component {
FAILED
` } + return html`
{ e.preventDefault() @@ -208,6 +213,7 @@ class ImagePreview extends Component { }) }) } + render() { let { scale, rotate, duration, x, y } = this.#state let styles = styleMap({