Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

have drag placeholder in the viewport

ulferts61d61d8ce065
diff --git a/frontend/src/app/modules/grids/grid/area.service.ts b/frontend/src/app/modules/grids/grid/area.service.ts
index f119828c5e1..ccfc9d31305 100644
--- a/frontend/src/app/modules/grids/grid/area.service.ts
+++ b/frontend/src/app/modules/grids/grid/area.service.ts
@@ -131,6 +131,18 @@ export class GridAreaService {
this.helpMode = !this.helpMode;
}
+ // This is a hacky way to have the placeholder in the viewport.
+ // It is a noop for firefox and edge as both do not support scrollIntoViewIfNeeded.
+ // But as scrollIntoView will always readjust the viewport, the result would be an unbearable flicker
+ // which causes e.g. dragging to be impossible.
+ public scrollPlaceholderIntoView() {
+ let placeholder = jQuery('.grid--area.-placeholder');
+
+ if ((placeholder[0] as any).scrollIntoViewIfNeeded) {
+ setTimeout(() => (placeholder[0] as any).scrollIntoViewIfNeeded());
+ }
+ }
+
private saveGrid(resource:GridWidgetResource|any, schema?:SchemaResource) {
this
.gridDm
diff --git a/frontend/src/app/modules/grids/grid/drag-and-drop.service.ts b/frontend/src/app/modules/grids/grid/drag-and-drop.service.ts
index 3cce859ef47..a85e5f438ae 100644
--- a/frontend/src/app/modules/grids/grid/drag-and-drop.service.ts
+++ b/frontend/src/app/modules/grids/grid/drag-and-drop.service.ts
@@ -35,6 +35,8 @@ export class GridDragAndDropService implements OnDestroy {
throttle(val => interval(10))
).subscribe(area => {
this.updateArea(area!);
+
+ this.layout.scrollPlaceholderIntoView();
});
}
diff --git a/frontend/src/app/modules/grids/grid/grid.component.ts b/frontend/src/app/modules/grids/grid/grid.component.ts
index e6324a85784..d9736a89e0b 100644
--- a/frontend/src/app/modules/grids/grid/grid.component.ts
+++ b/frontend/src/app/modules/grids/grid/grid.component.ts
@@ -104,7 +104,7 @@ export class GridComponent implements OnDestroy, OnInit {
public get gridColumnStyle() {
return this.gridStyle(this.layout.numColumns,
- `calc((100% - ${this.GRID_GAP_DIMENSION} * ${this.layout.numColumns + 1}) / ${this.layout.numColumns})`)
+ `calc((100% - ${this.GRID_GAP_DIMENSION} * ${this.layout.numColumns + 1}) / ${this.layout.numColumns})`);
}
public get gridRowStyle() {