fixed profilemore expansion on mobile display
This commit is contained in:
@@ -5,19 +5,13 @@ import { MoreSection, PROFILE } from "@/data/content";
|
|||||||
import { useFullBleed, usePrefersReducedMotion } from "@/hooks/useAnimations";
|
import { useFullBleed, usePrefersReducedMotion } from "@/hooks/useAnimations";
|
||||||
import "@/styles/more-section.css";
|
import "@/styles/more-section.css";
|
||||||
|
|
||||||
/**
|
|
||||||
* Publishes the threshold rule's distance from the top of the document as
|
|
||||||
* `--threshold-y`, which the root background gradient reads to tint everything
|
|
||||||
* below it. Keeping this on the background instead of in an element means it
|
|
||||||
* covers the rest of the page without adding to the scrollable area.
|
|
||||||
*/
|
|
||||||
function useThresholdTint(ref: React.RefObject<HTMLElement | null>) {
|
function useThresholdTint(ref: React.RefObject<HTMLElement | null>) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const el = ref.current;
|
const el = ref.current;
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
|
|
||||||
const root = document.documentElement;
|
const root = document.documentElement;
|
||||||
|
|
||||||
const publish = () => {
|
const publish = () => {
|
||||||
const rect = el.getBoundingClientRect();
|
const rect = el.getBoundingClientRect();
|
||||||
// The rule sits at the element's vertical centre.
|
// The rule sits at the element's vertical centre.
|
||||||
@@ -49,16 +43,14 @@ export default function ProfileMore() {
|
|||||||
const { ref: bleedRef, style: bleedStyle } = useFullBleed<HTMLDivElement>();
|
const { ref: bleedRef, style: bleedStyle } = useFullBleed<HTMLDivElement>();
|
||||||
useThresholdTint(bleedRef);
|
useThresholdTint(bleedRef);
|
||||||
|
|
||||||
// Sections before `moreSectionsStart` are always visible; the rest are the
|
|
||||||
// payload that lives below the threshold.
|
|
||||||
const start = PROFILE.moreSectionsStart ?? 0;
|
const start = PROFILE.moreSectionsStart ?? 0;
|
||||||
const above = PROFILE.moreSections.slice(0, start);
|
const above = PROFILE.moreSections.slice(0, start);
|
||||||
const below = PROFILE.moreSections.slice(start);
|
const below = PROFILE.moreSections.slice(start);
|
||||||
|
|
||||||
// Crossing the line opens it. The reveal then latches -- crossing back up
|
const cross = useCallback((e: any) => {
|
||||||
// leaves it open, so a stray hover never yanks content out from under someone
|
if(e.pointerType=='touch'){
|
||||||
// mid-read. Collapsing is deliberate only: a click on the label.
|
return;
|
||||||
const cross = useCallback(() => {
|
}
|
||||||
setArmed(true);
|
setArmed(true);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
}, []);
|
}, []);
|
||||||
@@ -87,11 +79,7 @@ export default function ProfileMore() {
|
|||||||
{/* The threshold. The rule sits at this box's vertical centre, and the
|
{/* The threshold. The rule sits at this box's vertical centre, and the
|
||||||
rule and glow bleed to the viewport edges via the measured offset.
|
rule and glow bleed to the viewport edges via the measured offset.
|
||||||
Entering the band at all is what counts as crossing it. */}
|
Entering the band at all is what counts as crossing it. */}
|
||||||
<div
|
<div ref={bleedRef} style={{ ...bleedStyle, position: "relative" }} onPointerEnter={cross}>
|
||||||
ref={bleedRef}
|
|
||||||
style={{ ...bleedStyle, position: "relative" }}
|
|
||||||
onMouseEnter={cross}
|
|
||||||
>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="threshold"
|
className="threshold"
|
||||||
@@ -101,7 +89,8 @@ export default function ProfileMore() {
|
|||||||
aria-controls="profile-more-reveal"
|
aria-controls="profile-more-reveal"
|
||||||
onFocus={() => setArmed(true)}
|
onFocus={() => setArmed(true)}
|
||||||
onBlur={() => setArmed(open)}
|
onBlur={() => setArmed(open)}
|
||||||
onClick={toggle}
|
onClick={() => toggle()}
|
||||||
|
|
||||||
>
|
>
|
||||||
<span className="threshold-glow" aria-hidden="true" />
|
<span className="threshold-glow" aria-hidden="true" />
|
||||||
<span className="threshold-rule" aria-hidden="true" />
|
<span className="threshold-rule" aria-hidden="true" />
|
||||||
|
|||||||
Reference in New Issue
Block a user