Use lozad for lazy image loading
Ref: grouped-emoji-picker
This commit is contained in:
parent
90f757cc6d
commit
c70cdbb873
|
@ -35,6 +35,7 @@
|
||||||
"js-cookie": "3.0.1",
|
"js-cookie": "3.0.1",
|
||||||
"localforage": "1.10.0",
|
"localforage": "1.10.0",
|
||||||
"parse-link-header": "2.0.0",
|
"parse-link-header": "2.0.0",
|
||||||
|
"lozad": "^1.16.0",
|
||||||
"phoenix": "1.6.2",
|
"phoenix": "1.6.2",
|
||||||
"punycode.js": "2.1.0",
|
"punycode.js": "2.1.0",
|
||||||
"qrcode": "1.5.0",
|
"qrcode": "1.5.0",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { defineAsyncComponent } from 'vue'
|
import { defineAsyncComponent } from 'vue'
|
||||||
import Checkbox from '../checkbox/checkbox.vue'
|
import Checkbox from '../checkbox/checkbox.vue'
|
||||||
|
import LazyImageContainer from '../../directives/lazy_image_container'
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
faBoxOpen,
|
faBoxOpen,
|
||||||
|
@ -64,6 +65,9 @@ const EmojiPicker = {
|
||||||
StickerPicker: defineAsyncComponent(() => import('../sticker_picker/sticker_picker.vue')),
|
StickerPicker: defineAsyncComponent(() => import('../sticker_picker/sticker_picker.vue')),
|
||||||
Checkbox
|
Checkbox
|
||||||
},
|
},
|
||||||
|
directives: {
|
||||||
|
LazyImageContainer
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onStickerUploaded (e) {
|
onStickerUploaded (e) {
|
||||||
this.$emit('sticker-uploaded', e)
|
this.$emit('sticker-uploaded', e)
|
||||||
|
@ -184,7 +188,7 @@ const EmojiPicker = {
|
||||||
this.showingStickers = value
|
this.showingStickers = value
|
||||||
},
|
},
|
||||||
limitedEmojis (list, groupId) {
|
limitedEmojis (list, groupId) {
|
||||||
return list.slice(0, this.loadedCount[groupId])
|
return list // list.slice(0, this.loadedCount[groupId])
|
||||||
},
|
},
|
||||||
filterByKeyword (list, keyword) {
|
filterByKeyword (list, keyword) {
|
||||||
return filterByKeyword(list, keyword)
|
return filterByKeyword(list, keyword)
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
ref="emoji-groups"
|
ref="emoji-groups"
|
||||||
|
v-lazy-image-container
|
||||||
class="emoji-groups"
|
class="emoji-groups"
|
||||||
:class="groupsScrolledClass"
|
:class="groupsScrolledClass"
|
||||||
@scroll="onScroll"
|
@scroll="onScroll"
|
||||||
|
@ -87,7 +88,7 @@
|
||||||
<span v-if="!emoji.imageUrl">{{ emoji.replacement }}</span>
|
<span v-if="!emoji.imageUrl">{{ emoji.replacement }}</span>
|
||||||
<img
|
<img
|
||||||
v-else
|
v-else
|
||||||
:src="emoji.imageUrl"
|
:data-src="emoji.imageUrl"
|
||||||
>
|
>
|
||||||
</span>
|
</span>
|
||||||
<span :ref="'group-end-' + group.id" />
|
<span :ref="'group-end-' + group.id" />
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
import lozad from 'lozad'
|
||||||
|
|
||||||
|
const LazyImageContainer = {
|
||||||
|
inserted (el) {
|
||||||
|
const images = el.querySelectorAll('img')
|
||||||
|
console.log(images.length)
|
||||||
|
el.$observer = lozad(images)
|
||||||
|
el.$observer.observe()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LazyImageContainer
|
|
@ -5733,6 +5733,11 @@ lower-case@^2.0.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
tslib "^2.0.3"
|
tslib "^2.0.3"
|
||||||
|
|
||||||
|
lozad@^1.16.0:
|
||||||
|
version "1.16.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/lozad/-/lozad-1.16.0.tgz#86ce732c64c69926ccdebb81c8c90bb3735948b4"
|
||||||
|
integrity sha512-JBr9WjvEFeKoyim3svo/gsQPTkgG/mOHJmDctZ/+U9H3ymUuvEkqpn8bdQMFsvTMcyRJrdJkLv0bXqGm0sP72w==
|
||||||
|
|
||||||
lru-cache@^6.0.0:
|
lru-cache@^6.0.0:
|
||||||
version "6.0.0"
|
version "6.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
|
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
|
||||||
|
|
Loading…
Reference in New Issue