mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(RollingText): should render correctly when changing height prop (#11994)
This commit is contained in:
parent
6b8a83eefc
commit
00da05be47
@ -34,28 +34,26 @@ export default defineComponent({
|
|||||||
? props.figureArr.slice().reverse()
|
? props.figureArr.slice().reverse()
|
||||||
: props.figureArr
|
: props.figureArr
|
||||||
);
|
);
|
||||||
const totalHeight = computed(
|
const translatePx = computed(() => {
|
||||||
() => props.height * props.figureArr.length - props.height
|
const totalHeight = props.height * (props.figureArr.length - 1);
|
||||||
);
|
return `-${totalHeight}px`;
|
||||||
const translateValPx = computed(() => `-${totalHeight.value}px`);
|
});
|
||||||
|
const itemStyle = computed(() => ({
|
||||||
const itemStyleObj = {
|
|
||||||
lineHeight: addUnit(props.height),
|
lineHeight: addUnit(props.height),
|
||||||
};
|
}));
|
||||||
|
const rootStyle = computed(() => ({
|
||||||
const getStyle = () => ({
|
|
||||||
height: addUnit(props.height),
|
height: addUnit(props.height),
|
||||||
'--van-translate': translateValPx.value,
|
'--van-translate': translatePx.value,
|
||||||
'--van-duration': props.duration + 's',
|
'--van-duration': props.duration + 's',
|
||||||
'--van-delay': props.delay + 's',
|
'--van-delay': props.delay + 's',
|
||||||
});
|
}));
|
||||||
|
|
||||||
return () => (
|
return () => (
|
||||||
<div class={bem([props.direction])} style={getStyle()}>
|
<div class={bem([props.direction])} style={rootStyle.value}>
|
||||||
<div class={bem('box', { animate: props.isStart })}>
|
<div class={bem('box', { animate: props.isStart })}>
|
||||||
{Array.isArray(newFigureArr.value) &&
|
{Array.isArray(newFigureArr.value) &&
|
||||||
newFigureArr.value.map((figure) => (
|
newFigureArr.value.map((figure) => (
|
||||||
<div class={bem('item')} style={itemStyleObj}>
|
<div class={bem('item')} style={itemStyle.value}>
|
||||||
{figure}
|
{figure}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user