1.4.0 • Published 2 years ago

timeline-vertical-navigation v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

timeline-vertical-navigation

Navigate in time same way as Google Photos. Built with StencilJS

Properties

PropertyAttributeDescriptionTypeDefault
darkmodedarkmodebooleanfalse
dates (required)datesDate[] or stringundefined
opaquebackgroundopaquebackgroundbooleanfalse
pinnedpinnedbooleanfalse

Events

EventDescriptionType
dateSelectedCustomEvent<Date>

Methods

updateSelectedDate(date: Date) => void

Example with native HTML & JavaScript

For the demo, there is an "items-grid" component you can find in source, this is an example of what your scrollable component could be.

<timeline-vertical-navigation
  dates="2020-03-31, 2022-09-12, 2022-04-01, 2022-03-12, 2022-03-13, 2022-03-14, 2022-03-15, 2000-01-01, 2010-12-01, 2013-10-01, 2010-11-21, 1998-07-28, 2000-01-01, 2000-01-11, 2002-03-11, 2002-04-11, 2002-04-12, 2025-01-01"
></timeline-vertical-navigation>
<script>
  const timelineVerticalNavigation = document.querySelector('timeline-vertical-navigation');
  timelineVerticalNavigation.addEventListener('dateSelected', e => {
    const selectedDate = e.detail;
    // You can scroll into your scrollable component to the selected date
    {yourScrollableComponent}.scrollToDate(selectedDate);
  });
  // Then your scrollable component need to dispatch which date is currently displayed in order to update the selected date
   {yourScrollableComponent}.addEventListener('scrolledToDate', e => {
        const firstDateVisible = e.detail;
        const timelineVerticalNavigation = document.querySelector('timeline-vertical-navigation');
        timelineVerticalNavigation.updateSelectedDate(firstDateVisible);
      });
</script>

Online demo

React.js

Use react-timeline-vertical-navigation package.

1.2.0

2 years ago

1.4.0

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago