From d77275e3d1b3f1b105bf90c01864ed7e42720be9 Mon Sep 17 00:00:00 2001
From: jos
Add new vertical bar representing a custom time that can be dragged by the user.
Parameter
diff --git a/examples/timeline/other/customTimeBars.html b/examples/timeline/other/customTimeBars.html
index 4794904c..37310165 100644
--- a/examples/timeline/other/customTimeBars.html
+++ b/examples/timeline/other/customTimeBars.html
@@ -25,7 +25,7 @@
time can be a Date, Number, or String, and is new Date() by default.
- Parameter id can be Number or String and is undefined by default.
- Returns id of the created bar.
+ Parameter id can be Number or String and is undefined by default.
+ The idcode> is added as CSS class name of the custom time bar, allowing to style multiple time bars differently.
+ The method returns id of the created bar.
- +
timechange event, index: , time:
@@ -49,7 +49,7 @@
// Set first time bar
customDate = new Date(customDate.getFullYear(), customDate.getMonth(), customDate.getDate() + 1);
- timeline.addCustomTime(customDate, '1');
+ timeline.addCustomTime(customDate, 't1');
document.getElementById('add').onclick = function () {
try {
diff --git a/lib/timeline/component/CustomTime.js b/lib/timeline/component/CustomTime.js
index 8efdb8ca..86aec043 100644
--- a/lib/timeline/component/CustomTime.js
+++ b/lib/timeline/component/CustomTime.js
@@ -34,10 +34,10 @@ function CustomTime (body, options) {
this.eventParams = {}; // stores state parameters while dragging the bar
+ this.setOptions(options);
+
// create the DOM
this._create();
-
- this.setOptions(options);
}
CustomTime.prototype = new Component();
@@ -63,7 +63,7 @@ CustomTime.prototype.setOptions = function(options) {
CustomTime.prototype._create = function() {
var bar = document.createElement('div');
bar['custom-time'] = this;
- bar.className = 'vis-custom-time';
+ bar.className = 'vis-custom-time ' + (this.options.id || '');
bar.style.position = 'absolute';
bar.style.top = '0px';
bar.style.height = '100%';