fix: add resize-observer-polyfill #4508

close #4508
pull/4520/head
tangjinzhou 3 years ago
parent 8187d3a739
commit 9f15fe9fdf

@ -1,5 +1,6 @@
import contains from '../vc-util/Dom/contains'; import contains from '../vc-util/Dom/contains';
import type { TargetPoint } from './interface'; import type { TargetPoint } from './interface';
import ResizeObserver from 'resize-observer-polyfill';
export function isSamePoint(prev: TargetPoint, next: TargetPoint) { export function isSamePoint(prev: TargetPoint, next: TargetPoint) {
if (prev === next) return true; if (prev === next) return true;

@ -1,5 +1,6 @@
// based on rc-resize-observer 1.0.0 // based on rc-resize-observer 1.0.0
import type { PropType } from 'vue'; import type { PropType } from 'vue';
import ResizeObserver from 'resize-observer-polyfill';
import { import {
defineComponent, defineComponent,
getCurrentInstance, getCurrentInstance,
@ -18,7 +19,7 @@ interface ResizeObserverState {
offsetWidth: number; offsetWidth: number;
} }
const ResizeObserver = defineComponent({ export default defineComponent({
name: 'ResizeObserver', name: 'ResizeObserver',
props: { props: {
disabled: Boolean, disabled: Boolean,
@ -110,7 +111,7 @@ const ResizeObserver = defineComponent({
} }
if (!resizeObserver && element) { if (!resizeObserver && element) {
resizeObserver = new window.ResizeObserver(onResize); resizeObserver = new ResizeObserver(onResize);
resizeObserver.observe(element); resizeObserver.observe(element);
} }
}; };
@ -135,5 +136,3 @@ const ResizeObserver = defineComponent({
}; };
}, },
}); });
export default ResizeObserver;

@ -1,4 +1,5 @@
import debounce from 'lodash-es/debounce'; import debounce from 'lodash-es/debounce';
import ResizeObserver from 'resize-observer-polyfill';
import classnames from '../../_util/classNames'; import classnames from '../../_util/classNames';
import BaseMixin from '../../_util/BaseMixin'; import BaseMixin from '../../_util/BaseMixin';
import defaultProps from './default-props'; import defaultProps from './default-props';

@ -1,4 +1,5 @@
import debounce from 'lodash-es/debounce'; import debounce from 'lodash-es/debounce';
import ResizeObserver from 'resize-observer-polyfill';
import PropTypes from '../../_util/vue-types'; import PropTypes from '../../_util/vue-types';
import BaseMixin from '../../_util/BaseMixin'; import BaseMixin from '../../_util/BaseMixin';
import { getComponent, getSlot } from '../../_util/props-util'; import { getComponent, getSlot } from '../../_util/props-util';

@ -160,7 +160,6 @@
"querystring": "^0.2.0", "querystring": "^0.2.0",
"raw-loader": "^4.0.2", "raw-loader": "^4.0.2",
"reqwest": "^2.0.5", "reqwest": "^2.0.5",
"resize-observer-polyfill": "^1.5.1",
"rimraf": "^3.0.0", "rimraf": "^3.0.0",
"rucksack-css": "^1.0.2", "rucksack-css": "^1.0.2",
"selenium-server": "^3.0.1", "selenium-server": "^3.0.1",
@ -214,6 +213,7 @@
"lodash-es": "^4.17.15", "lodash-es": "^4.17.15",
"moment": "^2.27.0", "moment": "^2.27.0",
"omit.js": "^2.0.0", "omit.js": "^2.0.0",
"resize-observer-polyfill": "^1.5.1",
"scroll-into-view-if-needed": "^2.2.25", "scroll-into-view-if-needed": "^2.2.25",
"shallow-equal": "^1.0.0", "shallow-equal": "^1.0.0",
"vue-types": "^3.0.0", "vue-types": "^3.0.0",

Loading…
Cancel
Save