Skip to content

Commit 4c11ead

Browse files
committed
Merge branch 'MC-4262-column-move-indicator' into cms-team-1-delivery
2 parents cbda3da + 57a7d42 commit 4c11ead

File tree

5 files changed

+54
-34
lines changed

5 files changed

+54
-34
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/_drag-drop.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
}
4646
}
4747

48-
.pagebuilder-content-type-wrapper.ui-sortable-helper {
48+
.pagebuilder-content-type-wrapper.ui-sortable-helper,
49+
.pagebuilder-content-type.ui-draggable-dragging {
4950
opacity: .7;
5051

5152
> .pagebuilder-content-type > .pagebuilder-options {

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/content-type/column-group/_default.less

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@
77
// Default appearance styles
88
// _____________________________________________
99

10+
@keyframes inner-pulsate {
11+
0% {
12+
box-shadow: inset 0 0 0 1px rgba(142, 0, 6, 0);
13+
}
14+
50% {
15+
box-shadow: inset 0 0 0 8px rgba(142, 0, 6, .1);
16+
}
17+
100% {
18+
box-shadow: inset 0 0 0 2px rgba(142, 0, 6, 0);
19+
}
20+
}
21+
1022
.pagebuilder-content-type {
1123
.pagebuilder-column-group {
1224
border: none;
@@ -39,13 +51,13 @@
3951
}
4052

4153
.move-placeholder {
54+
animation: inner-pulsate 1s infinite ease-in-out;
4255
background: rgba(142, 0, 6, .3);
43-
bottom: -1px;
56+
bottom: 0;
4457
opacity: 0;
4558
position: absolute;
46-
top: -1px;
47-
transform: translateX(-3px);
48-
transition: .5s opacity;
59+
top: 0;
60+
transition: .25s opacity;
4961
visibility: hidden;
5062
width: 6px;
5163
z-index: 26;
@@ -55,7 +67,7 @@
5567

5668
&.active {
5769
opacity: 1;
58-
transition: .5s opacity;
70+
transition: .25s opacity;
5971
visibility: visible;
6072
}
6173
}

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/content-type/column/_default.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
}
8484
}
8585

86+
.pagebuilder-content-type-hidden .pagebuilder-column-resize-handle,
8687
.pagebuilder-stage.interacting .pagebuilder-content-type.pagebuilder-column .pagebuilder-column-resize-handle {
8788
display: none;
8889
}

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/column-group/preview.js

Lines changed: 14 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/column-group/preview.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export default class Preview extends PreviewCollection {
8181
private resizeUtils: Resize;
8282
private gridSizeHistory: Map<number, number[]> = new Map();
8383
private interactionLevel: number = 0;
84+
private startDragEvent: JQueryEventObject;
8485

8586
/**
8687
*
@@ -346,11 +347,12 @@ export default class Preview extends PreviewCollection {
346347
});
347348
return helper;
348349
},
349-
start: (event: Event) => {
350+
start: (event: JQueryEventObject) => {
350351
const columnInstance: ContentTypeCollectionInterface = ko.dataFor($(event.target)[0]);
351352
// Use the global state as columns can be dragged between groups
352353
setDragColumn((columnInstance.parent as ContentTypeCollectionInterface<ColumnPreview>));
353354
this.dropPositions = calculateDropPositions(this.parent);
355+
this.startDragEvent = event;
354356

355357
events.trigger("column:dragStart", {
356358
column: columnInstance,
@@ -373,6 +375,7 @@ export default class Preview extends PreviewCollection {
373375

374376
this.dropPlaceholder.removeClass("left right");
375377
this.movePlaceholder.removeClass("active");
378+
this.startDragEvent = null;
376379

377380
events.trigger("column:dragStop", {
378381
column: draggedColumn,
@@ -798,30 +801,30 @@ export default class Preview extends PreviewCollection {
798801
const currentX = event.pageX - groupPosition.left;
799802

800803
// Are we within the same column group or have we ended up over another?
801-
if (columnInstance.parent === this.parent) {
802-
const currentColumn = dragColumn.preview.element;
803-
const currentColumnRight = currentColumn.position().left + currentColumn.width();
804-
const lastColInGroup = (this.parent.children()[this.parent.children().length - 1]
805-
.preview as ColumnPreview).element;
806-
const insertLastPos = lastColInGroup.position().left + (lastColInGroup.width() / 2);
804+
if (columnInstance.parent === this.parent && this.startDragEvent) {
805+
const dragDirection = (event.pageX <= this.startDragEvent.pageX ? "left" : "right");
806+
const adjacentLeftColumn = getAdjacentColumn(dragColumn, "-1");
807807

808+
// Determine the current move position based on the cursors position and direction of drag
808809
this.movePosition = this.dropPositions.find((position) => {
809-
// Only ever look for the left placement, except the last item where we look on the right
810-
const placement = (currentX >= insertLastPos ? "right" : "left");
811-
// There is 200px area over each column borders
812-
return comparator(currentX, position[placement], 100) &&
813-
!comparator(currentX, currentColumnRight, 100) &&
814-
position.affectedColumn !== columnInstance && // Check affected column isn't the current column
815-
position.placement === placement; // Verify the position, we only check left on sorting
810+
return currentX > position.left && currentX < position.right &&
811+
position.placement === dragDirection && position.affectedColumn !== dragColumn;
816812
});
817813

814+
// Differences in the element & event positions cause a right movement to activate on the left column
815+
if (this.movePosition && dragDirection === "right" &&
816+
this.movePosition.affectedColumn === adjacentLeftColumn
817+
) {
818+
this.movePosition = null;
819+
}
820+
818821
if (this.movePosition) {
819822
this.dropPlaceholder.removeClass("left right");
820823
this.movePlaceholder.css({
821824
left: (this.movePosition.placement === "left" ? this.movePosition.left : ""),
822-
right: (this.movePosition.placement === "right" ?
823-
groupPosition.outerWidth - this.movePosition.right - 5 : ""
824-
),
825+
right: (this.movePosition.placement === "right"
826+
? groupPosition.width - this.movePosition.right : ""),
827+
width: dragColumn.preview.element.outerWidth() + "px",
825828
}).addClass("active");
826829
} else {
827830
this.movePlaceholder.removeClass("active");

0 commit comments

Comments
 (0)