Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Afform - ensure dragging classes are removed when not sorting #21750

Merged
merged 1 commit into from
Oct 6, 2021
Merged
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
Afform - ensure dragging classes are removed when not sorting
  • Loading branch information
colemanw committed Oct 6, 2021
commit 67120a3d75bb1bf4ec02e2af68365fbdffe2fb04
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