Merge branch 'master' of github.com:frappe/gantt
This commit is contained in:
commit
d432ab200e
16
src/Gantt.js
16
src/Gantt.js
@ -1,7 +1,7 @@
|
|||||||
/* global moment, Snap */
|
/* global moment, Snap */
|
||||||
/**
|
/**
|
||||||
* Gantt:
|
* Gantt:
|
||||||
* element: querySelector string, required
|
* element: querySelector string, HTML DOM or SVG DOM element, required
|
||||||
* tasks: array of tasks, required
|
* tasks: array of tasks, required
|
||||||
* task: { id, name, start, end, progress, dependencies, custom_class }
|
* task: { id, name, start, end, progress, dependencies, custom_class }
|
||||||
* config: configuration options, optional
|
* config: configuration options, optional
|
||||||
@ -60,8 +60,17 @@ export default function Gantt(element, tasks, config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reset_variables(tasks) {
|
function reset_variables(tasks) {
|
||||||
|
if(typeof element === 'string') {
|
||||||
|
self.element = document.querySelector(element);
|
||||||
|
} else if (element instanceof SVGElement) {
|
||||||
|
self.element = element;
|
||||||
|
} else if (element instanceof HTMLElement) {
|
||||||
|
self.element = element.querySelector('svg');
|
||||||
|
} else {
|
||||||
|
throw new TypeError('Frappé Gantt only supports usage of a string CSS selector,' +
|
||||||
|
' HTML DOM element or SVG DOM element for the \'element\' parameter');
|
||||||
|
}
|
||||||
|
|
||||||
self.element = element;
|
|
||||||
self._tasks = tasks;
|
self._tasks = tasks;
|
||||||
|
|
||||||
self._bars = [];
|
self._bars = [];
|
||||||
@ -265,7 +274,8 @@ export default function Gantt(element, tasks, config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function set_scroll_position() {
|
function set_scroll_position() {
|
||||||
const parent_element = document.querySelector(self.element).parentElement;
|
const parent_element = self.element.parentElement;
|
||||||
|
|
||||||
if(!parent_element) return;
|
if(!parent_element) return;
|
||||||
|
|
||||||
const scroll_pos = get_min_date().diff(self.gantt_start, 'hours') /
|
const scroll_pos = get_min_date().diff(self.gantt_start, 'hours') /
|
||||||
|
|||||||
@ -72,7 +72,6 @@ $handle-color: #ddd;
|
|||||||
text-anchor: middle;
|
text-anchor: middle;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: lighter;
|
font-weight: lighter;
|
||||||
letter-spacing: 0.8px;
|
|
||||||
|
|
||||||
&.big {
|
&.big {
|
||||||
fill: $text-light;
|
fill: $text-light;
|
||||||
@ -150,4 +149,4 @@ $handle-color: #ddd;
|
|||||||
.hide {
|
.hide {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user