Skip to content

Commit

Permalink
Merge pull request #21750 from colemanw/afformHoverFix
Browse files Browse the repository at this point in the history
Afform - ensure dragging classes are removed when not sorting
  • Loading branch information
eileenmcnaughton authored Oct 6, 2021
2 parents aafd51d + 67120a3 commit b3a8f01
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ext/afform/admin/ang/afGuiEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,19 +180,24 @@
CRM.loadScript(CRM.config.resourceBase + 'js/jquery/jquery.crmIconPicker.js').done(function() {
$('#af-gui-icon-picker').crmIconPicker();
});
// Add css class while dragging
// Add css classes 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() {
$('body').removeClass('af-gui-dragging');
$('.af-gui-dragtarget').removeClass('af-gui-dragtarget');
});
Expand Down

0 comments on commit b3a8f01

Please sign in to comment.