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;
|
||||
}
|
||||
|
||||
.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 {
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
position: absolute;
|
||||
}
|
||||
.gantt .grid-background {
|
||||
fill: none;
|
||||
}
|
||||
.gantt .grid-header {
|
||||
fill: #ffffff;
|
||||
stroke: #e0e0e0;
|
||||
stroke-width: 1.4;
|
||||
}
|
||||
.gantt .grid-row {
|
||||
fill: #ffffff;
|
||||
}
|
||||
@ -143,14 +167,14 @@
|
||||
fill: #fff;
|
||||
}
|
||||
.gantt .bar-label {
|
||||
fill: #333;
|
||||
fill: #111;
|
||||
dominant-baseline: central;
|
||||
font-family: Helvetica;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
}
|
||||
.gantt .bar-label.big {
|
||||
fill: #333;
|
||||
fill: #111;
|
||||
text-anchor: start;
|
||||
}
|
||||
.gantt .bar-wrapper.important .bar {
|
||||
@ -172,43 +196,25 @@
|
||||
visibility: hidden;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
.gantt:hover .handle {
|
||||
.gantt .bar-wrapper {
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
}
|
||||
.gantt .bar-wrapper.active .handle {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
}
|
||||
.gantt .bar-wrapper {
|
||||
cursor: pointer;
|
||||
}
|
||||
.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;
|
||||
}
|
||||
.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 0.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;
|
||||
}
|
||||
@ -228,6 +234,10 @@
|
||||
color: #959da5;
|
||||
border-radius: 3px;
|
||||
border: 1px solid rgb(0, 0, 0);
|
||||
width: max-content;
|
||||
}
|
||||
.gantt-container .popup-wrapper.hidden {
|
||||
opacity: 0 !important;
|
||||
}
|
||||
.gantt-container .popup-wrapper .title {
|
||||
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.task.progress / 100) || 0;
|
||||
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,
|
||||
});
|
||||
this.bar_group = createSVG("g", {
|
||||
@ -672,25 +672,13 @@ var Gantt = (function () {
|
||||
}
|
||||
|
||||
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, "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) => {
|
||||
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) => {
|
||||
@ -716,7 +704,7 @@ var Gantt = (function () {
|
||||
"MMM D",
|
||||
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({
|
||||
x,
|
||||
@ -743,9 +731,11 @@ var Gantt = (function () {
|
||||
return;
|
||||
}
|
||||
this.update_attr(bar, "x", x);
|
||||
this.update_attr(this.$date_highlight, "x", x);
|
||||
}
|
||||
if (width) {
|
||||
this.update_attr(bar, "width", width);
|
||||
this.update_attr(this.$date_highlight, "width", width);
|
||||
}
|
||||
this.update_label_position();
|
||||
this.update_handle_position();
|
||||
@ -1131,7 +1121,6 @@ var Gantt = (function () {
|
||||
// set data
|
||||
this.title.innerHTML = options.title;
|
||||
this.subtitle.innerHTML = options.subtitle;
|
||||
this.parent.style.width = this.parent.clientWidth + "px";
|
||||
}
|
||||
|
||||
// set position
|
||||
@ -1252,7 +1241,9 @@ var Gantt = (function () {
|
||||
language: "en",
|
||||
readonly: false,
|
||||
highlight_weekend: true,
|
||||
scroll_today: true
|
||||
scroll_today: true,
|
||||
lines: 'both',
|
||||
auto_move_label: true,
|
||||
};
|
||||
this.options = Object.assign({}, default_options, options);
|
||||
if (!options.view_mode_padding) options.view_mode_padding = {};
|
||||
@ -1284,12 +1275,17 @@ var Gantt = (function () {
|
||||
});
|
||||
}
|
||||
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
|
||||
if (date_utils.diff(task._end, task._start, "year") > 10) {
|
||||
task.end = null;
|
||||
}
|
||||
|
||||
|
||||
// cache index
|
||||
task._index = i;
|
||||
|
||||
@ -1495,7 +1491,7 @@ var Gantt = (function () {
|
||||
|
||||
setup_layers() {
|
||||
this.layers = {};
|
||||
const layers = ["grid", "arrow", "progress", "bar", "details", "date"];
|
||||
const layers = ["grid", "arrow", "progress", "bar", "details"];
|
||||
// make group layers
|
||||
for (let layer of layers) {
|
||||
this.layers[layer] = createSVG("g", {
|
||||
@ -1526,7 +1522,7 @@ var Gantt = (function () {
|
||||
width: grid_width,
|
||||
height: grid_height,
|
||||
class: "grid-background",
|
||||
append_to: this.layers.date,
|
||||
append_to: this.$svg,
|
||||
});
|
||||
|
||||
$.attr(this.$svg, {
|
||||
@ -1553,34 +1549,39 @@ var Gantt = (function () {
|
||||
class: "grid-row",
|
||||
append_to: rows_layer,
|
||||
});
|
||||
|
||||
createSVG("line", {
|
||||
x1: 0,
|
||||
y1: row_y + row_height,
|
||||
x2: row_width,
|
||||
y2: row_y + row_height,
|
||||
class: "row-line",
|
||||
append_to: lines_layer,
|
||||
});
|
||||
if (this.options.lines === 'both' || this.options.lines === 'horizontal') {
|
||||
createSVG("line", {
|
||||
x1: 0,
|
||||
y1: row_y + row_height,
|
||||
x2: row_width,
|
||||
y2: row_y + row_height,
|
||||
class: "row-line",
|
||||
append_to: lines_layer,
|
||||
});
|
||||
}
|
||||
|
||||
row_y += this.options.bar_height + this.options.padding;
|
||||
}
|
||||
}
|
||||
|
||||
make_grid_header() {
|
||||
const header_width = this.dates.length * this.options.column_width;
|
||||
const header_height = this.options.header_height + 10;
|
||||
createSVG("rect", {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: header_width,
|
||||
height: header_height,
|
||||
class: "grid-header",
|
||||
append_to: this.layers.grid,
|
||||
});
|
||||
let $header = document.createElement("div");
|
||||
|
||||
$header.style.height = this.options.header_height + 10 + "px";
|
||||
$header.style.width = this.dates.length * this.options.column_width + "px";
|
||||
$header.classList.add('grid-header');
|
||||
this.$header = $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() {
|
||||
if (this.options.lines !== 'both' && this.options.lines !== 'vertical') return
|
||||
let tick_x = 0;
|
||||
let tick_y = this.options.header_height + this.options.padding / 2;
|
||||
let tick_height =
|
||||
@ -1721,25 +1722,23 @@ var Gantt = (function () {
|
||||
|
||||
make_dates() {
|
||||
for (let date of this.get_dates_to_draw()) {
|
||||
createSVG("text", {
|
||||
x: date.lower_x,
|
||||
y: date.lower_y,
|
||||
innerHTML: date.lower_text,
|
||||
class: "lower-text",
|
||||
append_to: this.layers.date,
|
||||
});
|
||||
let $lower_text = document.createElement('div');
|
||||
$lower_text.classList.add('lower-text');
|
||||
$lower_text.style.left = date.lower_x + 'px';
|
||||
$lower_text.style.top = date.lower_y + 'px';
|
||||
$lower_text.innerText = date.lower_text;
|
||||
this.$header.appendChild($lower_text);
|
||||
|
||||
if (date.upper_text) {
|
||||
const $upper_text = createSVG("text", {
|
||||
x: date.upper_x,
|
||||
y: date.upper_y,
|
||||
innerHTML: date.upper_text,
|
||||
class: "upper-text",
|
||||
append_to: this.layers.date,
|
||||
});
|
||||
let $upper_text = document.createElement('div');
|
||||
$upper_text.classList.add('lower-text');
|
||||
$upper_text.style.left = date.upper_x + 'px';
|
||||
$upper_text.style.top = date.upper_y + 'px';
|
||||
$upper_text.innerText = date.upper_text;
|
||||
this.$header.appendChild($upper_text);
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
@ -1809,8 +1808,8 @@ var Gantt = (function () {
|
||||
x: last_date_info
|
||||
? last_date_info.base_pos_x + last_date_info.column_width
|
||||
: 0,
|
||||
lower_y: this.options.header_height,
|
||||
upper_y: this.options.header_height - 25,
|
||||
lower_y: this.options.header_height - 15,
|
||||
upper_y: this.options.header_height - 35,
|
||||
};
|
||||
|
||||
const x_pos = {
|
||||
@ -1829,7 +1828,7 @@ var Gantt = (function () {
|
||||
Year_lower: this.options.column_width / 2,
|
||||
Year_upper: (this.options.column_width * 30) / 2,
|
||||
};
|
||||
|
||||
console.log(base_pos.x, x_pos[`${this.options.view_mode}_lower`],);
|
||||
return {
|
||||
date,
|
||||
column_width,
|
||||
@ -1911,8 +1910,7 @@ var Gantt = (function () {
|
||||
(hours_before_first_task / this.options.step) *
|
||||
this.options.column_width -
|
||||
this.options.column_width;
|
||||
|
||||
parent_element.scrollLeft = scroll_pos;
|
||||
console.log(parent_element.scrollTo({ left: scroll_pos, behavior: 'smooth' }));
|
||||
}
|
||||
|
||||
scroll_today() {
|
||||
@ -1950,6 +1948,7 @@ var Gantt = (function () {
|
||||
|
||||
$.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (e, element) => {
|
||||
const bar_wrapper = $.closest(".bar-wrapper", element);
|
||||
bars.forEach((bar) => bar.group.classList.remove("active"));
|
||||
|
||||
if (element.classList.contains("left")) {
|
||||
is_resizing_left = true;
|
||||
@ -1960,6 +1959,7 @@ var Gantt = (function () {
|
||||
}
|
||||
|
||||
bar_wrapper.classList.add("active");
|
||||
this.popup.parent.classList.add('hidden');
|
||||
|
||||
x_on_start = e.offsetX;
|
||||
y_on_start = e.offsetY;
|
||||
@ -1986,8 +1986,6 @@ var Gantt = (function () {
|
||||
let localBars = [];
|
||||
const ids = [];
|
||||
let dx;
|
||||
|
||||
this.layers.date.setAttribute('transform', 'translate(0,' + e.currentTarget.scrollTop + ')');
|
||||
if (x_on_scroll_start) {
|
||||
dx = e.currentTarget.scrollLeft - x_on_scroll_start;
|
||||
}
|
||||
@ -1998,10 +1996,11 @@ var Gantt = (function () {
|
||||
|
||||
if (dx) {
|
||||
localBars = ids.map(id => this.get_bar(id));
|
||||
|
||||
localBars.forEach(bar => {
|
||||
bar.update_label_position_on_horizontal_scroll({ x: dx, sx: e.currentTarget.scrollLeft });
|
||||
});
|
||||
if (this.options.auto_move_label) {
|
||||
localBars.forEach(bar => {
|
||||
bar.update_label_position_on_horizontal_scroll({ x: dx, sx: e.currentTarget.scrollLeft });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
x_on_scroll_start = e.currentTarget.scrollLeft;
|
||||
@ -2040,9 +2039,6 @@ var Gantt = (function () {
|
||||
});
|
||||
|
||||
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_resizing_left = false;
|
||||
@ -2170,6 +2166,7 @@ var Gantt = (function () {
|
||||
[...this.$svg.querySelectorAll(".bar-wrapper")].forEach((el) => {
|
||||
el.classList.remove("active");
|
||||
});
|
||||
this.popup.parent.classList.remove('hidden');
|
||||
}
|
||||
|
||||
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>
|
||||
let tasks = [
|
||||
{
|
||||
start: '2024-10-01',
|
||||
end: '2024-10-08',
|
||||
start: '2024-04-01',
|
||||
end: '2024-04-08',
|
||||
name: 'Redesign website',
|
||||
id: "Task 0",
|
||||
progress: 30
|
||||
},
|
||||
{
|
||||
start: '2024-09-26',
|
||||
start: '2024-03-26',
|
||||
// Utilizes duration
|
||||
duration: '6d',
|
||||
name: 'Write new content',
|
||||
@ -50,32 +50,32 @@
|
||||
important: true
|
||||
},
|
||||
{
|
||||
start: '2024-10-04',
|
||||
end: '2024-10-08',
|
||||
start: '2024-04-04',
|
||||
end: '2024-04-08',
|
||||
name: 'Apply new styles',
|
||||
id: "Task 2",
|
||||
progress: 80,
|
||||
dependencies: 'Task 1'
|
||||
},
|
||||
{
|
||||
start: '2024-10-08',
|
||||
end: '2024-10-09',
|
||||
start: '2024-04-08',
|
||||
end: '2024-04-09',
|
||||
name: 'Review',
|
||||
id: "Task 3",
|
||||
progress: 5,
|
||||
dependencies: 'Task 2'
|
||||
},
|
||||
{
|
||||
start: '2024-10-08',
|
||||
end: '2024-10-10',
|
||||
start: '2024-04-08',
|
||||
end: '2024-04-10',
|
||||
name: 'Deploy',
|
||||
id: "Task 4",
|
||||
progress: 0,
|
||||
// dependencies: 'Task 2'
|
||||
},
|
||||
{
|
||||
start: '2024-10-11',
|
||||
end: '2024-10-11',
|
||||
start: '2024-04-21',
|
||||
end: '2024-04-29',
|
||||
name: 'Go Live!',
|
||||
id: "Task 5",
|
||||
progress: 0,
|
||||
@ -116,6 +116,7 @@
|
||||
view_mode: "Day",
|
||||
view_mode_padding: { DAY: "7d" },
|
||||
language: "en",
|
||||
scroll_today: false,
|
||||
// readonly: true
|
||||
});
|
||||
console.log(gantt_chart);
|
||||
|
||||
@ -36,6 +36,18 @@ $light-blue: #c4c4e9 !default;
|
||||
position: absolute;
|
||||
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 {
|
||||
|
||||
24
src/index.js
24
src/index.js
@ -424,13 +424,19 @@ export default class Gantt {
|
||||
}
|
||||
|
||||
make_grid_header() {
|
||||
let header = document.createElement("div");
|
||||
let $header = document.createElement("div");
|
||||
|
||||
header.style.height = this.options.header_height + 10 + "px";
|
||||
header.style.width = this.dates.length * this.options.column_width + "px";
|
||||
header.classList.add('grid-header')
|
||||
this.$header = header
|
||||
this.$svg.parentElement.appendChild(header)
|
||||
$header.style.height = this.options.header_height + 10 + "px";
|
||||
$header.style.width = this.dates.length * this.options.column_width + "px";
|
||||
$header.classList.add('grid-header')
|
||||
this.$header = $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() {
|
||||
@ -681,7 +687,7 @@ export default class Gantt {
|
||||
Year_lower: this.options.column_width / 2,
|
||||
Year_upper: (this.options.column_width * 30) / 2,
|
||||
};
|
||||
|
||||
console.log(base_pos.x, x_pos[`${this.options.view_mode}_lower`],)
|
||||
return {
|
||||
date,
|
||||
column_width,
|
||||
@ -763,8 +769,7 @@ export default class Gantt {
|
||||
(hours_before_first_task / this.options.step) *
|
||||
this.options.column_width -
|
||||
this.options.column_width;
|
||||
|
||||
parent_element.scrollLeft = scroll_pos;
|
||||
console.log(parent_element.scrollTo({ left: scroll_pos, behavior: 'smooth' }))
|
||||
}
|
||||
|
||||
scroll_today() {
|
||||
@ -840,7 +845,6 @@ export default class Gantt {
|
||||
let localBars = [];
|
||||
const ids = [];
|
||||
let dx;
|
||||
|
||||
if (x_on_scroll_start) {
|
||||
dx = e.currentTarget.scrollLeft - x_on_scroll_start;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user