Browse Source

Improve code for better compatibility

pull/18835/head
ztplz 5 years ago
committed by 偏右
parent
commit
fe30adc18d
  1. 4
      components/_util/responsiveObserve.ts
  2. 4
      components/carousel/index.tsx
  3. 4
      components/layout/Sider.tsx

4
components/_util/responsiveObserve.ts

@ -2,6 +2,7 @@
// https://github.com/WickyNilliams/enquire.js/issues/82
let enquire: any;
// TODO: Will be removed in antd 4.0 because we will no longer support ie9
if (typeof window !== 'undefined') {
const matchMediaPolyfill = (mediaQuery: string) => {
return {
@ -11,7 +12,8 @@ if (typeof window !== 'undefined') {
removeListener() {},
};
};
window.matchMedia = window.matchMedia || matchMediaPolyfill;
// ref: https://github.com/ant-design/ant-design/issues/18774
if (!window.matchMedia) window.matchMedia = matchMediaPolyfill as any;
// eslint-disable-next-line global-require
enquire = require('enquire.js');
}

4
components/carousel/index.tsx

@ -6,6 +6,7 @@ import warning from '../_util/warning';
// matchMedia polyfill for
// https://github.com/WickyNilliams/enquire.js/issues/82
// TODO: Will be removed in antd 4.0 because we will no longer support ie9
if (typeof window !== 'undefined') {
const matchMediaPolyfill = (mediaQuery: string) => {
return {
@ -15,7 +16,8 @@ if (typeof window !== 'undefined') {
removeListener() {},
};
};
window.matchMedia = window.matchMedia || matchMediaPolyfill;
// ref: https://github.com/ant-design/ant-design/issues/18774
if (!window.matchMedia) window.matchMedia = matchMediaPolyfill as any;
}
// Use require over import (will be lifted up)
// make sure matchMedia polyfill run before require('react-slick')

4
components/layout/Sider.tsx

@ -11,6 +11,7 @@ import isNumeric from '../_util/isNumeric';
// matchMedia polyfill for
// https://github.com/WickyNilliams/enquire.js/issues/82
// TODO: Will be removed in antd 4.0 because we will no longer support ie9
if (typeof window !== 'undefined') {
const matchMediaPolyfill = (mediaQuery: string) => {
return {
@ -20,7 +21,8 @@ if (typeof window !== 'undefined') {
removeListener() {},
};
};
window.matchMedia = window.matchMedia || matchMediaPolyfill;
// ref: https://github.com/ant-design/ant-design/issues/18774
if (!window.matchMedia) window.matchMedia = matchMediaPolyfill as any;
}
const dimensionMaxMap = {

Loading…
Cancel
Save