Skip to content

Commit 3586dee

Browse files
committed
refactor: update AnimateOnScroll datasets
1 parent c8e6a06 commit 3586dee

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

packages/@primereact/headless/src/animateonscroll/useAnimateOnScroll.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export const useAnimateOnScroll = withHeadless({
4646
}
4747

4848
unobserveReset(el);
49-
el.removeAttribute('data-pd-animateonscroll-state');
49+
el.removeAttribute('data-enter');
50+
el.removeAttribute('data-leave');
5051
animationState.current = undefined;
5152
}
5253
}
@@ -76,7 +77,7 @@ export const useAnimateOnScroll = withHeadless({
7677
}
7778

7879
addClass(el, enterClassName ?? '');
79-
el.setAttribute('data-pd-animateonscroll-state', 'enter');
80+
el.setAttribute('data-enter', '');
8081
animationState.current = 'enter';
8182

8283
bindAnimationEvents();
@@ -104,7 +105,7 @@ export const useAnimateOnScroll = withHeadless({
104105
addClass(el, leaveClassName ?? '');
105106
bindAnimationEvents();
106107
animationState.current = 'leave';
107-
el.setAttribute('data-pd-animateonscroll-state', 'leave');
108+
el.setAttribute('data-leave', '');
108109
} else {
109110
el.style.opacity = '0';
110111
}
@@ -140,7 +141,8 @@ export const useAnimateOnScroll = withHeadless({
140141
el.style.opacity = '';
141142
}
142143

143-
el.removeAttribute('data-pd-animateonscroll-state');
144+
el.removeAttribute('data-enter');
145+
el.removeAttribute('data-leave');
144146
animationState.current = undefined;
145147
}
146148
};
@@ -171,15 +173,14 @@ export const useAnimateOnScroll = withHeadless({
171173

172174
useMountEffect(() => {
173175
if (elementRef.current) {
174-
elementRef.current.setAttribute('data-pd-animateonscroll', 'true');
175176
setTimeout(() => elementRef.current && observe(elementRef.current), 0);
176177
}
177178
});
178179

179180
useUnmountEffect(() => {
180181
if (elementRef.current) {
181-
elementRef.current.removeAttribute('data-pd-animateonscroll');
182-
elementRef.current.removeAttribute('data-pd-animateonscroll-state');
182+
elementRef.current.removeAttribute('data-enter');
183+
elementRef.current.removeAttribute('data-leave');
183184
unobserve(elementRef.current);
184185
unobserveReset(elementRef.current);
185186
unbindAnimationEvents();

packages/primereact/src/animateonscroll/AnimateOnScroll.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ export const AnimateOnScroll = withComponent({
1515
return animateonscroll;
1616
},
1717
render(instance) {
18-
const { props, ptmi } = instance;
18+
const { props, cx, ptmi } = instance;
1919

20-
const rootProps = mergeProps({}, ptmi('root'));
20+
const rootProps = mergeProps(
21+
{
22+
className: cx('root')
23+
},
24+
ptmi('root')
25+
);
2126

2227
return (
2328
<AnimateOnScrollProvider value={instance}>

0 commit comments

Comments
 (0)