npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pp-timeline

v1.0.4

Published

Vanilla JavaScript horizontal / vertical timeline component

Downloads

4

Readme

Timeline

es6导入改造

A vanilla JavaScript horizontal / vertical timeline.

Horizontal timeline demo | Vertical timeline demo

  • Responsive
  • Configure settings using the API or through data attributes
  • Built with performance in mind
  • Small file size
  • Library agnostic. If jQuery is present it will register itself as a plugin
  • Written in ES6 and transpiled into ES5 via Babel

Usage

Link the required files

<script src="/dist/js/timeline.min.js"></script>
<link href="/dist/css/timeline.min.css" rel="stylesheet" />

HTML markup

<div class="timeline">
    <div class="timeline__wrap">
        <div class="timeline__items">
            <div class="timeline__item">
                <div class="timeline__content">
                    Content / markup here
                </div>
            </div>
            <div class="timeline__item">
                <div class="timeline__content">
                    Content / markup here
                </div>
            </div>
            <div class="timeline__item">
                <div class="timeline__content">
                    Content / markup here
                </div>
            </div>
            <div class="timeline__item">
                <div class="timeline__content">
                    Content / markup here
                </div>
            </div>
            <div class="timeline__item">
                <div class="timeline__content">
                    Content / markup here
                </div>
            </div>
        </div>
    </div>
</div>

Initialize the plugin

JavaScript

timeline(document.querySelectorAll('.timeline'));

jQuery

jQuery('.timeline').timeline();

Configuration options

Using data attributes will take priority over settings via the API.

mode

Choose whether the timeline should be vertical or horizontal

JavaScript/jQuery

default: 'vertical'
options: 'vertical', 'horizontal'

Data attribute

<div class="timeline" data-mode="horizontal">
    ...
</div>

forceVerticalMode

When using the timeline in horizontal mode, define at which viewport width it should revert to vertical mode

JavaScript/jQuery

default: 600
options: integer

Data attribute

<div class="timeline" data-force-vertical-mode="600">
    ...
</div>

horizontalStartPosition

When using the timeline in horizontal mode, define the vertical alignment of the first item

JavaScript/jQuery

default: 'top'
options: 'bottom', 'top'

Data attribute

<div class="timeline" data-horizontal-start-position="top">
    ...
</div>

moveItems

When using the timeline in horizontal mode, define how many items to move when clicking a navigation button

JavaScript/jQuery

default: 1
options: integer

Data attribute

<div class="timeline" data-move-items="1">
    ...
</div>

rtlMode

When using the timeline in horizontal mode, this defines whether the timeline should start from the right. This overrides the startIndex setting.

JavaScript/jQuery

default: false
options: true / false

Data attribute

<div class="timeline" data-rtl-mode="true">
    ...
</div>

startIndex

When using the timeline in horizontal mode, define which item the timeline should start at

JavaScript/jQuery

default: 0
options: integer

Data attribute

<div class="timeline" data-start-index="0">
    ...
</div>

verticalStartPosition

When using the timeline in vertical mode, define the alignment of the first item

JavaScript/jQuery

default: 'left'
options: 'left', 'right'

Data attribute

<div class="timeline" data-vertical-start-position="right">
    ...
</div>

verticalTrigger

When using the timeline in vertical mode, define the distance from the bottom of the screen, in percent or pixels, that the items slide into view

JavaScript/jQuery

default: '15%'
options: percentage or pixel value e.g. '20%' or '150px'

Data attribute

<div class="timeline" data-vertical-trigger="150px">
    ...
</div>

visibleItems

If using the timeline in horizontal mode, define how many items are visible in the viewport

JavaScript/jQuery

default: 3
options: integer

Data attribute

<div class="timeline" data-visible-items="3">
    ...
</div>

Examples

Horizontal timeline

With 4 items visible in the viewport and changes into vertical mode at a 800px breakpoint

See demo

JavaScript

timeline(document.querySelectorAll('.timeline'), {
    mode: 'horizontal',
    visibleItems: 4,
    forceVerticalMode: 800
});

jQuery

jQuery('.timeline').timeline({
    mode: 'horizontal',
    visibleItems: 4,
    forceVerticalMode: 800
});

Data attributes

timeline(document.querySelectorAll('.timeline'));

Or

jQuery('.timeline').timeline();

And

<div class="timeline" data-mode="horizontal" data-visible-items="4" data-force-vertical-width="800">
    ...
</div>

Vertical timeline

With the first item aligned to the right and the elements set to come into view 150px from the bottom of the window

See demo

JavaScript

timeline(document.querySelectorAll('.timeline'), {
    verticalStartPosition: 'right',
    verticalTrigger: '150px'
});

jQuery

jQuery('.timeline').timeline({
    verticalStartPosition: 'right',
    verticalTrigger: '150px'
});

Data attributes

timeline(document.querySelectorAll('.timeline'));

Or

jQuery('.timeline').timeline();

And

<div class="timeline" data-vertical-start-position="right" data-vertical-trigger="150px">
    ...
</div>

Upcoming development

  • [ ] Ability to choose how many items are visible at user defined breakpoints when using the timeline in horizontal mode
  • [x] Ability to set how many items slide at a time when navigating through the horizontal timeline
  • [x] Ability to set trigger distance from the top of the page in vertical mode
  • [x] Add a horizontal start position option
  • [ ] Generate a tab menu to navigate to specific items
  • [ ] Ability to change classes for the HTML elements
  • [ ] Add various animation options for the vertical timeline (e.g. slide up/slide in/fade in)