feat: today button, improved scroll
chore: build
This commit is contained in:
parent
dd28b8ee0e
commit
2fd3aefd79
74
dist/frappe-gantt.css
vendored
74
dist/frappe-gantt.css
vendored
@ -66,18 +66,42 @@
|
|||||||
border-top-color: #333;
|
border-top-color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.gantt-container .grid-header {
|
||||||
|
background-color: #ffffff;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
.gantt-container .lower-text,
|
||||||
|
.gantt-container .upper-text {
|
||||||
|
font-size: 14px;
|
||||||
|
text-anchor: middle;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
.gantt-container .lower-text {
|
||||||
|
position: absolute;
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
.gantt-container #today-button {
|
||||||
|
position: sticky;
|
||||||
|
left: 10px;
|
||||||
|
top: 5px;
|
||||||
|
background-color: #2c94ec;
|
||||||
|
border: none;
|
||||||
|
color: #fff;
|
||||||
|
padding: 4px 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
.gantt {
|
.gantt {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
|
position: absolute;
|
||||||
}
|
}
|
||||||
.gantt .grid-background {
|
.gantt .grid-background {
|
||||||
fill: none;
|
fill: none;
|
||||||
}
|
}
|
||||||
.gantt .grid-header {
|
|
||||||
fill: #ffffff;
|
|
||||||
stroke: #e0e0e0;
|
|
||||||
stroke-width: 1.4;
|
|
||||||
}
|
|
||||||
.gantt .grid-row {
|
.gantt .grid-row {
|
||||||
fill: #ffffff;
|
fill: #ffffff;
|
||||||
}
|
}
|
||||||
@ -143,14 +167,14 @@
|
|||||||
fill: #fff;
|
fill: #fff;
|
||||||
}
|
}
|
||||||
.gantt .bar-label {
|
.gantt .bar-label {
|
||||||
fill: #333;
|
fill: #111;
|
||||||
dominant-baseline: central;
|
dominant-baseline: central;
|
||||||
font-family: Helvetica;
|
font-family: Helvetica;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
.gantt .bar-label.big {
|
.gantt .bar-label.big {
|
||||||
fill: #333;
|
fill: #111;
|
||||||
text-anchor: start;
|
text-anchor: start;
|
||||||
}
|
}
|
||||||
.gantt .bar-wrapper.important .bar {
|
.gantt .bar-wrapper.important .bar {
|
||||||
@ -172,43 +196,25 @@
|
|||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
transition: opacity 0.3s ease;
|
transition: opacity 0.3s ease;
|
||||||
}
|
}
|
||||||
.gantt:hover .handle {
|
.gantt .bar-wrapper {
|
||||||
|
cursor: pointer;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.gantt .bar-wrapper.active .handle {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
.gantt .bar-wrapper {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.gantt .bar-wrapper .bar {
|
.gantt .bar-wrapper .bar {
|
||||||
outline: groove 1px black;
|
-webkit-filter: drop-shadow(3px 3px 2px rgba(0, 0, 0, 0.7));
|
||||||
|
filter: drop-shadow(0 0 2px rgba(17, 43, 66, 0.16));
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
.gantt .bar-wrapper.important .bar {
|
|
||||||
outline: none;
|
|
||||||
outline-width: 1.5px;
|
|
||||||
}
|
|
||||||
.gantt .bar-wrapper.important .bar:active {
|
|
||||||
outline: 1px dotted;
|
|
||||||
}
|
|
||||||
.gantt .bar-wrapper:hover .bar {
|
.gantt .bar-wrapper:hover .bar {
|
||||||
outline-width: 1.5px;
|
|
||||||
transition: transform 0.3s ease;
|
transition: transform 0.3s ease;
|
||||||
}
|
}
|
||||||
.gantt .bar-wrapper:hover .date-highlight {
|
.gantt .bar-wrapper:hover .date-highlight {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.gantt .bar-wrapper.active .bar {
|
|
||||||
outline-style: dotted;
|
|
||||||
}
|
|
||||||
.gantt .lower-text,
|
|
||||||
.gantt .upper-text {
|
|
||||||
font-size: 14px;
|
|
||||||
text-anchor: middle;
|
|
||||||
}
|
|
||||||
.gantt .lower-text,
|
|
||||||
.gantt .upper-text {
|
|
||||||
fill: #333;
|
|
||||||
}
|
|
||||||
.gantt .hide {
|
.gantt .hide {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@ -228,6 +234,10 @@
|
|||||||
color: #959da5;
|
color: #959da5;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border: 1px solid rgb(0, 0, 0);
|
border: 1px solid rgb(0, 0, 0);
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
.gantt-container .popup-wrapper.hidden {
|
||||||
|
opacity: 0 !important;
|
||||||
}
|
}
|
||||||
.gantt-container .popup-wrapper .title {
|
.gantt-container .popup-wrapper .title {
|
||||||
border-bottom: 1px solid #dedfe0;
|
border-bottom: 1px solid #dedfe0;
|
||||||
|
|||||||
137
dist/frappe-gantt.js
vendored
137
dist/frappe-gantt.js
vendored
@ -437,7 +437,7 @@ var Gantt = (function () {
|
|||||||
this.duration *
|
this.duration *
|
||||||
(this.task.progress / 100) || 0;
|
(this.task.progress / 100) || 0;
|
||||||
this.group = createSVG("g", {
|
this.group = createSVG("g", {
|
||||||
class: "bar-wrapper " + (this.task.custom_class || "") + (this.task.important && 'important'),
|
class: "bar-wrapper" + (this.task.custom_class ? " " + this.task.custom_class : "") + (this.task.important ? ' important' : ''),
|
||||||
"data-id": this.task.id,
|
"data-id": this.task.id,
|
||||||
});
|
});
|
||||||
this.bar_group = createSVG("g", {
|
this.bar_group = createSVG("g", {
|
||||||
@ -672,25 +672,13 @@ var Gantt = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setup_click_event() {
|
setup_click_event() {
|
||||||
let in_action = false;
|
|
||||||
$.on(this.group, "mouseover", (e) => this.gantt.trigger_event("hover", [this.task, e.screenX, e.screenY, e]));
|
$.on(this.group, "mouseover", (e) => this.gantt.trigger_event("hover", [this.task, e.screenX, e.screenY, e]));
|
||||||
|
$.on(this.group, "mouseenter", (e) => this.show_popup(e.offsetX));
|
||||||
|
$.on(this.group, "mouseleave", () => this.gantt.hide_popup());
|
||||||
|
|
||||||
|
|
||||||
$.on(this.group, "focus " + this.gantt.options.popup_trigger, (e) => {
|
$.on(this.group, "focus " + this.gantt.options.popup_trigger, (e) => {
|
||||||
this.gantt.trigger_event("click", [this.task]);
|
this.gantt.trigger_event("click", [this.task]);
|
||||||
if (this.action_completed) {
|
|
||||||
// just finished a move action, wait for a few seconds
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (in_action) {
|
|
||||||
this.gantt.hide_popup();
|
|
||||||
this.group.classList.remove("active");
|
|
||||||
} else {
|
|
||||||
this.show_popup(e.offsetX);
|
|
||||||
this.gantt.unselect_all();
|
|
||||||
this.group.classList.add("active");
|
|
||||||
}
|
|
||||||
|
|
||||||
in_action = !in_action;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$.on(this.group, "dblclick", (e) => {
|
$.on(this.group, "dblclick", (e) => {
|
||||||
@ -716,7 +704,7 @@ var Gantt = (function () {
|
|||||||
"MMM D",
|
"MMM D",
|
||||||
this.gantt.options.language,
|
this.gantt.options.language,
|
||||||
);
|
);
|
||||||
const subtitle = start_date + " - " + end_date;
|
const subtitle = `${start_date} - ${end_date}<br/>Progress: ${this.task.progress}`;
|
||||||
|
|
||||||
this.gantt.show_popup({
|
this.gantt.show_popup({
|
||||||
x,
|
x,
|
||||||
@ -743,9 +731,11 @@ var Gantt = (function () {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.update_attr(bar, "x", x);
|
this.update_attr(bar, "x", x);
|
||||||
|
this.update_attr(this.$date_highlight, "x", x);
|
||||||
}
|
}
|
||||||
if (width) {
|
if (width) {
|
||||||
this.update_attr(bar, "width", width);
|
this.update_attr(bar, "width", width);
|
||||||
|
this.update_attr(this.$date_highlight, "width", width);
|
||||||
}
|
}
|
||||||
this.update_label_position();
|
this.update_label_position();
|
||||||
this.update_handle_position();
|
this.update_handle_position();
|
||||||
@ -1131,7 +1121,6 @@ var Gantt = (function () {
|
|||||||
// set data
|
// set data
|
||||||
this.title.innerHTML = options.title;
|
this.title.innerHTML = options.title;
|
||||||
this.subtitle.innerHTML = options.subtitle;
|
this.subtitle.innerHTML = options.subtitle;
|
||||||
this.parent.style.width = this.parent.clientWidth + "px";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set position
|
// set position
|
||||||
@ -1252,7 +1241,9 @@ var Gantt = (function () {
|
|||||||
language: "en",
|
language: "en",
|
||||||
readonly: false,
|
readonly: false,
|
||||||
highlight_weekend: true,
|
highlight_weekend: true,
|
||||||
scroll_today: true
|
scroll_today: true,
|
||||||
|
lines: 'both',
|
||||||
|
auto_move_label: true,
|
||||||
};
|
};
|
||||||
this.options = Object.assign({}, default_options, options);
|
this.options = Object.assign({}, default_options, options);
|
||||||
if (!options.view_mode_padding) options.view_mode_padding = {};
|
if (!options.view_mode_padding) options.view_mode_padding = {};
|
||||||
@ -1284,12 +1275,17 @@ var Gantt = (function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
task._end = date_utils.parse(task.end);
|
task._end = date_utils.parse(task.end);
|
||||||
|
let diff = date_utils.diff(task._end, task._start, "year");
|
||||||
|
if (diff < 0) {
|
||||||
|
console.log(task._end, task._start);
|
||||||
|
throw Error("start of task can't be after end of task: in task #, " + (i + 1))
|
||||||
|
}
|
||||||
// make task invalid if duration too large
|
// make task invalid if duration too large
|
||||||
if (date_utils.diff(task._end, task._start, "year") > 10) {
|
if (date_utils.diff(task._end, task._start, "year") > 10) {
|
||||||
task.end = null;
|
task.end = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// cache index
|
// cache index
|
||||||
task._index = i;
|
task._index = i;
|
||||||
|
|
||||||
@ -1495,7 +1491,7 @@ var Gantt = (function () {
|
|||||||
|
|
||||||
setup_layers() {
|
setup_layers() {
|
||||||
this.layers = {};
|
this.layers = {};
|
||||||
const layers = ["grid", "arrow", "progress", "bar", "details", "date"];
|
const layers = ["grid", "arrow", "progress", "bar", "details"];
|
||||||
// make group layers
|
// make group layers
|
||||||
for (let layer of layers) {
|
for (let layer of layers) {
|
||||||
this.layers[layer] = createSVG("g", {
|
this.layers[layer] = createSVG("g", {
|
||||||
@ -1526,7 +1522,7 @@ var Gantt = (function () {
|
|||||||
width: grid_width,
|
width: grid_width,
|
||||||
height: grid_height,
|
height: grid_height,
|
||||||
class: "grid-background",
|
class: "grid-background",
|
||||||
append_to: this.layers.date,
|
append_to: this.$svg,
|
||||||
});
|
});
|
||||||
|
|
||||||
$.attr(this.$svg, {
|
$.attr(this.$svg, {
|
||||||
@ -1553,34 +1549,39 @@ var Gantt = (function () {
|
|||||||
class: "grid-row",
|
class: "grid-row",
|
||||||
append_to: rows_layer,
|
append_to: rows_layer,
|
||||||
});
|
});
|
||||||
|
if (this.options.lines === 'both' || this.options.lines === 'horizontal') {
|
||||||
createSVG("line", {
|
createSVG("line", {
|
||||||
x1: 0,
|
x1: 0,
|
||||||
y1: row_y + row_height,
|
y1: row_y + row_height,
|
||||||
x2: row_width,
|
x2: row_width,
|
||||||
y2: row_y + row_height,
|
y2: row_y + row_height,
|
||||||
class: "row-line",
|
class: "row-line",
|
||||||
append_to: lines_layer,
|
append_to: lines_layer,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
row_y += this.options.bar_height + this.options.padding;
|
row_y += this.options.bar_height + this.options.padding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
make_grid_header() {
|
make_grid_header() {
|
||||||
const header_width = this.dates.length * this.options.column_width;
|
let $header = document.createElement("div");
|
||||||
const header_height = this.options.header_height + 10;
|
|
||||||
createSVG("rect", {
|
$header.style.height = this.options.header_height + 10 + "px";
|
||||||
x: 0,
|
$header.style.width = this.dates.length * this.options.column_width + "px";
|
||||||
y: 0,
|
$header.classList.add('grid-header');
|
||||||
width: header_width,
|
this.$header = $header;
|
||||||
height: header_height,
|
this.$svg.parentElement.appendChild($header);
|
||||||
class: "grid-header",
|
|
||||||
append_to: this.layers.grid,
|
let $today_button = document.createElement('button');
|
||||||
});
|
$today_button.id = 'today-button';
|
||||||
|
$today_button.textContent = 'Today';
|
||||||
|
$today_button.onclick = this.scroll_today.bind(this);
|
||||||
|
this.$header.appendChild($today_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
make_grid_ticks() {
|
make_grid_ticks() {
|
||||||
|
if (this.options.lines !== 'both' && this.options.lines !== 'vertical') return
|
||||||
let tick_x = 0;
|
let tick_x = 0;
|
||||||
let tick_y = this.options.header_height + this.options.padding / 2;
|
let tick_y = this.options.header_height + this.options.padding / 2;
|
||||||
let tick_height =
|
let tick_height =
|
||||||
@ -1721,25 +1722,23 @@ var Gantt = (function () {
|
|||||||
|
|
||||||
make_dates() {
|
make_dates() {
|
||||||
for (let date of this.get_dates_to_draw()) {
|
for (let date of this.get_dates_to_draw()) {
|
||||||
createSVG("text", {
|
let $lower_text = document.createElement('div');
|
||||||
x: date.lower_x,
|
$lower_text.classList.add('lower-text');
|
||||||
y: date.lower_y,
|
$lower_text.style.left = date.lower_x + 'px';
|
||||||
innerHTML: date.lower_text,
|
$lower_text.style.top = date.lower_y + 'px';
|
||||||
class: "lower-text",
|
$lower_text.innerText = date.lower_text;
|
||||||
append_to: this.layers.date,
|
this.$header.appendChild($lower_text);
|
||||||
});
|
|
||||||
|
|
||||||
if (date.upper_text) {
|
if (date.upper_text) {
|
||||||
const $upper_text = createSVG("text", {
|
let $upper_text = document.createElement('div');
|
||||||
x: date.upper_x,
|
$upper_text.classList.add('lower-text');
|
||||||
y: date.upper_y,
|
$upper_text.style.left = date.upper_x + 'px';
|
||||||
innerHTML: date.upper_text,
|
$upper_text.style.top = date.upper_y + 'px';
|
||||||
class: "upper-text",
|
$upper_text.innerText = date.upper_text;
|
||||||
append_to: this.layers.date,
|
this.$header.appendChild($upper_text);
|
||||||
});
|
|
||||||
|
|
||||||
// remove out-of-bound dates
|
// remove out-of-bound dates
|
||||||
if ($upper_text.getBBox().x2 > this.layers.grid.getBBox().width) {
|
if (date.upper_x > this.layers.grid.getBBox().width) {
|
||||||
$upper_text.remove();
|
$upper_text.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1809,8 +1808,8 @@ var Gantt = (function () {
|
|||||||
x: last_date_info
|
x: last_date_info
|
||||||
? last_date_info.base_pos_x + last_date_info.column_width
|
? last_date_info.base_pos_x + last_date_info.column_width
|
||||||
: 0,
|
: 0,
|
||||||
lower_y: this.options.header_height,
|
lower_y: this.options.header_height - 15,
|
||||||
upper_y: this.options.header_height - 25,
|
upper_y: this.options.header_height - 35,
|
||||||
};
|
};
|
||||||
|
|
||||||
const x_pos = {
|
const x_pos = {
|
||||||
@ -1829,7 +1828,7 @@ var Gantt = (function () {
|
|||||||
Year_lower: this.options.column_width / 2,
|
Year_lower: this.options.column_width / 2,
|
||||||
Year_upper: (this.options.column_width * 30) / 2,
|
Year_upper: (this.options.column_width * 30) / 2,
|
||||||
};
|
};
|
||||||
|
console.log(base_pos.x, x_pos[`${this.options.view_mode}_lower`],);
|
||||||
return {
|
return {
|
||||||
date,
|
date,
|
||||||
column_width,
|
column_width,
|
||||||
@ -1911,8 +1910,7 @@ var Gantt = (function () {
|
|||||||
(hours_before_first_task / this.options.step) *
|
(hours_before_first_task / this.options.step) *
|
||||||
this.options.column_width -
|
this.options.column_width -
|
||||||
this.options.column_width;
|
this.options.column_width;
|
||||||
|
console.log(parent_element.scrollTo({ left: scroll_pos, behavior: 'smooth' }));
|
||||||
parent_element.scrollLeft = scroll_pos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scroll_today() {
|
scroll_today() {
|
||||||
@ -1950,6 +1948,7 @@ var Gantt = (function () {
|
|||||||
|
|
||||||
$.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (e, element) => {
|
$.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (e, element) => {
|
||||||
const bar_wrapper = $.closest(".bar-wrapper", element);
|
const bar_wrapper = $.closest(".bar-wrapper", element);
|
||||||
|
bars.forEach((bar) => bar.group.classList.remove("active"));
|
||||||
|
|
||||||
if (element.classList.contains("left")) {
|
if (element.classList.contains("left")) {
|
||||||
is_resizing_left = true;
|
is_resizing_left = true;
|
||||||
@ -1960,6 +1959,7 @@ var Gantt = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bar_wrapper.classList.add("active");
|
bar_wrapper.classList.add("active");
|
||||||
|
this.popup.parent.classList.add('hidden');
|
||||||
|
|
||||||
x_on_start = e.offsetX;
|
x_on_start = e.offsetX;
|
||||||
y_on_start = e.offsetY;
|
y_on_start = e.offsetY;
|
||||||
@ -1986,8 +1986,6 @@ var Gantt = (function () {
|
|||||||
let localBars = [];
|
let localBars = [];
|
||||||
const ids = [];
|
const ids = [];
|
||||||
let dx;
|
let dx;
|
||||||
|
|
||||||
this.layers.date.setAttribute('transform', 'translate(0,' + e.currentTarget.scrollTop + ')');
|
|
||||||
if (x_on_scroll_start) {
|
if (x_on_scroll_start) {
|
||||||
dx = e.currentTarget.scrollLeft - x_on_scroll_start;
|
dx = e.currentTarget.scrollLeft - x_on_scroll_start;
|
||||||
}
|
}
|
||||||
@ -1998,10 +1996,11 @@ var Gantt = (function () {
|
|||||||
|
|
||||||
if (dx) {
|
if (dx) {
|
||||||
localBars = ids.map(id => this.get_bar(id));
|
localBars = ids.map(id => this.get_bar(id));
|
||||||
|
if (this.options.auto_move_label) {
|
||||||
localBars.forEach(bar => {
|
localBars.forEach(bar => {
|
||||||
bar.update_label_position_on_horizontal_scroll({ x: dx, sx: e.currentTarget.scrollLeft });
|
bar.update_label_position_on_horizontal_scroll({ x: dx, sx: e.currentTarget.scrollLeft });
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x_on_scroll_start = e.currentTarget.scrollLeft;
|
x_on_scroll_start = e.currentTarget.scrollLeft;
|
||||||
@ -2040,9 +2039,6 @@ var Gantt = (function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener("mouseup", (e) => {
|
document.addEventListener("mouseup", (e) => {
|
||||||
if (is_dragging || is_resizing_left || is_resizing_right) {
|
|
||||||
bars.forEach((bar) => bar.group.classList.remove("active"));
|
|
||||||
}
|
|
||||||
|
|
||||||
is_dragging = false;
|
is_dragging = false;
|
||||||
is_resizing_left = false;
|
is_resizing_left = false;
|
||||||
@ -2170,6 +2166,7 @@ var Gantt = (function () {
|
|||||||
[...this.$svg.querySelectorAll(".bar-wrapper")].forEach((el) => {
|
[...this.$svg.querySelectorAll(".bar-wrapper")].forEach((el) => {
|
||||||
el.classList.remove("active");
|
el.classList.remove("active");
|
||||||
});
|
});
|
||||||
|
this.popup.parent.classList.remove('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
view_is(modes) {
|
view_is(modes) {
|
||||||
|
|||||||
2
dist/frappe-gantt.js.map
vendored
2
dist/frappe-gantt.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/frappe-gantt.min.css
vendored
2
dist/frappe-gantt.min.css
vendored
@ -1 +1 @@
|
|||||||
.dark>.gantt-container .gantt .grid-header{fill:#252525;stroke:#616161}.dark>.gantt-container .gantt .grid-row{fill:#252525}.dark>.gantt-container .gantt .grid-row:nth-child(even){fill:#3e3e3e}.dark>.gantt-container .gantt .row-line{stroke:#3e3e3e}.dark>.gantt-container .gantt .tick{stroke:#616161}.dark>.gantt-container .gantt .today-highlight{opacity:.2}.dark>.gantt-container .gantt .arrow{stroke:#eee}.dark>.gantt-container .gantt .bar{fill:#616161;stroke:none}.dark>.gantt-container .gantt .bar-progress{fill:#8a8aff}.dark>.gantt-container .gantt .bar-invalid{fill:rgba(0,0,0,0);stroke:#c6ccd2}.dark>.gantt-container .gantt .bar-invalid~.bar-label{fill:#ececec}.dark>.gantt-container .gantt .bar-label.big{fill:#ececec}.dark>.gantt-container .gantt .bar-wrapper:hover .bar{fill:#6e6e6e}.dark>.gantt-container .gantt .bar-wrapper:hover .bar-progress{fill:#a4a4ff}.dark>.gantt-container .gantt .bar-wrapper.active .bar{fill:#6e6e6e}.dark>.gantt-container .gantt .bar-wrapper.active .bar-progress{fill:#a4a4ff}.dark>.gantt-container .gantt .upper-text{fill:#a2a2a2}.dark>.gantt-container .gantt .lower-text{fill:#f7f7f7}.dark>.gantt-container .popup-wrapper{background-color:#333}.dark>.gantt-container .popup-wrapper .title{border-color:#a4a4ff}.dark>.gantt-container .popup-wrapper .pointer{border-top-color:#333}.gantt{user-select:none;-webkit-user-select:none}.gantt .grid-background{fill:none}.gantt .grid-header{fill:#fff;stroke:#e0e0e0;stroke-width:1.4}.gantt .grid-row{fill:#fff}.gantt .row-line{stroke:#ebeff2}.gantt .tick{stroke:#e0e0e0;stroke-width:.2}.gantt .tick.thick{stroke:#000;stroke-width:.5}.gantt .today-highlight{fill:#f6e796;opacity:.5}.gantt .week-highlight{fill:#f6e796;opacity:.5}.gantt .holiday-highlight{fill:#f3f4f7;opacity:.5}.gantt .month-highlight{fill:#f6e796;opacity:.5}.gantt .year-highlight{fill:#f6e796;opacity:.5}.gantt .arrow{fill:none;stroke:#666;stroke-width:1.4}.gantt .bar-wrapper .bar{fill:#fff;stroke:#fff;stroke-width:0;transition:stroke-width .3s ease}.gantt .bar-progress{fill:#dedfe0}.gantt .date-highlight{fill:#e8e8e8;display:none}.gantt .bar-expected-progress{fill:#c4c4e9}.gantt .bar-invalid{fill:rgba(0,0,0,0);stroke:#fff;stroke-width:1;stroke-dasharray:5}.gantt .bar-invalid~.bar-label{fill:#fff}.gantt .bar-label{fill:#333;dominant-baseline:central;font-family:Helvetica;font-size:14px;font-weight:400}.gantt .bar-label.big{fill:#333;text-anchor:start}.gantt .bar-wrapper.important .bar{fill:#94c4f4}.gantt .bar-wrapper.important .bar-progress{fill:#2c94ec}.gantt .bar-wrapper.important .bar-label{fill:#fff}.gantt .bar-wrapper.important .handle{fill:#94c4f4}.gantt .handle{fill:#dcdce4;cursor:ew-resize;opacity:0;visibility:hidden;transition:opacity .3s ease}.gantt:hover .handle{visibility:visible;opacity:1}.gantt .bar-wrapper{cursor:pointer}.gantt .bar-wrapper .bar{outline:groove 1px #000;border-radius:3px}.gantt .bar-wrapper.important .bar{outline:none;outline-width:1.5px}.gantt .bar-wrapper.important .bar:active{outline:1px dotted}.gantt .bar-wrapper:hover .bar{outline-width:1.5px;transition:transform .3s ease}.gantt .bar-wrapper:hover .date-highlight{display:block}.gantt .bar-wrapper.active .bar{outline-style:dotted}.gantt .lower-text,.gantt .upper-text{font-size:14px;text-anchor:middle}.gantt .lower-text,.gantt .upper-text{fill:#333}.gantt .hide{display:none}.gantt-container{position:relative;overflow:auto;font-size:12px;height:500px}.gantt-container .popup-wrapper{position:absolute;top:0;left:0;background:#000;padding:0;color:#959da5;border-radius:3px;border:1px solid #000}.gantt-container .popup-wrapper .title{border-bottom:1px solid #dedfe0;padding:10px;text-align:center;color:#fff}.gantt-container .popup-wrapper .subtitle{padding:10px;color:#dfe2e5}.gantt-container .popup-wrapper .pointer{position:absolute;height:5px;margin:0 0 0 -5px;border:5px solid rgba(0,0,0,0);border-bottom-color:rgba(0,0,0,.8)}
|
.dark>.gantt-container .gantt .grid-header{fill:#252525;stroke:#616161}.dark>.gantt-container .gantt .grid-row{fill:#252525}.dark>.gantt-container .gantt .grid-row:nth-child(even){fill:#3e3e3e}.dark>.gantt-container .gantt .row-line{stroke:#3e3e3e}.dark>.gantt-container .gantt .tick{stroke:#616161}.dark>.gantt-container .gantt .today-highlight{opacity:.2}.dark>.gantt-container .gantt .arrow{stroke:#eee}.dark>.gantt-container .gantt .bar{fill:#616161;stroke:none}.dark>.gantt-container .gantt .bar-progress{fill:#8a8aff}.dark>.gantt-container .gantt .bar-invalid{fill:rgba(0,0,0,0);stroke:#c6ccd2}.dark>.gantt-container .gantt .bar-invalid~.bar-label{fill:#ececec}.dark>.gantt-container .gantt .bar-label.big{fill:#ececec}.dark>.gantt-container .gantt .bar-wrapper:hover .bar{fill:#6e6e6e}.dark>.gantt-container .gantt .bar-wrapper:hover .bar-progress{fill:#a4a4ff}.dark>.gantt-container .gantt .bar-wrapper.active .bar{fill:#6e6e6e}.dark>.gantt-container .gantt .bar-wrapper.active .bar-progress{fill:#a4a4ff}.dark>.gantt-container .gantt .upper-text{fill:#a2a2a2}.dark>.gantt-container .gantt .lower-text{fill:#f7f7f7}.dark>.gantt-container .popup-wrapper{background-color:#333}.dark>.gantt-container .popup-wrapper .title{border-color:#a4a4ff}.dark>.gantt-container .popup-wrapper .pointer{border-top-color:#333}.gantt-container .grid-header{background-color:#fff;position:sticky;top:0;left:0}.gantt-container .lower-text,.gantt-container .upper-text{font-size:14px;text-anchor:middle;color:#666}.gantt-container .lower-text{position:absolute;width:fit-content}.gantt-container #today-button{position:sticky;left:10px;top:5px;background-color:#2c94ec;border:none;color:#fff;padding:4px 10px;font-size:14px;border-radius:2px}.gantt{user-select:none;-webkit-user-select:none;position:absolute}.gantt .grid-background{fill:none}.gantt .grid-row{fill:#fff}.gantt .row-line{stroke:#ebeff2}.gantt .tick{stroke:#e0e0e0;stroke-width:.2}.gantt .tick.thick{stroke:#000;stroke-width:.5}.gantt .today-highlight{fill:#f6e796;opacity:.5}.gantt .week-highlight{fill:#f6e796;opacity:.5}.gantt .holiday-highlight{fill:#f3f4f7;opacity:.5}.gantt .month-highlight{fill:#f6e796;opacity:.5}.gantt .year-highlight{fill:#f6e796;opacity:.5}.gantt .arrow{fill:none;stroke:#666;stroke-width:1.4}.gantt .bar-wrapper .bar{fill:#fff;stroke:#fff;stroke-width:0;transition:stroke-width .3s ease}.gantt .bar-progress{fill:#dedfe0}.gantt .date-highlight{fill:#e8e8e8;display:none}.gantt .bar-expected-progress{fill:#c4c4e9}.gantt .bar-invalid{fill:rgba(0,0,0,0);stroke:#fff;stroke-width:1;stroke-dasharray:5}.gantt .bar-invalid~.bar-label{fill:#fff}.gantt .bar-label{fill:#111;dominant-baseline:central;font-family:Helvetica;font-size:14px;font-weight:400}.gantt .bar-label.big{fill:#111;text-anchor:start}.gantt .bar-wrapper.important .bar{fill:#94c4f4}.gantt .bar-wrapper.important .bar-progress{fill:#2c94ec}.gantt .bar-wrapper.important .bar-label{fill:#fff}.gantt .bar-wrapper.important .handle{fill:#94c4f4}.gantt .handle{fill:#dcdce4;cursor:ew-resize;opacity:0;visibility:hidden;transition:opacity .3s ease}.gantt .bar-wrapper{cursor:pointer;outline:none}.gantt .bar-wrapper.active .handle{visibility:visible;opacity:1}.gantt .bar-wrapper .bar{-webkit-filter:drop-shadow(3px 3px 2px rgba(0, 0, 0, 0.7));filter:drop-shadow(0 0 2px rgba(17, 43, 66, 0.16));border-radius:3px}.gantt .bar-wrapper:hover .bar{transition:transform .3s ease}.gantt .bar-wrapper:hover .date-highlight{display:block}.gantt .hide{display:none}.gantt-container{position:relative;overflow:auto;font-size:12px;height:500px}.gantt-container .popup-wrapper{position:absolute;top:0;left:0;background:#000;padding:0;color:#959da5;border-radius:3px;border:1px solid #000;width:max-content}.gantt-container .popup-wrapper.hidden{opacity:0 !important}.gantt-container .popup-wrapper .title{border-bottom:1px solid #dedfe0;padding:10px;text-align:center;color:#fff}.gantt-container .popup-wrapper .subtitle{padding:10px;color:#dfe2e5}.gantt-container .popup-wrapper .pointer{position:absolute;height:5px;margin:0 0 0 -5px;border:5px solid rgba(0,0,0,0);border-bottom-color:rgba(0,0,0,.8)}
|
||||||
2
dist/frappe-gantt.min.js
vendored
2
dist/frappe-gantt.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/frappe-gantt.min.js.map
vendored
2
dist/frappe-gantt.min.js.map
vendored
File diff suppressed because one or more lines are too long
23
index.html
23
index.html
@ -34,14 +34,14 @@
|
|||||||
<script>
|
<script>
|
||||||
let tasks = [
|
let tasks = [
|
||||||
{
|
{
|
||||||
start: '2024-10-01',
|
start: '2024-04-01',
|
||||||
end: '2024-10-08',
|
end: '2024-04-08',
|
||||||
name: 'Redesign website',
|
name: 'Redesign website',
|
||||||
id: "Task 0",
|
id: "Task 0",
|
||||||
progress: 30
|
progress: 30
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
start: '2024-09-26',
|
start: '2024-03-26',
|
||||||
// Utilizes duration
|
// Utilizes duration
|
||||||
duration: '6d',
|
duration: '6d',
|
||||||
name: 'Write new content',
|
name: 'Write new content',
|
||||||
@ -50,32 +50,32 @@
|
|||||||
important: true
|
important: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
start: '2024-10-04',
|
start: '2024-04-04',
|
||||||
end: '2024-10-08',
|
end: '2024-04-08',
|
||||||
name: 'Apply new styles',
|
name: 'Apply new styles',
|
||||||
id: "Task 2",
|
id: "Task 2",
|
||||||
progress: 80,
|
progress: 80,
|
||||||
dependencies: 'Task 1'
|
dependencies: 'Task 1'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
start: '2024-10-08',
|
start: '2024-04-08',
|
||||||
end: '2024-10-09',
|
end: '2024-04-09',
|
||||||
name: 'Review',
|
name: 'Review',
|
||||||
id: "Task 3",
|
id: "Task 3",
|
||||||
progress: 5,
|
progress: 5,
|
||||||
dependencies: 'Task 2'
|
dependencies: 'Task 2'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
start: '2024-10-08',
|
start: '2024-04-08',
|
||||||
end: '2024-10-10',
|
end: '2024-04-10',
|
||||||
name: 'Deploy',
|
name: 'Deploy',
|
||||||
id: "Task 4",
|
id: "Task 4",
|
||||||
progress: 0,
|
progress: 0,
|
||||||
// dependencies: 'Task 2'
|
// dependencies: 'Task 2'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
start: '2024-10-11',
|
start: '2024-04-21',
|
||||||
end: '2024-10-11',
|
end: '2024-04-29',
|
||||||
name: 'Go Live!',
|
name: 'Go Live!',
|
||||||
id: "Task 5",
|
id: "Task 5",
|
||||||
progress: 0,
|
progress: 0,
|
||||||
@ -116,6 +116,7 @@
|
|||||||
view_mode: "Day",
|
view_mode: "Day",
|
||||||
view_mode_padding: { DAY: "7d" },
|
view_mode_padding: { DAY: "7d" },
|
||||||
language: "en",
|
language: "en",
|
||||||
|
scroll_today: false,
|
||||||
// readonly: true
|
// readonly: true
|
||||||
});
|
});
|
||||||
console.log(gantt_chart);
|
console.log(gantt_chart);
|
||||||
|
|||||||
@ -36,6 +36,18 @@ $light-blue: #c4c4e9 !default;
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#today-button {
|
||||||
|
position: sticky;
|
||||||
|
left: 10px;
|
||||||
|
top: 5px;
|
||||||
|
background-color: $progress-important;
|
||||||
|
border: none;
|
||||||
|
color: $text-light;
|
||||||
|
padding: 4px 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.gantt {
|
.gantt {
|
||||||
|
|||||||
24
src/index.js
24
src/index.js
@ -424,13 +424,19 @@ export default class Gantt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
make_grid_header() {
|
make_grid_header() {
|
||||||
let header = document.createElement("div");
|
let $header = document.createElement("div");
|
||||||
|
|
||||||
header.style.height = this.options.header_height + 10 + "px";
|
$header.style.height = this.options.header_height + 10 + "px";
|
||||||
header.style.width = this.dates.length * this.options.column_width + "px";
|
$header.style.width = this.dates.length * this.options.column_width + "px";
|
||||||
header.classList.add('grid-header')
|
$header.classList.add('grid-header')
|
||||||
this.$header = header
|
this.$header = $header
|
||||||
this.$svg.parentElement.appendChild(header)
|
this.$svg.parentElement.appendChild($header)
|
||||||
|
|
||||||
|
let $today_button = document.createElement('button')
|
||||||
|
$today_button.id = 'today-button'
|
||||||
|
$today_button.textContent = 'Today'
|
||||||
|
$today_button.onclick = this.scroll_today.bind(this)
|
||||||
|
this.$header.appendChild($today_button)
|
||||||
}
|
}
|
||||||
|
|
||||||
make_grid_ticks() {
|
make_grid_ticks() {
|
||||||
@ -681,7 +687,7 @@ export default class Gantt {
|
|||||||
Year_lower: this.options.column_width / 2,
|
Year_lower: this.options.column_width / 2,
|
||||||
Year_upper: (this.options.column_width * 30) / 2,
|
Year_upper: (this.options.column_width * 30) / 2,
|
||||||
};
|
};
|
||||||
|
console.log(base_pos.x, x_pos[`${this.options.view_mode}_lower`],)
|
||||||
return {
|
return {
|
||||||
date,
|
date,
|
||||||
column_width,
|
column_width,
|
||||||
@ -763,8 +769,7 @@ export default class Gantt {
|
|||||||
(hours_before_first_task / this.options.step) *
|
(hours_before_first_task / this.options.step) *
|
||||||
this.options.column_width -
|
this.options.column_width -
|
||||||
this.options.column_width;
|
this.options.column_width;
|
||||||
|
console.log(parent_element.scrollTo({ left: scroll_pos, behavior: 'smooth' }))
|
||||||
parent_element.scrollLeft = scroll_pos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scroll_today() {
|
scroll_today() {
|
||||||
@ -840,7 +845,6 @@ export default class Gantt {
|
|||||||
let localBars = [];
|
let localBars = [];
|
||||||
const ids = [];
|
const ids = [];
|
||||||
let dx;
|
let dx;
|
||||||
|
|
||||||
if (x_on_scroll_start) {
|
if (x_on_scroll_start) {
|
||||||
dx = e.currentTarget.scrollLeft - x_on_scroll_start;
|
dx = e.currentTarget.scrollLeft - x_on_scroll_start;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user