diff --git a/src/components/core/update/updateSlides.js b/src/components/core/update/updateSlides.js index 8c57023a3..18190feff 100644 --- a/src/components/core/update/updateSlides.js +++ b/src/components/core/update/updateSlides.js @@ -1,4 +1,3 @@ -import { getWindow } from 'ssr-window'; import { extend } from '../../../utils/utils'; export default function updateSlides() { @@ -23,7 +22,6 @@ export default function updateSlides() { return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0); }; - const window = getWindow(); const params = swiper.params; const { $wrapperEl, size: swiperSize, rtlTranslate: rtl, wrongRTL } = swiper; @@ -151,7 +149,7 @@ export default function updateSlides() { if (slide.css('display') === 'none') continue; // eslint-disable-line if (params.slidesPerView === 'auto') { - const slideStyles = window.getComputedStyle(slide[0], null); + const slideStyles = getComputedStyle(slide[0]); const currentTransform = slide[0].style.transform; const currentWebKitTransform = slide[0].style.webkitTransform; if (currentTransform) { diff --git a/src/utils/utils.js b/src/utils/utils.js index d5e450680..4c9348634 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -21,13 +21,28 @@ function nextTick(callback, delay = 0) { function now() { return Date.now(); } +function getComputedStyle(el) { + const window = getWindow(); + let style; + if (window.getComputedStyle) { + style = window.getComputedStyle(el, null); + } + if (!style && el.currentStyle) { + style = el.currentStyle; + } + if (!style) { + style = el.style; + } + + return style; +} function getTranslate(el, axis = 'x') { const window = getWindow(); let matrix; let curTransform; let transformMatrix; - const curStyle = window.getComputedStyle(el, null); + const curStyle = getComputedStyle(el, null); if (window.WebKitCSSMatrix) { curTransform = curStyle.transform || curStyle.webkitTransform; @@ -110,4 +125,13 @@ function bindModuleMethods(instance, obj) { }); } -export { deleteProps, nextTick, now, getTranslate, isObject, extend, bindModuleMethods }; +export { + deleteProps, + nextTick, + now, + getTranslate, + isObject, + extend, + bindModuleMethods, + getComputedStyle, +};