mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
refactor(components): [carousel] class optimization in code (#14954)
refactor(components): [carousel] class optimization in code
This commit is contained in:
@@ -2,17 +2,7 @@
|
||||
<div
|
||||
v-show="ready"
|
||||
ref="carouselItemRef"
|
||||
:class="[
|
||||
ns.e('item'),
|
||||
ns.is('active', active),
|
||||
ns.is('in-stage', inStage),
|
||||
ns.is('hover', hover),
|
||||
ns.is('animating', animating),
|
||||
{
|
||||
[ns.em('item', 'card')]: isCardType,
|
||||
[ns.em('item', 'card-vertical')]: isCardType && isVertical,
|
||||
},
|
||||
]"
|
||||
:class="itemKls"
|
||||
:style="itemStyle"
|
||||
@click="handleItemClick"
|
||||
>
|
||||
@@ -51,6 +41,18 @@ const {
|
||||
handleItemClick,
|
||||
} = useCarouselItem(props, COMPONENT_NAME)
|
||||
|
||||
const itemKls = computed(() => [
|
||||
ns.e('item'),
|
||||
ns.is('active', active.value),
|
||||
ns.is('in-stage', inStage.value),
|
||||
ns.is('hover', hover.value),
|
||||
ns.is('animating', animating.value),
|
||||
{
|
||||
[ns.em('item', 'card')]: isCardType.value,
|
||||
[ns.em('item', 'card-vertical')]: isCardType.value && isVertical.value,
|
||||
},
|
||||
])
|
||||
|
||||
const itemStyle = computed<CSSProperties>(() => {
|
||||
const translateType = `translate${unref(isVertical) ? 'Y' : 'X'}`
|
||||
const _translate = `${translateType}(${unref(translate)}px)`
|
||||
|
||||
Reference in New Issue
Block a user