fix(feat): Refine responsive layout and section spacing
This commit is contained in:
@@ -33,7 +33,9 @@ const {
|
||||
const getOffset = () => header ? header.offsetHeight : 0;
|
||||
let activeScrollAnimation = 0;
|
||||
|
||||
const easeInCubic = (t: number) => t * t * t;
|
||||
const easeInOutCubic = (t: number) => (
|
||||
t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2
|
||||
);
|
||||
|
||||
const animateScrollTo = (targetTop: number) => {
|
||||
const startTop = window.scrollY;
|
||||
@@ -54,7 +56,7 @@ const {
|
||||
const step = (now: number) => {
|
||||
const elapsed = now - startTime;
|
||||
const progress = Math.min(elapsed / duration, 1);
|
||||
const easedProgress = easeInCubic(progress);
|
||||
const easedProgress = easeInOutCubic(progress);
|
||||
|
||||
window.scrollTo(0, startTop + distance * easedProgress);
|
||||
|
||||
@@ -77,6 +79,7 @@ const {
|
||||
e.preventDefault();
|
||||
const top = target.getBoundingClientRect().top + window.scrollY - getOffset();
|
||||
animateScrollTo(top);
|
||||
history.pushState(null, '', href);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user