Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions templates/contest/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
});

var oldSortIndex;
var dragCursorOffset;
$('#form_set').sortable({
handle: 'td.order-column',
placeholder: 'placeholder',
Expand All @@ -150,8 +151,35 @@
start: function(event, ui) {
ui.placeholder.empty();
oldSortIndex = ui.item.index();
// .table has backdrop-filter (table.scss), which makes the table a CSS
// containing block for fixed/absolute descendants in Chrome (but not
// consistently in Firefox/Safari), throwing off the dragged row's
// on-screen position. Suspend it for the drag and drive the helper with
// raw viewport coordinates so it never depends on any ancestor's offset.
$('#problem-table').css('backdrop-filter', 'none');
// Read the true on-screen rect BEFORE switching position, then set
// fixed + matching top/left atomically. Otherwise jQuery UI's old
// absolute-relative top/left gets reinterpreted under fixed semantics
// and the helper jumps far off its actual position.
var rect = ui.helper[0].getBoundingClientRect();
dragCursorOffset = {
top: event.clientY - rect.top,
left: event.clientX - rect.left,
};
ui.helper.css({
position: 'fixed',
top: rect.top,
left: rect.left,
});
},
sort: function(event, ui) {
ui.helper.css({
top: event.clientY - dragCursorOffset.top,
left: event.clientX - dragCursorOffset.left,
});
},
stop: function(event, ui) {
$('#problem-table').css('backdrop-filter', '');
_renumberOrders();
},
});
Expand Down
28 changes: 28 additions & 0 deletions templates/problem/data.html
Original file line number Diff line number Diff line change
Expand Up @@ -534,14 +534,42 @@
};

var oldIndex;
var dragCursorOffset;
$table.find('tbody:first').sortable({
handle: 'i.fa-ellipsis-v',
placeholder: 'placeholder',
start: function (event, ui) {
ui.placeholder.empty();
oldIndex = ui.item.index();
// .table has backdrop-filter (table.scss), which makes the table a CSS
// containing block for fixed/absolute descendants in Chrome (but not
// consistently in Firefox/Safari), throwing off the dragged row's
// on-screen position. Suspend it for the drag and drive the helper with
// raw viewport coordinates so it never depends on any ancestor's offset.
$table.css('backdrop-filter', 'none');
// Read the true on-screen rect BEFORE switching position, then set
// fixed + matching top/left atomically. Otherwise jQuery UI's old
// absolute-relative top/left gets reinterpreted under fixed semantics
// and the helper jumps far off its actual position.
var rect = ui.helper[0].getBoundingClientRect();
dragCursorOffset = {
top: event.clientY - rect.top,
left: event.clientX - rect.left,
};
ui.helper.css({
position: 'fixed',
top: rect.top,
left: rect.left,
});
},
sort: function (event, ui) {
ui.helper.css({
top: event.clientY - dragCursorOffset.top,
left: event.clientX - dragCursorOffset.left,
});
},
stop: function (event, ui) {
$table.css('backdrop-filter', '');
var newIndex = ui.item.index();
reordering_row(oldIndex, newIndex, ui.item);
}
Expand Down
Loading