Examples

Timeline Navigation

Fit content, pan to a date, or change zoom with the timeline's viewport APIs.

Choose the API that matches the navigation task

fitDateRange() fitArticleRange() fitArticles() setStartDate() setCentreDate() setZoom()

Fit methods pan and zoom until the requested content fits. Date methods pan without changing zoom. setZoom() changes scale around the viewport center by default; lower values show a closer view and higher values show a wider view.

Run the task that matches your use case, then compare it with the corresponding code below.

Need to limit how far users can navigate? See the Date Bounds example.

Try a navigation task

const fitOptions = {
  padding: { left: 70, right: 70 },
  animation: { active: true, duration: 350, easing: "swing" }
};

timeline.fitDateRange(
  { year: 1957, month: 1, day: 1 },
  { year: 1969, month: 12, day: 31 },
  fitOptions
);

const apollo = timeline.getArticleById("navigation-apollo");
timeline.fitArticleRange(apollo, fitOptions);

timeline.fitArticles(fitOptions);