You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.4 KiB
64 lines
1.4 KiB
4 years ago
|
import classNames from '../_util/classNames';
|
||
4 years ago
|
import ResizeObserver from '../vc-resize-observer';
|
||
4 years ago
|
import { CSSProperties, FunctionalComponent } from 'vue';
|
||
4 years ago
|
|
||
4 years ago
|
interface FillerProps {
|
||
|
prefixCls?: string;
|
||
|
/** Virtual filler height. Should be `count * itemMinHeight` */
|
||
|
height: number;
|
||
|
/** Set offset of visible items. Should be the top of start item position */
|
||
|
offset?: number;
|
||
|
onInnerResize?: () => void;
|
||
|
}
|
||
|
|
||
|
const Filter: FunctionalComponent<FillerProps> = (
|
||
|
{ height, offset, prefixCls, onInnerResize },
|
||
|
{ slots },
|
||
|
) => {
|
||
4 years ago
|
let outerStyle = {};
|
||
|
|
||
4 years ago
|
let innerStyle: CSSProperties = {
|
||
4 years ago
|
display: 'flex',
|
||
|
flexDirection: 'column',
|
||
|
};
|
||
|
|
||
|
if (offset !== undefined) {
|
||
4 years ago
|
outerStyle = { height: `${height}px`, position: 'relative', overflow: 'hidden' };
|
||
4 years ago
|
|
||
|
innerStyle = {
|
||
|
...innerStyle,
|
||
|
transform: `translateY(${offset}px)`,
|
||
|
position: 'absolute',
|
||
|
left: 0,
|
||
|
right: 0,
|
||
|
top: 0,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<div style={outerStyle}>
|
||
4 years ago
|
<ResizeObserver
|
||
|
onResize={({ offsetHeight }) => {
|
||
|
if (offsetHeight && onInnerResize) {
|
||
|
onInnerResize();
|
||
|
}
|
||
|
}}
|
||
4 years ago
|
>
|
||
4 years ago
|
<div
|
||
|
style={innerStyle}
|
||
|
class={classNames({
|
||
|
[`${prefixCls}-holder-inner`]: prefixCls,
|
||
|
})}
|
||
|
>
|
||
|
{slots.default?.()}
|
||
|
</div>
|
||
|
</ResizeObserver>
|
||
4 years ago
|
</div>
|
||
|
);
|
||
|
};
|
||
4 years ago
|
|
||
4 years ago
|
Filter.displayName = 'Filter';
|
||
|
Filter.inheritAttrs = false;
|
||
4 years ago
|
|
||
|
export default Filter;
|