Skip to content

Commit

Permalink
Afform - ensure dragging classes are removed when not sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Oct 6, 2021
1 parent 76bed79 commit b2b2818
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ext/afform/admin/ang/afGuiEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,22 @@
});
// Add css class while dragging
$(document)
// When dragging an item over a container, add a class to highlight the target
.on('sortover', function(e) {
$('.af-gui-container').removeClass('af-gui-dragtarget');
$(e.target).closest('.af-gui-container').addClass('af-gui-dragtarget');
})
// Un-highlight when dragging out of a container
.on('sortout', '.af-gui-container', function() {
$(this).removeClass('af-gui-dragtarget');
})
// Add body class which puts the entire UI into a "dragging" state
.on('sortstart', '#afGuiEditor', function() {
$('body').addClass('af-gui-dragging');
})
.on('sortstop', function() {
// Ensure dragging classes are removed when not sorting
// Listening to multiple event types because sort* events are not 100% reliable
.on('sortbeforestop mouseenter', function(e) {
$('body').removeClass('af-gui-dragging');
$('.af-gui-dragtarget').removeClass('af-gui-dragtarget');
});
Expand Down

0 comments on commit b2b2818

Please sign in to comment.