Skip to content

Commit

Permalink
fix(marquee): performance warning caused by non-function default slot (
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouyang committed Jan 15, 2025
1 parent c96427d commit ba135c1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## NEXT_VERSION

### Fixes

- Fix `n-marquee` component Non-function value encountered for default slot warning.

## 2.41.0

### Breaking Changes
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## NEXT_VERSION

### Fixes

- 修复 `n-marquee` 组件 Non-function value encountered for default slot 警告

## 2.41.0

`2025-01-05`
Expand Down
50 changes: 29 additions & 21 deletions src/marquee/src/Marquee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ export default defineComponent({
} = this
const originalNode = (
<VResizeObserver onResize={this.handleContentResize}>
<div
class={`${mergedClsPrefix}-marquee__item ${mergedClsPrefix}-marquee__original-item`}
>
{$slots}
</div>
{{
default: () => (
<div
class={`${mergedClsPrefix}-marquee__item ${mergedClsPrefix}-marquee__original-item`}
>
{$slots}
</div>
)
}}
</VResizeObserver>
)
const mirrorNode = (
Expand All @@ -108,22 +112,26 @@ export default defineComponent({
if (this.autoFill) {
return (
<VResizeObserver onResize={this.handleContainerResize}>
<div
class={`${mergedClsPrefix}-marquee ${mergedClsPrefix}-marquee--auto-fill`}
ref="containerElRef"
style={animationCssVars}
>
<div
class={`${mergedClsPrefix}-marquee__group`}
onAnimationiteration={handleAnimationIteration}
>
{originalNode}
{repeat(repeatCountInOneGroup - 1, mirrorNode)}
</div>
<div class={`${mergedClsPrefix}-marquee__group`}>
{repeat(repeatCountInOneGroup, mirrorNode)}
</div>
</div>
{{
default: () => (
<div
class={`${mergedClsPrefix}-marquee ${mergedClsPrefix}-marquee--auto-fill`}
ref="containerElRef"
style={animationCssVars}
>
<div
class={`${mergedClsPrefix}-marquee__group`}
onAnimationiteration={handleAnimationIteration}
>
{originalNode}
{repeat(repeatCountInOneGroup - 1, mirrorNode)}
</div>
<div class={`${mergedClsPrefix}-marquee__group`}>
{repeat(repeatCountInOneGroup, mirrorNode)}
</div>
</div>
)
}}
</VResizeObserver>
)
}
Expand Down

0 comments on commit ba135c1

Please sign in to comment.