Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var shb = document.querySelector('.essb-mobile-sharebottom');
- show(shb);
- adjustIngredientsPosition();
- updateBottomPosition();
- waitForElm('.bs6').then((elm) => {
- const ro = new ResizeObserver(entries => {
- for (let entry of entries) {
- updateButtonsPosition();
- adjustIngredientsPosition();
- updateBottomPosition();
- }
- });
- ro.observe(elm);
- });
- function waitForElm(selector) {
- return new Promise(resolve => {
- if (document.querySelector(selector)) {
- return resolve(document.querySelector(selector));
- }
- const observer = new MutationObserver(mutations => {
- if (document.querySelector(selector)) {
- resolve(document.querySelector(selector));
- observer.disconnect();
- }
- });
- observer.observe(document.body, {
- childList: true,
- subtree: true
- });
- });
- }
- function updateBottomPosition() {
- const essbMobileSharebottom = document.querySelector('.essb-mobile-sharebottom');
- const targetElement = document.querySelector('.bs6');
- const fixedIngredients = document.querySelector('.fixed-ingredients.visible');
- if (essbMobileSharebottom && targetElement) {
- let essbHeight = essbMobileSharebottom.offsetHeight;
- if (fixedIngredients) {
- essbHeight += fixedIngredients.offsetHeight;
- }
- targetElement.style.bottom = `${essbHeight}px`;
- }
- }
- const observer = new MutationObserver(mutations => {
- mutations.forEach(mutation => {
- if (mutation.target.classList.contains('fixed-ingredients')) {
- updateBottomPosition();
- }
- });
- });
- observer.observe(document.body, {
- attributes: true,
- subtree: true,
- attributeFilter: ['class']
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement