@daeryun/dr_components 0.7.55 → 0.7.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/common/hook/useElementObserve.d.ts +1 -2
- package/dist/components/common/hook/useElementObserve.js +3 -8
- package/dist/components/common/hook/useElementObserve.ts +3 -9
- package/dist/styles/observe.module.css +11 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
3
|
import style from '../../../styles/observe.module.css';
|
|
4
|
-
const useElementObserve = (targetRef,
|
|
4
|
+
const useElementObserve = (targetRef, threshold) => {
|
|
5
5
|
const [flag, setFlag] = useState(false);
|
|
6
|
-
const [flagStandardBoolean, setFlagStandardBoolean] = useState(false);
|
|
7
6
|
useEffect(() => {
|
|
8
7
|
const options = {
|
|
9
|
-
threshold: [
|
|
8
|
+
threshold: [threshold ? threshold : 0.1]
|
|
10
9
|
};
|
|
11
10
|
const callback = (entries, observer) => {
|
|
12
11
|
entries.forEach((entry, index) => {
|
|
13
12
|
if (entry.isIntersecting) {
|
|
14
|
-
if (entry.intersectionRatio >= 0.1) {
|
|
13
|
+
if (entry.intersectionRatio >= (threshold ? threshold : 0.1) && !flag) {
|
|
15
14
|
setFlag(true);
|
|
16
15
|
}
|
|
17
|
-
if (flagStandard && entry.intersectionRatio >= flagStandard) {
|
|
18
|
-
setFlagStandardBoolean(true);
|
|
19
|
-
}
|
|
20
16
|
}
|
|
21
17
|
});
|
|
22
18
|
};
|
|
@@ -32,7 +28,6 @@ const useElementObserve = (targetRef, flagStandard) => {
|
|
|
32
28
|
}, []);
|
|
33
29
|
return {
|
|
34
30
|
flag,
|
|
35
|
-
flagStandardBoolean,
|
|
36
31
|
flagClass: flag ? style.scroll_fade_in : 'opacity-0',
|
|
37
32
|
flagFastClass: flag ? style.scroll_fade_in_fast : 'opacity-0',
|
|
38
33
|
strengthClass: flag ? style.scroll_fade_in_strength : 'opacity-0',
|
|
@@ -3,24 +3,19 @@
|
|
|
3
3
|
import { useState, useEffect } from 'react';
|
|
4
4
|
import style from '../../../styles/observe.module.css';
|
|
5
5
|
|
|
6
|
-
const useElementObserve = (targetRef: any,
|
|
6
|
+
const useElementObserve = (targetRef: any, threshold?: number) => {
|
|
7
7
|
const [flag, setFlag] = useState<boolean>(false);
|
|
8
|
-
const [flagStandardBoolean, setFlagStandardBoolean] = useState<boolean>(false);
|
|
9
8
|
useEffect(() => {
|
|
10
9
|
const options: IntersectionObserverInit = {
|
|
11
|
-
threshold: [
|
|
10
|
+
threshold: [threshold ? threshold : 0.1]
|
|
12
11
|
};
|
|
13
12
|
|
|
14
13
|
const callback: IntersectionObserverCallback = (entries, observer) => {
|
|
15
14
|
entries.forEach((entry, index) => {
|
|
16
15
|
if (entry.isIntersecting) {
|
|
17
|
-
if (entry.intersectionRatio >= 0.1) {
|
|
16
|
+
if (entry.intersectionRatio >= (threshold ? threshold : 0.1) && !flag) {
|
|
18
17
|
setFlag(true);
|
|
19
18
|
}
|
|
20
|
-
|
|
21
|
-
if (flagStandard && entry.intersectionRatio >= flagStandard) {
|
|
22
|
-
setFlagStandardBoolean(true);
|
|
23
|
-
}
|
|
24
19
|
}
|
|
25
20
|
});
|
|
26
21
|
};
|
|
@@ -40,7 +35,6 @@ const useElementObserve = (targetRef: any, flagStandard?: number) => {
|
|
|
40
35
|
|
|
41
36
|
return {
|
|
42
37
|
flag,
|
|
43
|
-
flagStandardBoolean,
|
|
44
38
|
flagClass: flag ? style.scroll_fade_in : 'opacity-0',
|
|
45
39
|
flagFastClass: flag ? style.scroll_fade_in_fast : 'opacity-0',
|
|
46
40
|
strengthClass: flag ? style.scroll_fade_in_strength : 'opacity-0',
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
@keyframes fadeInUp {
|
|
2
|
+
from {
|
|
3
|
+
opacity: 0;
|
|
4
|
+
transform: translateY(100px);
|
|
5
|
+
}
|
|
6
|
+
to {
|
|
7
|
+
opacity: 1;
|
|
8
|
+
transform: translateY(0);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
1
12
|
/*.scroll_fade_in {*/
|
|
2
13
|
/* animation: fadeInUp 1.5s ease-in-out !important;*/
|
|
3
14
|
/* animation-fill-mode: forwards;*/
|