mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 03:22:59 +08:00
Fix wired Transfer repaint problem in IE or Edge
close #9697 https://stackoverflow.com/q/27947912/3040605
This commit is contained in:
parent
a3e245731b
commit
a516358298
@ -9,6 +9,10 @@ import Search from './search';
|
|||||||
import Item from './item';
|
import Item from './item';
|
||||||
import triggerEvent from '../_util/triggerEvent';
|
import triggerEvent from '../_util/triggerEvent';
|
||||||
|
|
||||||
|
function isIEorEDGE() {
|
||||||
|
return (document as any).documentMode || /Edge/.test(navigator.userAgent);
|
||||||
|
}
|
||||||
|
|
||||||
function noop() {
|
function noop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +56,8 @@ export default class TransferList extends React.Component<TransferListProps, any
|
|||||||
|
|
||||||
timer: number;
|
timer: number;
|
||||||
triggerScrollTimer: number;
|
triggerScrollTimer: number;
|
||||||
|
fixIERepaintTimer: number;
|
||||||
|
notFoundNode: HTMLDivElement;
|
||||||
|
|
||||||
constructor(props: TransferListProps) {
|
constructor(props: TransferListProps) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -71,6 +77,7 @@ export default class TransferList extends React.Component<TransferListProps, any
|
|||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
clearTimeout(this.timer);
|
clearTimeout(this.timer);
|
||||||
clearTimeout(this.triggerScrollTimer);
|
clearTimeout(this.triggerScrollTimer);
|
||||||
|
clearTimeout(this.fixIERepaintTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(...args: any[]) {
|
shouldComponentUpdate(...args: any[]) {
|
||||||
@ -107,10 +114,12 @@ export default class TransferList extends React.Component<TransferListProps, any
|
|||||||
triggerEvent(listNode, 'scroll');
|
triggerEvent(listNode, 'scroll');
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
|
this.fixIERepaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClear = () => {
|
handleClear = () => {
|
||||||
this.props.handleClear();
|
this.props.handleClear();
|
||||||
|
this.fixIERepaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
matchFilter = (text: string, item: TransferItem) => {
|
matchFilter = (text: string, item: TransferItem) => {
|
||||||
@ -131,6 +140,24 @@ export default class TransferList extends React.Component<TransferListProps, any
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveNotFoundRef = (node: HTMLDivElement) => {
|
||||||
|
this.notFoundNode = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix IE/Edge repaint
|
||||||
|
// https://github.com/ant-design/ant-design/issues/9697
|
||||||
|
// https://stackoverflow.com/q/27947912/3040605
|
||||||
|
fixIERepaint() {
|
||||||
|
if (!isIEorEDGE()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.fixIERepaintTimer = window.setTimeout(() => {
|
||||||
|
if (this.notFoundNode) {
|
||||||
|
this.notFoundNode.className = this.notFoundNode.className;
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
prefixCls, dataSource, titleText, checkedKeys, lazy,
|
prefixCls, dataSource, titleText, checkedKeys, lazy,
|
||||||
@ -203,7 +230,7 @@ export default class TransferList extends React.Component<TransferListProps, any
|
|||||||
>
|
>
|
||||||
{showItems}
|
{showItems}
|
||||||
</Animate>
|
</Animate>
|
||||||
<div className={`${prefixCls}-body-not-found`}>
|
<div className={`${prefixCls}-body-not-found`} ref={this.saveNotFoundRef}>
|
||||||
{notFoundContent}
|
{notFoundContent}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user