mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:58:05 +08:00
feat: Overlay 当目标组件所在滚动容器处于弹窗所在容器时, 滚动容器滚动需要重新定位 (#2285)
This commit is contained in:
parent
1a8061aa0c
commit
acf1846349
@ -12,12 +12,22 @@ import {
|
||||
import {findDOMNode} from 'react-dom';
|
||||
import React from 'react';
|
||||
import {calculatePosition, getContainer, ownerDocument} from '../utils/dom';
|
||||
import {autobind, noop} from '../utils/helper';
|
||||
import {autobind, getScrollParent, noop} from '../utils/helper';
|
||||
import {resizeSensor, getComputedStyle} from '../utils/resize-sensor';
|
||||
|
||||
// @ts-ignore
|
||||
BasePosition.propTypes.placement = () => null;
|
||||
|
||||
function onScroll(elem: HTMLElement, callback: () => void) {
|
||||
const handler = () => {
|
||||
requestAnimationFrame(callback);
|
||||
};
|
||||
elem.addEventListener('scroll', handler);
|
||||
return function () {
|
||||
elem.removeEventListener('scroll', handler);
|
||||
};
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
class Position extends BasePosition {
|
||||
props: any;
|
||||
@ -57,6 +67,15 @@ class Position extends BasePosition {
|
||||
: noop,
|
||||
resizeSensor(overlay, () => this.updatePosition(target))
|
||||
];
|
||||
|
||||
const scrollParent = getScrollParent(target);
|
||||
if (scrollParent && container.contains(scrollParent)) {
|
||||
this.resizeDispose.push(
|
||||
onScroll(scrollParent, () => {
|
||||
this.updatePosition(target);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
this.setState(
|
||||
|
Loading…
Reference in New Issue
Block a user