Fragiola

API: primitives (@fragiola/calendar-react)

Calendar.Scroller

The element that scrolls a time grid's slots, which the engine scrolls for you while a drag or a selection nears its edges.

Calendar.Scroller is the element that scrolls the slot rows of a time grid. It renders a div and its children; its height and its overflow: auto are yours, and so is the scroll position (a ref callback that scrolls to the morning, a saved position).

Behaviour

  • The engine registers it as the time grid's scroller: while a pointer drag, a resize or a selection nears its top or bottom edge (40 px by default), it scrolls it, 12 px a frame at most (the engine option autoScroll, false to turn it off).
  • A scroll inside the root drops the measured hit boxes, so a drag keeps landing where the pointer is.
  • It has no role: the grid's rows inside it keep their own.

Usage

import { Calendar } from "@fragiola/calendar-react";
import type { ReactNode } from "react";

/** Opens the time grid at 08:00 (the scroll position is the app's). */
function scrollToMorning(element: HTMLElement | null) {
    const eight = element?.querySelector<HTMLElement>('[data-time="08:00"]');
    if (element && eight) element.scrollTop = eight.offsetTop - 8;
}

export function Body(props: { children: ReactNode }) {
    return (
        <Calendar.Scroller
            ref={scrollToMorning}
            style={{ height: 480, overflow: "auto" }}
        >
            {props.children}
        </Calendar.Scroller>
    );
}

In React, ref is a plain prop, merged with the part's own; in Vue, a template ref on a part is its component, and its $el the element; in Angular, the element is yours (a viewChild). See Sizing and scrolling.

Attributes

attributevalue
data-calendar-partdata-calendar-part="scroller"

Props

In Vue: the same props (in kebab-case in a template), and slots in place of children; see Vue primitives.

In Angular: a directive on your element, the props as its inputs, templates in place of children; see Angular primitives.

ScrollerProps takes the common props and any div attribute, and:

proptypedescription
childrenReactNodethe slot rows and the layer of columns

State

ScrollerState is empty: a className or style function receives {}.