Remove lozad code

This commit is contained in:
tusooa 2022-12-24 12:43:30 -05:00
parent 3e8aa0a398
commit 78081836df
No known key found for this signature in database
GPG Key ID: 7B467EDE43A08224
4 changed files with 5 additions and 43 deletions

View File

@ -3,7 +3,6 @@ import Checkbox from '../checkbox/checkbox.vue'
import Popover from 'src/components/popover/popover.vue' import Popover from 'src/components/popover/popover.vue'
import StillImage from '../still-image/still-image.vue' import StillImage from '../still-image/still-image.vue'
import { ensureFinalFallback } from '../../i18n/languages.js' import { ensureFinalFallback } from '../../i18n/languages.js'
import lozad from 'lozad'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
import { import {
faBoxOpen, faBoxOpen,
@ -125,9 +124,6 @@ const EmojiPicker = {
setGroupRef (name) { setGroupRef (name) {
return el => { this.groupRefs[name] = el } return el => { this.groupRefs[name] = el }
}, },
setEmojiRef (name) {
return el => { this.emojiRefs[name] = el }
},
onPopoverShown () { onPopoverShown () {
this.$emit('show') this.$emit('show')
}, },
@ -208,43 +204,12 @@ const EmojiPicker = {
filterByKeyword (list, keyword) { filterByKeyword (list, keyword) {
return filterByKeyword(list, keyword, this.languages, this.maybeLocalizedEmojiName) return filterByKeyword(list, keyword, this.languages, this.maybeLocalizedEmojiName)
}, },
initializeLazyLoad () {
this.destroyLazyLoad()
this.$nextTick(() => {
this.$lozad = lozad('.still-image.emoji-picker-emoji', {
load: el => {
const name = el.getAttribute('data-emoji-name')
const vn = this.emojiRefs[name]
if (!vn) {
return
}
vn.loadLazy()
}
})
this.$lozad.observe()
})
},
waitForDomAndInitializeLazyLoad () {
this.$nextTick(() => this.initializeLazyLoad())
},
destroyLazyLoad () {
if (this.$lozad) {
if (this.$lozad.observer) {
this.$lozad.observer.disconnect()
}
if (this.$lozad.mutationObserver) {
this.$lozad.mutationObserver.disconnect()
}
}
},
onShowing () { onShowing () {
const oldContentLoaded = this.contentLoaded const oldContentLoaded = this.contentLoaded
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.search.focus() this.$refs.search.focus()
}) })
this.contentLoaded = true this.contentLoaded = true
this.waitForDomAndInitializeLazyLoad()
this.filteredEmojiGroups = this.getFilteredEmojiGroups() this.filteredEmojiGroups = this.getFilteredEmojiGroups()
if (!oldContentLoaded) { if (!oldContentLoaded) {
this.$nextTick(() => { this.$nextTick(() => {
@ -269,13 +234,9 @@ const EmojiPicker = {
this.debouncedHandleKeywordChange() this.debouncedHandleKeywordChange()
}, },
allCustomGroups () { allCustomGroups () {
this.waitForDomAndInitializeLazyLoad()
this.filteredEmojiGroups = this.getFilteredEmojiGroups() this.filteredEmojiGroups = this.getFilteredEmojiGroups()
} }
}, },
destroyed () {
this.destroyLazyLoad()
},
computed: { computed: {
activeGroupView () { activeGroupView () {
return this.showingStickers ? '' : this.activeGroup return this.showingStickers ? '' : this.activeGroup
@ -314,7 +275,6 @@ const EmojiPicker = {
}, },
debouncedHandleKeywordChange () { debouncedHandleKeywordChange () {
return debounce(() => { return debounce(() => {
this.waitForDomAndInitializeLazyLoad()
this.filteredEmojiGroups = this.getFilteredEmojiGroups() this.filteredEmojiGroups = this.getFilteredEmojiGroups()
}, 500) }, 500)
}, },

View File

@ -104,9 +104,9 @@
>{{ emoji.replacement }}</span> >{{ emoji.replacement }}</span>
<still-image <still-image
v-else v-else
:ref="setEmojiRef(group.id + emoji.displayText)"
class="emoji-picker-emoji -custom" class="emoji-picker-emoji -custom"
:data-src="emoji.imageUrl" loading="lazy"
:src="emoji.imageUrl"
:data-emoji-name="group.id + emoji.displayText" :data-emoji-name="group.id + emoji.displayText"
/> />
</span> </span>

View File

@ -8,7 +8,8 @@ const StillImage = {
'alt', 'alt',
'height', 'height',
'width', 'width',
'dataSrc' 'dataSrc',
'loading'
], ],
data () { data () {
return { return {

View File

@ -17,6 +17,7 @@
:data-src="dataSrc" :data-src="dataSrc"
:src="realSrc" :src="realSrc"
:referrerpolicy="referrerpolicy" :referrerpolicy="referrerpolicy"
:loading="loading"
@load="onLoad" @load="onLoad"
@error="onError" @error="onError"
> >