Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2f8927d

Browse files
Merge pull request #64 from takuma-hmng8/dev
Dev
2 parents c2b2e78 + 80f96c0 commit 2f8927d

File tree

12 files changed

+494
-444
lines changed

12 files changed

+494
-444
lines changed

‎app/ShaderFx.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const ShaderFx = ({ children }: { children: React.ReactNode }) => {
1616
setDpr(Math.round((0.5 + 1.0 * factor) * 10) / 10);
1717
}}>
1818
<Suspense fallback={null}>{children}</Suspense>
19-
{/* <Perf position={"bottom-left"} minimal={false} /> */}
19+
<Perf position={"bottom-left"} minimal={false} />
2020
</PerformanceMonitor>
2121
</Canvas>
2222
);

‎app/domSyncer/DomSyncer.tsx‎

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,32 +51,16 @@ export const DomSyncer = ({ state }: { state: number }) => {
5151
);
5252

5353
const { setFrameloop } = useThree();
54-
const isPlaying = useRef<boolean>(true);
55-
56-
useEffect(() => {
57-
let id: number;
58-
const filterIntersection = () => {
59-
if (domSyncerObj.intersections.some((item) => item)) {
60-
// どっかには交差してる
61-
if (!isPlaying.current) {
62-
setFrameloop("always");
63-
isPlaying.current = true;
64-
}
65-
} else {
66-
// どこにも交差してない
67-
if (isPlaying.current) {
68-
setFrameloop("never");
69-
isPlaying.current = false;
70-
}
71-
}
72-
73-
id = requestAnimationFrame(filterIntersection);
74-
};
75-
id = requestAnimationFrame(filterIntersection);
76-
return () => {
77-
cancelAnimationFrame(id);
78-
};
79-
}, [domSyncerObj.intersections, setFrameloop]);
54+
domSyncerObj.useDomView({
55+
onView: () => {
56+
console.log("play");
57+
setFrameloop("always");
58+
},
59+
onHidden: () => {
60+
console.log("stop");
61+
setFrameloop("never");
62+
},
63+
});
8064

8165
const domArr = useRef<(HTMLElement | Element)[]>([]);
8266
const contentArr = useRef<HTMLElement[]>([]);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /