MediaWiki:Gadget-AbsyFancyBoxy.js: различия между версиями
Ланселот (обсуждение | вклад) Нет описания правки |
Ланселот (обсуждение | вклад) Нет описания правки |
||
| Строка 205: | Строка 205: | ||
counterElement.style.left = left + 'px'; | counterElement.style.left = left + 'px'; | ||
counterElement.style.top = top + 'px'; | counterElement.style.top = top + 'px'; | ||
} | |||
// Крестик в overlay | |||
function updateClosePosition() { | |||
if ( !closeBtn || !imgElement || !overlay ) return; | |||
var imgRect = imgElement.getBoundingClientRect(); | |||
var overlayRect = overlay.getBoundingClientRect(); | |||
var left = imgRect.right - overlayRect.left - 8; // 8px от правого края картинки | |||
var top = imgRect.top - overlayRect.top - 12; // 12px от верхнего края картинки | |||
closeBtn.style.left = left + 'px'; | |||
closeBtn.style.top = top + 'px'; | |||
} | } | ||
| Строка 234: | Строка 245: | ||
captionElement.textContent = 'Не удалось загрузить изображение'; | captionElement.textContent = 'Не удалось загрузить изображение'; | ||
} ); | } ); | ||
imgElement.addEventListener( 'load', updateCounterPosition ); | imgElement.addEventListener( 'load', function () { | ||
updateCounterPosition(); | |||
updateClosePosition(); | |||
} ); | |||
imageWrap.appendChild( imgElement ); | imageWrap.appendChild( imgElement ); | ||
| Строка 276: | Строка 290: | ||
} | } | ||
} ); | } ); | ||
overlay.appendChild( closeBtn ); | |||
prevBtn = makeArrow( 'prev', '‹' ); | prevBtn = makeArrow( 'prev', '‹' ); | ||
| Строка 430: | Строка 444: | ||
} | } | ||
// Обновить | // Обновить позиции счётчика и крестика после рендера | ||
updateCounterPosition(); | updateCounterPosition(); | ||
updateClosePosition(); | |||
} | } | ||
| Строка 538: | Строка 553: | ||
updateCounterPosition(); | updateCounterPosition(); | ||
updateClosePosition(); | |||
if ( prevBtn && nextBtn ) { | if ( prevBtn && nextBtn ) { | ||