From 25ebec98855975492a051a3b64cde73c41b7a5fa Mon Sep 17 00:00:00 2001 From: kanghuiyi66 <58717456+kanghuiyi66@users.noreply.github.com> Date: Mon, 4 Apr 2022 19:52:18 +0800 Subject: [PATCH] perf: Modify the class display method in table, tabs, ripple and lazy (#391) --- packages/varlet-ui/src/lazy/index.ts | 3 +- packages/varlet-ui/src/ripple/index.ts | 5 +- packages/varlet-ui/src/table/Table.vue | 13 +++-- .../varlet-ui/src/tabs-items/TabsItems.vue | 15 +++--- packages/varlet-ui/src/tabs/Tabs.vue | 47 +++++++++++-------- 5 files changed, 49 insertions(+), 34 deletions(-) diff --git a/packages/varlet-ui/src/lazy/index.ts b/packages/varlet-ui/src/lazy/index.ts index eede8ee2fce..10b77479224 100644 --- a/packages/varlet-ui/src/lazy/index.ts +++ b/packages/varlet-ui/src/lazy/index.ts @@ -2,6 +2,7 @@ import { getAllParentScroller, inViewport } from '../utils/elements' import { createCache, removeItem, throttle } from '../utils/shared' import type { App, Directive, Plugin, DirectiveBinding } from 'vue' import type { CacheInstance } from '../utils/shared' +import { call } from '../utils/components' interface LazyOptions { loading?: string @@ -117,7 +118,7 @@ function createLazy(el: LazyHTMLElement, binding: DirectiveBinding) { setSRC(el, PIXEL) - defaultLazyOptions.filter?.(el._lazy) + call(defaultLazyOptions.filter, el._lazy) } function createImage(el: LazyHTMLElement, attemptSRC: string) { diff --git a/packages/varlet-ui/src/ripple/index.ts b/packages/varlet-ui/src/ripple/index.ts index c9ba7df2aa6..3ecc2ca8e66 100644 --- a/packages/varlet-ui/src/ripple/index.ts +++ b/packages/varlet-ui/src/ripple/index.ts @@ -4,6 +4,9 @@ import '../styles/common.less' import { supportTouch } from '../utils/elements' import type { Directive, Plugin, App } from 'vue' import type { DirectiveBinding } from '@vue/runtime-core' +import { createNamespace } from '../utils/components' + +const { n } = createNamespace('ripple') interface RippleStyles { x: number @@ -69,7 +72,7 @@ function createRipple(this: RippleHTMLElement, event: TouchEvent) { const { x, y, centerX, centerY, size }: RippleStyles = computeRippleStyles(this, event) const ripple: RippleHTMLElement = document.createElement('div') - ripple.classList.add('var-ripple') + ripple.classList.add(n()) ripple.style.opacity = `0` ripple.style.transform = `translate(${x}px, ${y}px) scale3d(.3, .3, .3)` ripple.style.width = `${size}px` diff --git a/packages/varlet-ui/src/table/Table.vue b/packages/varlet-ui/src/table/Table.vue index f05ceb03922..5335ff35268 100644 --- a/packages/varlet-ui/src/table/Table.vue +++ b/packages/varlet-ui/src/table/Table.vue @@ -1,11 +1,11 @@