mirror of
https://github.com/ClipFusion-org/clipfusion.git
synced 2025-08-03 18:05:09 +00:00
changed scrolling code a little bit
This commit is contained in:
parent
0710981de7
commit
fd21a73620
@ -11,7 +11,9 @@ export const ScrollFadingTitle = (props: ComponentProps<"div">) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleScroll = () => {
|
const handleScroll = () => {
|
||||||
if (!elementRef.current) return;
|
if (!elementRef.current) return;
|
||||||
const opacity = easeFade(1 - (window.scrollY / ( window.innerHeight / 20)));
|
const opacity = easeFade(
|
||||||
|
Math.max(0, Math.min(1, 1 - (window.scrollY / (window.innerHeight / 20))))
|
||||||
|
);
|
||||||
elementRef.current.style.opacity = `${opacity}`;
|
elementRef.current.style.opacity = `${opacity}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,12 +19,14 @@ export const SidebarTriggerAdjustable = (props: ComponentProps<"div">) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const triggerDiv = triggerElement as HTMLDivElement;
|
const triggerDiv = triggerElement as HTMLDivElement;
|
||||||
const slideAmount = easeSlide(Math.max(0, Math.min(1, window.scrollY / (window.innerHeight / 20))));
|
const slideAmount = easeSlide(
|
||||||
|
Math.max(0, Math.min(1, window.scrollY / (window.innerHeight / 20)))
|
||||||
|
);
|
||||||
triggerDiv.style.marginLeft = `calc(var(--spacing) * ${12 * slideAmount})`;
|
triggerDiv.style.marginLeft = `calc(var(--spacing) * ${12 * slideAmount})`;
|
||||||
triggerDiv.style.paddingTop = `calc(var(--spacing) * ${(isMobile ? 1 : 3) * slideAmount})`;
|
triggerDiv.style.paddingTop = `calc(var(--spacing) * ${(isMobile ? 1 : 3) * slideAmount})`;
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('scroll', handleScroll);
|
window.addEventListener('scroll', handleScroll, {passive: true});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener('scroll', handleScroll);
|
window.removeEventListener('scroll', handleScroll);
|
||||||
|
Loading…
Reference in New Issue
Block a user