Skip to content

Commit 5d4ada7

Browse files
committed
update
1 parent 1d6b879 commit 5d4ada7

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

components/FancyArrow.vue

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ const point2: Ref<AbsolutePosition | undefined> = useEndpointResolution(
8484
},
8585
);
8686
87+
const animationEnabled = computed(() => {
88+
return (
89+
props.animated ||
90+
props.animationDuration != null ||
91+
props.animationDelay != null
92+
);
93+
});
94+
8795
const { arrowSvg, textPosition } = useRoughArrow({
8896
point1,
8997
point2,
@@ -94,19 +102,18 @@ const { arrowSvg, textPosition } = useRoughArrow({
94102
headSize: props.headSize ? Number(props.headSize) : null,
95103
roughness: props.roughness ? Number(props.roughness) : undefined,
96104
seed: props.seed ? Number(props.seed) : undefined,
97-
animation:
98-
props.animated || props.animationDuration || props.animationDelay
99-
? {
100-
duration:
101-
props.animationDuration != null
102-
? Number(props.animationDuration)
103-
: undefined,
104-
delay:
105-
props.animationDelay != null
106-
? Number(props.animationDelay)
107-
: undefined,
108-
}
109-
: undefined,
105+
animation: animationEnabled.value
106+
? {
107+
duration:
108+
props.animationDuration != null
109+
? Number(props.animationDuration)
110+
: undefined,
111+
delay:
112+
props.animationDelay != null
113+
? Number(props.animationDelay)
114+
: undefined,
115+
}
116+
: undefined,
110117
strokeAnimationKeyframeName: "rough-arrow-dash",
111118
fillAnimationKeyframeName: "rough-arrow-fill",
112119
});
@@ -135,14 +142,10 @@ const { arrowSvg, textPosition } = useRoughArrow({
135142
left: `${textPosition.x}px`,
136143
top: `${textPosition.y}px`,
137144
transform: 'translate(-50%, -50%)',
138-
visibility:
139-
props.animated || props.animationDuration || props.animationDelay
140-
? 'hidden'
141-
: 'visible',
142-
animation:
143-
props.animated || props.animationDuration || props.animationDelay
144-
? `rough-arrow-content ${props.animationDuration ?? DEFAULT_ANIMATION_DURATION}ms ease-out ${props.animationDelay ?? 0}ms forwards`
145-
: 'none',
145+
visibility: animationEnabled ? 'hidden' : 'visible',
146+
animation: animationEnabled
147+
? `rough-arrow-content ${props.animationDuration ?? DEFAULT_ANIMATION_DURATION}ms ease-out ${props.animationDelay ?? 0}ms forwards`
148+
: 'none',
146149
}"
147150
>
148151
<slot />

slides.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,13 @@ If no snap target or absolute position is specified, the arrow will automaticall
712712
<img src="https://sli.dev/logo.svg" w-10 m-auto/>
713713
</FancyArrow>
714714

715+
<FancyArrow x1="500" y1="100" x2="600" y2="200" animated>
716+
Animated
717+
</FancyArrow>
718+
715719
<div mt-40>
716720

717-
```html
721+
```html {*}{maxHeight: '300px'}
718722
<FancyArrow x1="100" y1="100" x2="200" y2="200" >
719723
Hello
720724
</FancyArrow>
@@ -731,6 +735,10 @@ If no snap target or absolute position is specified, the arrow will automaticall
731735
<span text-nowrap>Slidev logo</span>
732736
<img src="https://sli.dev/logo.svg" w-10 m-auto/>
733737
</FancyArrow>
738+
739+
<FancyArrow x1="500" y1="100" x2="600" y2="200" animated>
740+
Animated
741+
</FancyArrow>
734742
```
735743

736744
</div>

0 commit comments

Comments
 (0)