Fix zoomslider layout with padding

This commit is contained in:
Maximilian Krög
2021-04-14 22:07:38 +02:00
parent ed5329e0cb
commit f999f1a675
+14 -7
View File
@@ -183,22 +183,29 @@ class ZoomSlider extends Control {
*/ */
initSlider_() { initSlider_() {
const container = this.element; const container = this.element;
const containerWidth = container.offsetWidth; let containerWidth = container.offsetWidth;
const containerHeight = container.offsetHeight; let containerHeight = container.offsetHeight;
if (containerWidth === 0 && containerHeight === 0) { if (containerWidth === 0 && containerHeight === 0) {
return (this.sliderInitialized_ = false); return (this.sliderInitialized_ = false);
} }
const containerStyle = getComputedStyle(container);
containerWidth -=
parseFloat(containerStyle['paddingRight']) +
parseFloat(containerStyle['paddingLeft']);
containerHeight -=
parseFloat(containerStyle['paddingTop']) +
parseFloat(containerStyle['paddingBottom']);
const thumb = /** @type {HTMLElement} */ (container.firstElementChild); const thumb = /** @type {HTMLElement} */ (container.firstElementChild);
const computedStyle = getComputedStyle(thumb); const thumbStyle = getComputedStyle(thumb);
const thumbWidth = const thumbWidth =
thumb.offsetWidth + thumb.offsetWidth +
parseFloat(computedStyle['marginRight']) + parseFloat(thumbStyle['marginRight']) +
parseFloat(computedStyle['marginLeft']); parseFloat(thumbStyle['marginLeft']);
const thumbHeight = const thumbHeight =
thumb.offsetHeight + thumb.offsetHeight +
parseFloat(computedStyle['marginTop']) + parseFloat(thumbStyle['marginTop']) +
parseFloat(computedStyle['marginBottom']); parseFloat(thumbStyle['marginBottom']);
this.thumbSize_ = [thumbWidth, thumbHeight]; this.thumbSize_ = [thumbWidth, thumbHeight];
if (containerWidth > containerHeight) { if (containerWidth > containerHeight) {