Skip to content

Commit 656ba98

Browse files
author
antoine
committed
U4-5793 prevent drag element off screen vertically
1 parent 5c17201 commit 656ba98

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/Umbraco.Web.UI.Client/src/less/gridview.less

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
// Sortabel
1212
// -------------------------
13+
1314
.usky-grid .ui-sortable-helper {
14-
position:absolute;
15+
position:absolute !important;
1516
border: dashed 1px #000 !important;
1617
background: #ccc;
1718
opacity: 0.4;
@@ -44,8 +45,9 @@
4445
text-align: center;
4546
font-size: 85px;
4647
line-height: 65px;
47-
color: @grayLighter;
48+
color: @gray;
4849
vertical-align: middle;
50+
background-color:@grayLighter;
4951
}
5052

5153
.usky-grid .ui-sortable-placeholder:hover{
@@ -138,6 +140,7 @@
138140
.usky-grid .usky-cell{
139141
position: relative;
140142
border: 1px dashed rgba(0,0,0,0);
143+
min-height:127px;
141144
}
142145

143146
.usky-grid .cell-tools {

src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ angular.module("umbraco")
2828
left: 90
2929
},
3030

31+
sort: function (event, ui) {
32+
/* prevent vertical scroll out of the screen */
33+
var max = $(".usky-grid").width() - 150;
34+
if (parseInt(ui.helper.css('left')) > max) {
35+
ui.helper.css({ 'left': max + "px" })
36+
}
37+
if (parseInt(ui.helper.css('left')) < 20) {
38+
ui.helper.css({ 'left': 20 })
39+
}
40+
},
41+
3142
start: function (e, ui) {
3243
ui.item.find('.mceNoEditor').each(function () {
3344
tinyMCE.execCommand('mceRemoveEditor', false, $(this).attr('id'));
@@ -46,7 +57,6 @@ angular.module("umbraco")
4657
var cancelMove = false;
4758

4859
$scope.sortableOptionsCell = {
49-
5060
distance: 10,
5161
cursor: "move",
5262
placeholder: "ui-sortable-placeholder",
@@ -61,6 +71,18 @@ angular.module("umbraco")
6171
left: 90
6272
},
6373

74+
sort: function (event, ui) {
75+
/* prevent vertical scroll out of the screen */
76+
var position = parseInt(ui.item.parent().offset().left) + parseInt(ui.helper.css('left')) - parseInt($(".usky-grid").offset().left);
77+
var max = $(".usky-grid").width() - 220;
78+
if (position > max) {
79+
ui.helper.css({ 'left': max - parseInt(ui.item.parent().offset().left) + parseInt($(".usky-grid").offset().left) + "px" })
80+
}
81+
if (position < 0) {
82+
ui.helper.css({ 'left': 0 - parseInt(ui.item.parent().offset().left) + parseInt($(".usky-grid").offset().left) + "px" })
83+
}
84+
},
85+
6486
over: function (event, ui) {
6587
allowedEditors = $(event.target).scope().area.allowed;
6688

@@ -527,7 +549,6 @@ angular.module("umbraco")
527549
};
528550

529551

530-
531552
// *********************************************
532553
// Init control
533554
// *********************************************

0 commit comments

Comments
 (0)