`

Horizontal Timeline 2.0, is a fully customisable jQuery adaptation of a script originally created by CodyHouse, to create a dynamic timeline on the horizontal axis.

Version 2.0 adds functionality that has been previously requested for the original version, and more:

For details of additions, changes, bug fixes, and removals, please visit the Changelog on Github.
Please see the Deprecation table for a list of deprecations and their replacements.

Setup

To get started, add the JS and CSS files to the document. The easiest way to do this is to add them via jsdilvr CDN. Otherwise, you can download them from our Github Repo.

// Add CSS via jsdilvr CDN
                    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/ycodetech/horizontal-timeline-2.0@2/css/horizontal_timeline.2.0.min.css">
                 
                    // Add jQuery 
    				<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
                    
                    // Add JS via jsdilvr CDN
                    <script src="https://cdn.jsdelivr.net/gh/ycodetech/horizontal-timeline-2.0@2/JavaScript/horizontal_timeline.2.0.min.js"></script>
                

Minimal HTML

Unlike the original, 2.0 dynamically creates the timeline according to the amount of event content there is. Making it even simpler to setup! All you need to do is create the event content…


					<div class="horizontal-timeline" id="example">
						<div class="events-content">
							<ol>
								<li class="selected" data-horizontal-timeline='{"date": "16/01/2014"}'>
									// Event description here
								</li>
								<li data-horizontal-timeline='{"date": "23/05/2015"}'>
									// Event description here
								</li>
								…etc.
							</ol>
						</div>
					</div>   		
                

Important things to note!

  • A unique id for the parent (the selector element) needs to be set. This is to ensure a timeline instance is created, allowing for multiple instances using multiple unique ids. Here, we're using example
  • Add an optional selected class to any of the <li> events content that you want to be selected first. If no events have it specified, then the first event will be selected.
Dates

The dates are essential for the timeline: it's how it all works!

Using a data attribute on the event content, we can specify the date. However, the dates need to be unique within the timeline instance because they act as ID's for the event content and the event date display acts as anchor links. While dates alone are very unique, you can of course combine them with time, creating very unique and specific events.

There are 3 supported formats:
Date
DD/MM/YYYY
(23/10/2005)
Date and Time
DD/MM/YYYYTHH:MM
(23/10/2005T15:30)
Time
HH:MM
(15:30)

Previously, timeline has used the data-date attribute, but along with the data-custom-display attribute, it is deprecated as of v2.0.5-alpha.3, in favour of the new combined singular data attribute: data-horizontal-timeline. However, the old multiple attributes will continue to work alongside the singular attribute, until they are removed in a later release.

The new attribute is used as a JSON object with comma separated key:value pairs. This helps to keep the HTML clean and tidy and the timeline options in one place.

The date should be added as the value to the date key in the data object.

Example: data-horizontal-timeline='{"date": "16/01/2014", "customDisplay": "Step 1"}'

  • The parent (the selector element) naturally has a 100% width, so you will need to set a width if desired on the element or on a grand-parent element.
  • The order of the event content is crucial for the ordering and displaying of the timeline. By using this natural support for ordering, you can reverse the order in which the events are displayed along the timeline. For example, if the timeline events are ascending but want them decending, then reversing the event content will do the trick. See the Advanced Event Order section for advanced reversing.

Initialise the timeline with jQuery using the default options.


                    <script>$('#example').horizontalTimeline();</script>
                

Displaying Event Content Externally

As of v2.0.5.4, you can use contentContainerSelector option to specify a container element externally, and separate from the plugin to display the events-content HTML and hide the plugin's default events-content.

It accepts any kind of selector string like ".container" otherwise false is the default.

Note: The plugin's default events-content is not removed, it is only hidden by CSS, as it is still needed by the plugin to make the timeline work correctly.


                    $('#example').horizontalTimeline({
						contentContainerSelector: ".section .external-content"});
                

Options


				

/* The Defaults */

$('#example').horizontalTimeline({ // ! Deprecated these individual options in favour of the object options. // desktopDateIntervals: 200, tabletDateIntervals: 150, mobileDateIntervals: 120, minimalFirstDateInterval: true, // ! End Deprecated options // /* New object options... */ // If object doesn't exist in the user options, then default to the individual options, // otherwise use the object. // Can not use in conjunction with the single options... // If both single and object options are set in the options, the object will take precedence. dateIntervals: { "desktop": 200, "tablet": 150, "mobile": 120, "minimal": true}, /* End new object options */ dateDisplay: "dateTime", // dateTime, date, time, dayMonth, monthYear, year dateOrder: "normal", // normal, reverse autoplay: false, autoplaySpeed: 8, autoplayPause_onHover: false, useScrollWheel: false, useTouchSwipe: true, useKeyboardKeys: false, addRequiredFile: true, useFontAwesomeIcons: true, useNavBtns: true, useScrollBtns: true, // ! Deprecated these individual options in favour of the object options. // iconBaseClass: "fas fa-3x", // Space separated class names scrollLeft_iconClass: "fa-chevron-circle-left", scrollRight_iconClass: "fa-chevron-circle-right", prev_iconClass: "fa-arrow-circle-left", next_iconClass: "fa-arrow-circle-right", pause_iconClass: "fa-pause-circle", play_iconClass: "fa-play-circle", animation_baseClass: "animationSpeed", // Space separated class names enter_animationClass: { "left": "enter-left", "right": "enter-right"}, exit_animationClass: { "left": "exit-left", "right": "exit-right"}, // ! End Deprecated options // /* New object options... */ // If object doesn't exist in the user options, then default to the individual options, // otherwise use the object. // Can not use in conjunction with the single options... // If both single and object options are set in the options, the object will take precedence. iconClass: { "base": "fas fa-3x", // Space separated class names "scrollLeft": "fa-chevron-circle-left", "scrollRight": "fa-chevron-circle-right", "prev": "fa-arrow-circle-left", "next": "fa-arrow-circle-right", "pause": "fa-pause-circle", "play": "fa-play-circle"}, animationClass: { "base": "animationSpeed", // Space separated class names "enter": { "left": "enter-left", "right": "enter-right"}, "exit": { "left": "exit-left", "right": "exit-right"},} /* End new object options */ contentContainerSelector: false // false, ".container" [any selector string] });

Event Date Display

As previously stated, the event dates are created dynamically along the timeline, but there are a few ways that we can customise the way they are displayed!

Uniform Intervals

The uniform event dates replaced the scattered, distanced style in the original version, meaning they are now positioned at regular intervals.

To keep things from colliding, the intervals have a minimum of 120 px. If the intervals fall below this value, then it will be automatically reset to this.

The intervals are split into 4 options, either as the all new combined object option dateIntervals with key:value pairs, or the deprecated individual options.

  • desktop object key or desktopDateIntervals individual option, describes the intervals on desktops. The default is 200
  • tablet object key or tabletDateIntervals individual option, describes the intervals on tablets. The default is 150
  • mobile object key or mobileDateIntervals individual option, describes the intervals on mobiles. The default is 120
  • minimal object key or minimalFirstDateInterval individual option, sets the first date to the start of the timeline, with effectively no interval, at 0px, while the desktop, tablet and mobile date intervals will be set from the second date onwards. The default is true
Information to Note
  • On mobile, minimal will always return true regardless of whether it is set to false. This is to keep mobile viewing easy.
  • The intervals are responsive and will change according to the width of the device/browser to the correct values as set in the options or defaults.
  • If the deprecated individual options exist in the user options, then use them, otherwise the default will be the new object options.
  • Can not use the deprecated individual options in conjunction with the object options... If both single and object options are set in the user options, the object will take precedence.
  • The following example is of the first date scenario with the interval defaults.
    1. First Date

      At 0px.

    2. Second Date

      At 200px (desktop), 150px (tablet), or 120px (mobile).

    
    						$('#example').horizontalTimeline({
    							dateIntervals: {
    								"desktop": 200,
    								"tablet": 150,
    								"mobile": 120,
    								"minimal": true}
    						});
    					

Display Types

There may be times when a different type of date display will be useful, version 2.0 adds that functionality, allowing up to 6 types! You can specify the type of date display using the dateDisplay option. The display types are as follows:

  • dateTime defines the full date and/or time as set in the date portion of the data object.
  • date defines the date only, displays in the format DD/MM/YYYY
  • time defines the time only, displays in the format HH:MM
  • dayMonth defines the day and month only, displays in the format DD/monthName
  • monthYear defines the month and year only, displays in the format monthName/YYYY
  • year defines the year only, displays in the format YYYY

The default is dateTime

dateTime

Set the date in any of the formats.

  1. 16/01/2014 14:30

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  2. 16/01/2015

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  3. 15:45

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  4. 16/01/2017

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  5. 16/01/2018 00:00

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  6. 16/01/2019

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


					$('#example').horizontalTimeline({
						dateDisplay: "dateTime"
					});
				

date

Set the date in the format of DD/MM/YYYY or DD/MM/YYYYTHH:MM.

  1. 01/01/2014 12:00

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  2. 01/01/2015

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  3. 02/01/2015

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  4. 01/12/2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  5. 25/11/2017

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


					$('#example').horizontalTimeline({
						dateDisplay: "date"
					});
				

time

Set the date in the format of HH:MM or DD/MM/YYYYTHH:MM.

  1. 12:00

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  2. 01/01/2015 08:15

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  3. 23:50

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  4. 01/12/2016 18:00

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  5. 00:01

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


					$('#example').horizontalTimeline({
						dateDisplay: "time"
					});
				

dayMonth

Set the date in the format of DD/MM/YYYY or DD/MM/YYYYTHH:MM.

  1. 01/01/2014 12:00

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  2. 02/02/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  3. 03/03/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  4. 04/04/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  5. 05/05/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  6. 06/06/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  7. 07/07/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  8. 08/08/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  9. 09/09/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  10. 10/10/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  11. 11/11/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  12. 12/12/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


					$('#example').horizontalTimeline({
						dateDisplay: "dayMonth"
					});
				

monthYear

Set the date in the format of DD/MM/YYYY or DD/MM/YYYYTHH:MM.

  1. 01/01/2014 12:00

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  2. 02/02/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  3. 03/03/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  4. 04/04/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  5. 05/05/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  6. 06/06/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  7. 07/07/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  8. 08/08/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  9. 09/09/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  10. 10/10/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  11. 11/11/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  12. 12/12/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


					$('#example').horizontalTimeline({
						dateDisplay: "monthYear"
					});
				

year

Set the date in the format of DD/MM/YYYY or DD/MM/YYYYTHH:MM.

  1. 16/01/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  2. 16/01/2015

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  3. 23/10/2015

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  4. 23/11/2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  5. 25/11/2017

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


					$('#example').horizontalTimeline({
						dateDisplay: "year"
					});
				

Custom Display Text

As requested via email, there is also an option to customise the date display text. So in case the project doesn't require dates, but another form of text, you can specify that custom text for the date display with this option.

There is no plugin options for this one though! Just add the customDisplay to the data-horizontal-timeline object or add the deprecated data-custom-display attribute along with your custom text to the appropriate event content, and it'll work immediately.

Note: This overrides the dateDisplay plugin option whereever the customDisplay or data-custom-display is used.

You can also mix the use of custom text with the date formats, so that only one (or more) events can be custom, while the rest will be left untouched as one of the 6 date formats.

  1. Step 1 at 16/01/2014 14:30

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  2. Step 2 at 17/01/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  3. No Custom Text at 15:44

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  4. Step 3 at 15:45

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


					<div class="horizontal-timeline" id="example">
						<div class="events-content">
							<ol>
								<li class="selected" data-horizontal-timeline='{"date": "16/01/2014", "customDisplay": "Custom Text"}'>
									// Event description here
								</li>
								<li data-horizontal-timeline='{"date": "23/05/2015"}'>
								// Event description here
							</li>
								…etc.
							</ol>
						</div>
					</div>   		
            	

Advanced Event Order

The previously mentioned natural support for ordering is great, but what if you want to reverse the events and start selecting them from the right instead of the left? Well, that's where the dateOrder option comes in handy.

Setting it to reverse will reverse the order in which the event dates are displayed and selected on the timeline. The default is normal .

Note:

  • When set to normal , the order of the date display is the same as their corresponding event content and the selection process starts on the left.
  • When set to reverse , the order of the date display is reversed and the selection process starts on the right; - i.e., the first event is now the last event on the farthest right along the timeline, but it is still technically the first event being selected. However, the timeline filling line direction remains unchanged and will always fill from the left.
  • Autoplay will be affected and works in the direction set by this option. But the progress bar direction remains unchanged and will always fill from the left.
  • If any of the event content has the optional selected class then the selection process is skipped naturally.
  1. 16/01/2014 - First

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  2. 17/02/2014 - Second

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  3. 18/03/2014 - Third

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  4. 19/04/2014 - Fourth

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  5. 20/05/2014 - Fifth

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


					$('#example').horizontalTimeline({
						dateOrder: "reverse"
					});
				

Autoplay

By popular demand, an autoplay feature has been added! Plus pause/play buttons, pause on hover and adjustable speed, with a progress bar to visualise the length of time autoplay stays on each event.

There are 3 options:

  • autoplay This enables the autoplay feature. The default is false
  • autoplaySpeed This specifies the speed of the autoplay cycle in seconds. The default is 8
  • autoplayPause_onHover When set to true, this allows the autoplay cycle to pause on mouse hover of the event content. It will play again when the mouse hover ends. The default is false

As of v2.0.5.3, you can specify a different speed for every event. This option utilises the data-horizontal-timeline. Simply add the "speed" key and an arbitrary number value (in seconds) to the data object of the specific event you want to change the speed of and it will override the plugin setting autoplaySpeed

Example: data-horizontal-timeline='{"date": "16/01/2014", "speed": 15}'

Because this is an event-specific option, you can pick and choose the events to override and where there isn't a speed option inside the data attribute, autoplay will default to the plugin setting. See the live example below.

Information to note

  • Autoplay can only be used once per page, meaning it can not be set on multiple timelines as yet.
  • Once paused, you can still swipe the content, click any of the events and the next/prev buttons without restarting the autoplay cycle.
  • When in the paused state and the selected event changes, upon playing again, the progress bar timer will reset to the start.
  • If autoplay was paused via the pause button, and the mouse hovers over the content, the autoplay cycle will not restart when the mouse hover ends.
  • Pause on hover is disabled on mobiles.
  • Autoplay will always know which event is selected, no matter how you navigate it, paused or not; so there will be no glitches and it won't get out of sync.
  1. 16/01/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  2. 16/01/2015

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  3. 23/10/2015

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  4. 23/10/2017

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  5. 23/10/2018

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


					$('#example').horizontalTimeline({
						autoplay: true,
						autoplaySpeed: 8,
						autoplayPause_onHover: true
					});
				

					// Data attribute speed option

					<li data-horizontal-timeline='{"date": "16/01/2014", "speed": 10}'></li>
					<li data-horizontal-timeline='{"date": "16/01/2015", "speed": 4}'></li>
					<li data-horizontal-timeline='{"date": "23/10/2015", "speed": 20}'></li>
					<li data-horizontal-timeline='{"date": "23/10/2017"}'></li>
					<li data-horizontal-timeline='{"date": "23/10/2018"}'></li>
				

Go-to Timeline

Want to link to a specific date of a timeline? No problem, just add a simple go-to anchor link anywhere on the page.


					<a href="#example" class="goto-horizontal-timeline" data-gototimeline='{"date": "23/10/2015", "scrollspeed": 500, "scrolloffset": 0, "scrolleasing": "linear"}'>Link description</a>
				

Requirements

  • The href describes the timeline ID of which we are targeting. If the link is inside a timeline and we want to target the same timeline (itself), then use a single # , like: href="#"
  • The class specifies the button we are using as the go-to link. This must be goto-horizontal-timeline to keep things easy.
  • The data-gototimeline attribute describes the go-to timeline options. The options are defined as an object.
    • The date is required and it defines the date of the timeline to go-to. This has to be exactly as defined in the date portion of the data object of the target timeline's event content.
    • The scrollspeed is optional and it defines the speed in milliseconds (ms) of the smooth scroll. If the option isn't defined, then the default is 500 ms.
    • The scrolloffset is optional and it defines the amount of offset in pixels (px) to subtract from the element's position (useful for fixed headers). If the option isn't defined, then the default is 0 px.
    • The scrolleasing is optional and it defines the easing method of scrolling. To get the most out of this, a jQuery plugin is recommended. This website uses the jQuery Easing Plugin. If the option isn't defined, then the default is linear

Placement

The go-to timeline link works just like any other link, so you can use it:

Information to Note

  • The timeline will only change content:
    • Once the smooth scroll has finished animating.
    • If a date isn't already selected.
  • The smooth scroll won't function if a link is inside a timeline and is targetting itself, the timeline content will just change instead.
  • No options are passed through the jQuery initialisation method, instead the timeline automatically looks for these links within the page and grabs whats needed from them. So you can go ahead and initialise the timeline as normal.
  • The links now utilise the new goTo method and will fire the DOM event.

Mousewheel

Scrolling the event content couldn't be easier using the jQuery Mousewheel plugin!

useScrollWheel enables the mousewheel functionality. Scrolling works when the mouse is over the event content and then using the mousewheel, scroll down to show the next content and scroll up to show the previous content. The default is false

Note: the required plugin file will be loaded dynamically, so there's no need to add it to the document. But if it's already apart of your project, don't worry; the timeline will know that and won't load the plugin again, it'll just call the functions. If addRequiredFile option is set to false the required file won't be loaded at all, the timeline will just call the functions.

  1. Scroll Down!

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  2. 16/01/2015

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  3. Scroll Up!

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


					$('#example').horizontalTimeline({
						useScrollWheel: true
						
					});
				

TouchSwipe

Touch events for mobile and touch screen devices are provided by the jQuery TouchSwipe plugin.

useTouchSwipe enables the TouchSwipe functionality. The default is true

Remember:

Swiping from right to left (swipe left) is to go right.
Swiping from left to right (swipe right) is to go left.
While it is topsy turvy, just think of dragging them along instead.

Usage

There's 2 ways TouchSwipe is implemented:

  • Scrolling the timeline

    Scrolling the timeline is made easier with TouchSwipe... just swipe(drag) the timeline in the direction, and it will scroll the amount of distance swiped. A small distance swiped means a small distance scrolled and likewise for large distances.

  • Changing the event content

    Changing the event content couldn't be easier... just swipe(drag) the event content in the direction and it will change accordingly.

While it is useful for mobiles and other touch screen devices, timeline won't force the TouchSwipe functionality if it's set as false

Note: the required plugin file will be loaded dynamically, so there's no need to add it to the document. But if it's already apart of your project, don't worry; the timeline will know that and won't load the plugin again, it'll just call the functions. If addRequiredFile option is set to false the required file won't be loaded at all, the timeline will just call the functions.

All of the timelines on this website are examples of TouchSwipe, just load it up in a mobile or touch screen device for real touch or on a desktop computer using the mouse.


					$('#example').horizontalTimeline({
						useTouchSwipe: true
						
					});
				

Keyboard Arrow Keys

You can use the keyboard arrow keys (left and right) to scroll the event content.

useKeyboardKeys enables the keyboard arrow keys. The default is false

  1. 16/01/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  2. 16/01/2015

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  3. 23/10/2015

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


					$('#example').horizontalTimeline({
						useKeyboardKeys: true
						
					});
				

Methods

There are methods you can use dynamically after the initialisation of a timeline. However, these can not be called straight after the initialisation code. Please either call them in your own code functions, or use the DOM events, specifically the initialised event to run the code.

  • Refresh

    The refresh method allows you to refresh the timeline if:

    • The width of the timeline changes dynamically.
    • New event content is added dynamically. Though if new content is added via the addEvent method, then you don't need to use this.
    • An event is removed dynamically. Though if the event is removed via the removeEvent method, then you don't need to use this.
    • Plus anything else that requires a refresh.
    
    						$('#example').horizontalTimeline('refresh');
    					
  • Destroy

    The destroy method allows you to completely destroy the timeline:

    • Removes all HTML that was added.
    • Removes all event handlers used, including TouchSwipe.
    • Resets the event content to its original state, therefore all classes and id's added by the plugin will be removed. If there was a selected class on one of the event content initially, then it will be reset back to this state. Additionally, if any event was removed or new events added, this will read or remove the events respectively.
    • Destroys and removes autoplay.
    • Deletes the instance stored as data.
    • If the timeline that is being destroyed is the one and only timeline on the page, then this method will also destroy the go-to timeline functionality and act as a normal link.
    
    						$('#example').horizontalTimeline('destroy');
    					
  • Add Event

    The addEvent method allows you to add an event to the timeline.

    We already know that timeline automatically creates the timeline event dates, so all you need to specify is:

    • The event content HTML, making sure to use a unique date in the date portion of the data object as usual.
    • The insertion method: before or after.
    • An existing unique date to position the new content around. This must match the existing date in the data object utilising the formats.

    Example: If we want to add a new event with the date 02/02/2002 after the existing event with the date 01/01/2001, we would pass the 'after' and '01/01/2001' into the method:

    var html = '<li data-horizontal-timeline='{"date": "02/02/2002"}'>Event content description.</li>';
    							
    							$('#example').horizontalTimeline('addEvent', html, 'after', '01/01/2001');

    After the event content is added, the method will then create the event date along the timeline and the refresh method will be called automatically and the eventAdded DOM event will be fired.

    Note: If a new event date already exists in the timeline, then the method will just ignore it.

  • Remove Event

    The removeEvent method allows you to remove an event from the timeline.

    Simply pass the unique date* to the method, and it'll remove the timeline event and the content connected with that date and the refresh method will be called automatically and the eventRemoved DOM event will be fired.

    Note:
    • If the event in question is selected, the method will remove the class and it will always try to select the next event, upon failing it will select the previous event instead.
    • If the event in question is the one and only event in the timeline, it will not be removed. There must always be at least 1 event in the timeline after initialisation. Please use the Destroy method instead.
    • * The date must match the target's unique date as set in the data object utilising the formats.
    							
    						$('#example').horizontalTimeline('removeEvent', '01/01/2001');
    					
  • Go To Event

    The goTo method allows you to go to an event in the timeline.

    Simply pass the unique date* to the method, and it'll simply go to that event on a specified timeline.

    If you wish to scroll smoothly to the timeline before changing to the event, then you can add an object with the optional settings:

    • smoothScroll[boolean] if set as true it enables the smooth scroll function. The default is false.
    • speed[integer], describes the speed of the smooth scroll in ms. The default is 500.
    • offset[integer], describes the offset from the top where the smooth scroll will stop. The default is 0 which means it will stop at the very top. Could also be a minus integer to offset in the opposite direction, e.g: -50
    • easing[string] describes the easing function of the smooth scroll. The default is linear. This could be useful for the various jQuery easing plugins.
    Note:
    • The selector must be the selector of a timeline that we are targetting.
    • * The date must match the target's unique date as set in the data object utilising the formats.
    • 0 or more optional settings can be set and can also be left out. If left out, then the default value will be used.
    • Before the method runs, the goToTimeline DOM event will be fired.
    // Smooth scroll disabled.
    						$('#example').horizontalTimeline('goTo', '01/01/2001');
    
    						// Smooth scroll enabled with the defaults.
    						$('#example').horizontalTimeline('goTo', '01/01/2001', {smoothScroll: true});
    
    						// Smooth scroll enabled with speed set and the rest as defaults.
    						$('#example').horizontalTimeline('goTo', '01/01/2001', {smoothScroll: true, speed: 1000});
    
    						// Smooth scroll enabled with all options set.
    						$('#example').horizontalTimeline('goTo', '01/01/2001', {smoothScroll: true, speed: 1000, offset: 100, easing: "easeInQuad"});
    					

DOM Events

DOM events allow you to listen for and run your own code when they are triggered under specific conditions.

  • initialised [attachable]

    The DOM event initialised.horizontalTimeline triggers every time a new timeline is initialised.

    It passes two bits of useful data within the event object:

    • instance specifies the instance of the timeline.
    • timelineSelector specifies the timeline selector as a jquery object.

    This event must be attached to the timeline selector used for the plugin.

    Note: This DOM event was created as a workaround for an error that occurred when a method is run straight after the initialisation code. Due to issues of timeline occasionally setting the wrong width, a setTimeout was used in the plugin to ensure the correct width was being set all the time, meaning that for 300ms after initialisation the methods would return an error. The DOM event is fired after the delay, therefore, if you need to use a method directly after initialisation, please use it inside this attachable event.

    
    						$('#example').horizontal-timeline();
    
    						$('#example').on("initialised.horizontalTimeline", function(event){
    							event.timelineSelector.horizontalTimeline('removeEvent', '01/01/2001');
    						});
    					
  • eventAdded [attachable]

    The DOM event eventAdded.horizontalTimeline triggers every time a new event is added using the public method.

    It passes two bits of useful data within the event object:

    • newEventDate specifies the date of the added event.
    • newEventContent specifies the HTML of the added content.

    This event must be attached to the timeline selector used for the plugin.

    
    						$('#example').on("eventAdded.horizontalTimeline", function(event){
    							if(event.newEventDate == "01/01/2001") {
    								...}
    							console.log('Added ' + event.newEventDate);
    						});
    					
  • eventRemoved [attachable]

    The DOM event eventRemoved.horizontalTimeline triggers every time an event is removed using the public method.

    It passes two bits of useful data within the event object:

    • removedDate specifies the date of the removed event.
    • removedContent specifies the HTML of the removed content.

    This event must be attached to the timeline selector used for the plugin.

    
    						$('#example').on("eventRemoved.horizontalTimeline", function(event){
    							if(event.removedDate == "01/01/2001") {
    								...}
    							console.log('Removed ' + event.removedDate);
    						});
    					
  • eventChanged [attachable]

    The DOM event eventChanged.horizontalTimeline triggers every time an event changes to a different one by:

    • Clicking the prev/next buttons
    • Clicking the timeline event
    • TouchSwiping left/right
    • Mousewheel scrolling left/right
    • Pressing keyboard keys left/right
    • Using Autoplay
    • Using Go-to Timeline links

    It passes one useful piece of data within the event object:

    • currentEventDate specifies the date of the new selected event.

    This event must be attached to the timeline selector used for the plugin.

    
    						$('#example').on("eventChanged.horizontalTimeline", function(event){
    							if(event.currentEventDate == "01/01/2001") {
    								...}
    							console.log('The new selected date is ' + event.currentEventDate);
    						});
    					
  • goToTimeline [attachable]

    The DOM event goToTimeline.horizontalTimeline triggers every time the goTo method is used (via the public method or internally through the use of go-to-timeline links) and fires before it runs the method.

    It passes two bits of useful data within the event object:

    • goToDate specifies the go-to date.
    • timelineSelector specifies the timeline selector as a jquery object.

    This event is only attachable to the body due to the possibility of go-to-timeline links in the DOM.

    
    						$('body').on("goToTimeline.horizontalTimeline", function(event){
    							if(event.goToDate == "01/01/2001") {
    								event.timelineSelector.addClass('goneTo');
    								...}
    							console.log('The date we are going to is: ' + event.goToDate +' and on the timeline: '+ event.timelineSelector[0].id);
    						});
    					

Methods and Events Sandbox

Use the controls below to play with the methods.

Add Event

All formats for the date are accepted, this is for the date in the data object.

Remove Event
Go To Event
Smooth Scroll Options

Use these settings for the smooth scroll. Please note, for demo purposes, the smooth scroll is permanently switched on and that if the controls are left empty, the defaults will be used.

The easing functions are provided by the jQuery Easing Plugin.

Go to timeline link
DOM Events Results
  1. 16/01/2014

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


Extras

  • The Buttons

    The prev/next buttons have been renamed to scroll-left and scroll-right respectively, to reflect their functionality:

    • Scroll-left button controls the left scrolling of the timeline.
    • Scroll-right button controls the right scrolling of the timeline.

    New prev/next buttons have been added which controls the event content:

    • Prev button changes the current event content to the previous content.
    • Next button changes the current event content to the next content.
  • Inactive Button States

    The buttons will become inactive under certain conditions:

    • If the first event is selected, then the prev button will become inactive and the next button will be active.
    • If the last event is selected, then the next button will become inactive and the prev button will be active.
    • If the timeline width is large enough to accommodate all events without having to scroll, then the scroll-left and scroll-right buttons will become inactive
    • If the timeline is at the start and can't physically scroll left, then the scroll-left button will become inactive , and the scroll-right button will be active.
    • If the timeline is at the end and can't physically scroll right, then the scroll-right button will become inactive , and the scroll-left button will be active.
  • Button Icons

    All button icons are provided by the font library Font Awesome (v5.8.2) and it's CSS file on cdnjs will be dynamically added to the head of the document, so there's no need to add it specifically. Though, if it's already apart of your project, don't worry, timeline will know that and won't add it again. If addRequiredFile option is set to false the required file won't be loaded at all.

    Despite being the primary choice, you might prefer to use another icon font library. With this in mind, you can disable the use of Font Awesome altogether by setting useFontAwesomeIcons option to false .

    By default the button icons have specific classes from Font Awesome, but you can change these to different icons to whatever you wish, inside or outside of Font Awesome, by changing the individual class options.

    There are 7 icon class options, either as the all new object option iconClass with key:value pairs, or the deprecated individual options.

    • base object key or iconBaseClass individual option, describes the class of the font library. You can also specify any other related class such as sizing.
    • scrollLeft object key or scrollLeft_iconClass individual option, describes the class of the scroll-left button icon.
    • scrollRight object key or scrollRight_iconClass individual option, describes the class of the scroll-right button icon.
    • prev object key or prev_iconClass individual option, describes the class of the prev button icon.
    • next object key or next_iconClass individual option, describes the class of the next button icon.
    • pause object key or pause_iconClass individual option, describes the class of the pause button icon.
    • play object key or play_iconClass individual option, describes the class of the play button icon.
    Note:

    If the deprecated individual options exist in the user options, then timeline will use them, otherwise it will default to the new object options.

    The deprecated individual options can not be used in conjunction with the object options... If both single and object options are set in the user options, the object will take precedence.

    
    					$('#example').horizontalTimeline({
    						iconClass: {
    							"base": "fas fa-3x",
    							"scrollLeft": "fa-chevron-circle-left",
    							"scrollRight": "fa-chevron-circle-right",
    							"prev": "fa-arrow-circle-left",
    							"next": "fa-arrow-circle-right",
    							"pause": "fa-pause-circle",
    							"play": "fa-play-circle"}
    						
    					});
  • Disabling The Buttons

    As per a request via email, the prev/next and scroll-left/right buttons can now be disabled. There are two options for this:

    • useNavBtns When set to false, this disables the prev/next buttons. The default is true.
    • useScrollBtns When set to false, this disables the scroll-left/right buttons. The default is true.

    Using the 2 aforementioned options, there are 4 different outcomes:

    • Both the nav (prev/next) buttons and the scroll (left/right) buttons are created and enabled - the default.
      
                              $('#example').horizontalTimeline({
      								useNavBtns: true,
                                  	useScrollBtns: true
                                      
      						});
    • Only the nav (prev/next) buttons are created and enabled.
      
                              $('#example').horizontalTimeline({
      								useNavBtns: true,
                                  	useScrollBtns: false
                                      
      						});
    • Only the scroll (left/right) buttons are created and enabled.
      
                              $('#example').horizontalTimeline({
      								useNavBtns: false,
                                  	useScrollBtns: true
                                      
      						});
    • None of the buttons are created at all and are disabled.
      
                              $('#example').horizontalTimeline({
      								useNavBtns: false,
                                  	useScrollBtns: false
                                      
      						});

    Note: When disabled, the buttons will never be created, so there will be no redundant HTML lying about.

  • Add Required Files

    By default, adding the required files for the Mousewheel, TouchSwipe and Font Awesome plugins is enabled. But you can disable this by setting the addRequiredFile option to false and timeline will not load any of the files at all, but will still call the plugins if their option is enabled.

    
    						$('#example').horizontalTimeline({
    							addRequiredFile: false
    						});
    					
  • Event Content Animation

    It is now possible to customise the animation of the event content using classes. So if you want to change the way the event content animates in and out, you can either utilise any class-based CSS animation libraries such as Animate.css or create your own animations.

    There are 3 options, either as the all new object option animationClass with key:value pairs, or the deprecated individual options.

    • base object key or animation_baseClass individual option can be used for the base class that may be required for the animation libraries and any additional classes such as speed.
      The default is animationSpeed that defines a 0.4s speed.
    • enter and exit object keys or enter_animationClass and exit_animationClass individual options are all objects that define the enter and exit classes and have two key:value pairs: left and right.

      These keys describe the classes that will be used when an event is selected, though which class is used is determined by the positioning of the new event, to the left or right of the current event. Therefore, if any event to the left of the current event is selected, the current event content will have the exit right class and the new content will have the enter left class. The event selected to the right of the current will have the vice versa effects.

      The default is enter-left enter-right exit-left and exit-right.

    Note:

    If the deprecated individual options exist in the user options, then timeline will use them, otherwise it will default to the new object options.

    The deprecated individual options can not be used in conjunction with the object options... If both single and object options are set in the user options, the object will take precedence.

    1. 16/01/2014

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

    2. 17/01/2014

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

    3. 18/01/2014

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

    4. 19/01/2014

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

    
    						$('#example').horizontalTimeline({
    							animationClass: {
    								"base": "animated fast",
    								"enter": {
    									"left": "rotateInDownLeft",
    									"right": "rotateInUpRight"},
    								"exit": {
    									"left": "rotateOutDownLeft",
    									"right": "rotateOutUpRight"}}
    						});
    					

Deprecated

Deprecated Item Replacing Object Object Key Deprecated in Which Version? Removed in Which Version?
data-date data-horizontal-timeline date v2.0.5-alpha.3 Will be in v2.0.6
data-custom-display customDisplay
desktopDateIntervals dateIntervals desktop v2.0.5.1
tabletDateIntervals tablet
mobileDateIntervals mobile
minimalFirstDateInterval minimal
iconBaseClass iconClass base
scrollLeft_iconClass scrollLeft
scrollRight_iconClass scrollRight
prev_iconClass prev
next_iconClass next
pause_iconClass pause
play_iconClass play
animation_baseClass animationClass base
enter_animationClass enter
exit_animationClass exit