ProSchedulerSign in

Timeline · Use cases

36-hour rolling window

A custom range of 36 hours from 06:00 today, so the night shift is shown whole. Paging moves by 36 hours.

Live demo

Page forward twice · Drag a shift across midnight

Fullscreen
import { useMemo } from "react"
import { ProScheduler } from "@andreisaac/pro-scheduler"
import { crew, crewShifts } from "./data/shifts"
import { useEvents } from "./kit"

const today = () => {
  const d = new Date()
  return new Date(d.getFullYear(), d.getMonth(), d.getDate())
}

export function RollingWindowDemo() {
  const { events, handlers } = useEvents(() => crewShifts())
  // 36 hours from 06:00 today: the night shift in the middle is never split.
  const range = useMemo(() => {
    const start = today()
    start.setHours(6)
    return { start, end: new Date(start.getTime() + 36 * 3_600_000) }
  }, [])
  return (
    <ProScheduler
      data={events}
      resources={crew}
      view={{ timeline: { type: "custom", range, resolutionHorizontal: "hour" } }}
      styleConfig={{ unitWidthPx: 44, fitToWidth: false }}
      height={520}
      {...handlers}
    />
  )
}

About this demo

A custom range of 36 hours from 06:00 today, so the night shift is shown whole. Paging moves by 36 hours.

The red line marks the current time.

Things to try

  • Page forward twice
  • Drag a shift across midnight

The props behind it are explained in Scales, ranges and zoom.

Use ProScheduler in your project