refactor(avatar): disabled native lazy currently

This commit is contained in:
07akioni 2022-07-07 00:29:37 +08:00
parent 2ea323ae2b
commit 5e60c9fc19
4 changed files with 22 additions and 17 deletions

View File

@ -1,2 +1,3 @@
export const isImageSupportNativeLazy =
typeof document !== 'undefined' && 'loading' in document.createElement('img')
export const isImageSupportNativeLazy = false
// Keep it to false currently, we will provide a prop to make it configuable
// typeof document !== 'undefined' && 'loading' in document.createElement('img')

View File

@ -9,8 +9,10 @@ You can use `lazy` to let image load after it enters viewport.
id="image-scroll-container"
style="overflow: auto; height: 100px; gap: 8px"
>
<div v-for="i of range" :key="i">
<n-space vertical>
<n-avatar
v-for="i of range"
:key="i"
size="small"
:src="
'https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg?t=' + i
@ -20,7 +22,7 @@ You can use `lazy` to let image load after it enters viewport.
root: '#image-scroll-container'
}"
/>
</div>
</n-space>
</div>
</template>

View File

@ -9,8 +9,10 @@
id="image-scroll-container"
style="overflow: auto; height: 100px; gap: 8px"
>
<div v-for="i of range" :key="i">
<n-space vertical>
<n-avatar
v-for="i of range"
:key="i"
size="small"
:src="
'https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg?t=' + i
@ -20,7 +22,7 @@
root: '#image-scroll-container'
}"
/>
</div>
</n-space>
</div>
</template>

View File

@ -12,21 +12,21 @@ import {
onBeforeUnmount
} from 'vue'
import { VResizeObserver } from 'vueuc'
import { avatarGroupInjectionKey } from './context'
import type { Size, ObjectFit } from './interface'
import { tagInjectionKey } from '../../tag/src/Tag'
import { useConfig, useTheme, useThemeClass } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { avatarLight } from '../styles'
import type { AvatarTheme } from '../styles'
import { createKey, color2Class, resolveWrappedSlot } from '../../_utils'
import type { ExtractPublicPropTypes } from '../../_utils'
import style from './styles/index.cssr'
import { isImageSupportNativeLazy } from '../../_utils/env/is-native-lazy-load'
import {
IntersectionObserverOptions,
observeIntersection
} from '../../image/src/utils'
import { isImageSupportNativeLazy } from '../../_utils/env/is-native-lazy-load'
import { tagInjectionKey } from '../../tag/src/Tag'
import { useConfig, useTheme, useThemeClass } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { createKey, color2Class, resolveWrappedSlot } from '../../_utils'
import type { ExtractPublicPropTypes } from '../../_utils'
import { avatarLight } from '../styles'
import type { AvatarTheme } from '../styles'
import { avatarGroupInjectionKey } from './context'
import type { Size, ObjectFit } from './interface'
import style from './styles/index.cssr'
export const avatarProps = {
...(useTheme.props as ThemeProps<AvatarTheme>),