Created by: romanlex
Fix https://github.com/twbs/bootstrap/pull/24208
Offset option can be function (Popper.js)
Add support for calculate and dynamically change offset position for dropdown menu. Function call always when call Popper.js modifierFn.
With this code I can change any dropdown position as on picture
const dropdownMegaToggle = $('.dropdown-toggle--mega');
dropdownMegaToggle.dropdown({
offset: function(data) {
let popper = data.popper;
let reference = data.reference;
let w = $(window).width();
let buttonOffset = dropdownMegaToggle.offset();
popper.top = 100;
reference.width = w / 2; // f*cking Popper.js crutch
popper.left = w / 2 - popper.width / 2 - buttonOffset.left;
return data
}
});