diff --git a/src/ol/control/zoomslidercontrol.js b/src/ol/control/zoomslidercontrol.js index 6ee6224a40..f5d720bf27 100644 --- a/src/ol/control/zoomslidercontrol.js +++ b/src/ol/control/zoomslidercontrol.js @@ -189,20 +189,13 @@ ol.control.ZoomSlider.prototype.initSlider_ = function() { }; var thumb = container.firstElementChild; - var thumbComputedStyles = window.getComputedStyle(thumb); - var thumbMargins = { - left: parseFloat(thumbComputedStyles['marginLeft']), - right: parseFloat(thumbComputedStyles['marginRight']), - top: parseFloat(thumbComputedStyles['marginTop']), - bottom: parseFloat(thumbComputedStyles['marginBottom']) - }; - var thumbBorderBoxSize = { - width:thumb.offsetWidth, height: thumb.offsetHeight - }; - var thumbWidth = thumbBorderBoxSize.width + - thumbMargins.right + thumbMargins.left; - var thumbHeight = thumbBorderBoxSize.height + - thumbMargins.top + thumbMargins.bottom; + var computedStyle = ol.global.getComputedStyle(thumb); + var thumbWidth = thumb.offsetWidth + + parseFloat(computedStyle['marginRight']) + + parseFloat(computedStyle['marginLeft']); + var thumbHeight = thumb.offsetHeight + + parseFloat(computedStyle['marginTop']) + + parseFloat(computedStyle['marginBottom']); this.thumbSize_ = [thumbWidth, thumbHeight]; if (containerSize.width > containerSize.height) { diff --git a/src/ol/map.js b/src/ol/map.js index 9ebbc9ad81..fe35935ee1 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -1425,31 +1425,19 @@ ol.Map.prototype.updateSize = function() { if (!targetElement) { this.setSize(undefined); } else { - var targetElementComputedStyle = window.getComputedStyle(targetElement); - var borderBoxSize = { - width: targetElement.offsetWidth, height: targetElement.offsetHeight - }; - var paddingBox = { - left: parseFloat(targetElementComputedStyle['paddingLeft']), - right: parseFloat(targetElementComputedStyle['paddingRight']), - top: parseFloat(targetElementComputedStyle['paddingTop']), - bottom: parseFloat(targetElementComputedStyle['paddingBottom']) - }; - var borderBox = { - left: parseFloat(targetElementComputedStyle['borderLeftWidth']), - right: parseFloat(targetElementComputedStyle['borderRightWidth']), - top: parseFloat(targetElementComputedStyle['borderTopWidth']), - bottom: parseFloat(targetElementComputedStyle['borderBottomWidth']) - }; - var size = { - width: borderBoxSize.width - - borderBox.left - paddingBox.left - - paddingBox.right - borderBox.right, - height: borderBoxSize.height - - borderBox.top - paddingBox.top - - paddingBox.bottom - borderBox.bottom - }; - this.setSize([size.width, size.height]); + var computedStyle = ol.global.getComputedStyle(targetElement); + this.setSize([ + targetElement.offsetWidth - + parseFloat(computedStyle['borderLeftWidth']) - + parseFloat(computedStyle['paddingLeft']) - + parseFloat(computedStyle['paddingRight']) - + parseFloat(computedStyle['borderRightWidth']), + targetElement.offsetHeight - + parseFloat(computedStyle['borderTopWidth']) - + parseFloat(computedStyle['paddingTop']) - + parseFloat(computedStyle['paddingBottom']) - + parseFloat(computedStyle['borderBottomWidth']) + ]); } };