Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Drupal.behaviors.showAdvertizementLoader = {
- attach(context, settings) {
- if (context === document) {
- const body = $('#js-preroll-container', context)[0];
- const config = {childList: true, attributes: true, subtree: true};
- var in_dom = false;
- const observer = new MutationObserver(function (mutations) {
- mutations.forEach(function (mutation) {
- if ($(body).find('#js-preroll-container-wrapper').length > 0) {
- if (!in_dom) {
- console.log("element inserted");
- }
- in_dom = true;
- }
- else {
- if (in_dom) {
- in_dom = false;
- console.log("element removed");
- }
- }
- });
- });
- observer.observe(body, config);
- }
- },
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement