removed common method loadImage into mixin
This commit is contained in:
parent
a6eea72045
commit
53330304c7
|
@ -31,11 +31,13 @@
|
|||
|
||||
<script>
|
||||
import ThumbNav from '@/components/ThumbNav'
|
||||
import imageLoader from '~/mixins/imageLoader.js'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ThumbNav
|
||||
},
|
||||
mixins: [ imageLoader ],
|
||||
props: {
|
||||
isVisible: {
|
||||
type: Boolean,
|
||||
|
@ -105,18 +107,6 @@ export default {
|
|||
})
|
||||
// TODO catch errors
|
||||
},
|
||||
loadImage(url) {
|
||||
return new Promise( (resolve, reject) => {
|
||||
const img = new Image()
|
||||
|
||||
img.addEventListener('load', e => resolve(img));
|
||||
img.addEventListener('error', () => {
|
||||
reject(new Error(`Failed to load image URL: ${url}`));
|
||||
});
|
||||
|
||||
img.src = url;
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
export default {
|
||||
methods: {
|
||||
loadImage(url) {
|
||||
return new Promise( (resolve, reject) => {
|
||||
const img = new Image()
|
||||
|
||||
img.addEventListener('load', e => resolve(img));
|
||||
img.addEventListener('error', () => {
|
||||
reject(new Error(`Failed to load image URL: ${url}`));
|
||||
});
|
||||
|
||||
img.src = url;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue