`
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:
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>
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>
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
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.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.
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"}'
Initialise the timeline with jQuery using the default options.
<script>$('#example').horizontalTimeline();</script>
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"});
/* 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]
});
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!
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
minimal
will always return true
regardless of whether it is set to false. This is to keep mobile viewing
easy. At 0px.
At 200px (desktop), 150px (tablet), or 120px (mobile).
$('#example').horizontalTimeline({
dateIntervals: {
"desktop": 200,
"tablet": 150,
"mobile": 120,
"minimal": true}
});
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
Set the date in any of the formats.
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.
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.
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.
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.
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.
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"
});
Set the date in the format of DD/MM/YYYY or DD/MM/YYYYTHH:MM.
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.
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.
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.
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.
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"
});
Set the date in the format of HH:MM or DD/MM/YYYYTHH:MM.
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.
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.
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.
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.
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"
});
Set the date in the format of DD/MM/YYYY or DD/MM/YYYYTHH:MM.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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"
});
Set the date in the format of DD/MM/YYYY or DD/MM/YYYYTHH:MM.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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"
});
Set the date in the format of DD/MM/YYYY or DD/MM/YYYYTHH:MM.
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.
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.
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.
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.
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"
});
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.
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.
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.
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.
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>
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:
normal
,
the order of the date display is the same as their corresponding
event content and the selection process starts on the left. 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. selected
class
then the selection process is skipped naturally. 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.
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.
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.
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.
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"
});
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.
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.
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.
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.
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.
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>
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>
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="#"
class
specifies the button we are using as the go-to link. This must be goto-horizontal-timeline
to keep things easy. data-gototimeline
attribute describes the go-to timeline options. The options are defined
as an object.
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. 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. 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. 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
The go-to timeline link works just like any other link, so you can use it:
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.
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.
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.
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
});
Touch events for mobile and touch screen devices are provided by the jQuery TouchSwipe plugin.
useTouchSwipe
enables the TouchSwipe functionality. The default is true
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.
There's 2 ways TouchSwipe is implemented:
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 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
});
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
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.
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.
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
});
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.
The refresh
method allows you to refresh the timeline if:
$('#example').horizontalTimeline('refresh');
The destroy
method allows you to completely destroy the timeline:
$('#example').horizontalTimeline('destroy');
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:
date
portion of the data object as usual.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.
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.
$('#example').horizontalTimeline('removeEvent', '01/01/2001');
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.// 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 allow you to listen for and run your own code when they are triggered under specific conditions.
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.
$('#example').horizontal-timeline();
$('#example').on("initialised.horizontalTimeline", function(event){
event.timelineSelector.horizontalTimeline('removeEvent', '01/01/2001');
});
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);
});
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);
});
The DOM event eventChanged.horizontalTimeline
triggers every time an event changes to a different one by:
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);
});
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);
});
Use the controls below to play with the methods.
All formats for the date are accepted, this is for the date in the data object.
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.
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.
The buttons will become inactive
under certain conditions:
inactive
and the next button will be active. inactive
and the prev button will be active. inactive
inactive
, and the scroll-right button will be active. inactive
, and the scroll-left button will be active. 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:
$('#example').horizontalTimeline({
useNavBtns: true,
useScrollBtns: true
});
$('#example').horizontalTimeline({
useNavBtns: true,
useScrollBtns: false
});
$('#example').horizontalTimeline({
useNavBtns: false,
useScrollBtns: true
});
$('#example').horizontalTimeline({
useNavBtns: false,
useScrollBtns: false
});
Note: When disabled, the buttons will never be created, so there will be no redundant HTML lying about.
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
});
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. 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
.
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.
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.
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.
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.
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 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 |