ag-grid-enterprise
Version:
ag-Grid Enterprise Features
50 lines (40 loc) • 1.4 kB
text/typescript
import {
Autowired,
Component,
EventService,
GridOptionsWrapper,
HorizontalResizeService,
PostConstruct
} from "ag-grid-community/main";
export class HorizontalResizeComp extends Component {
private horizontalResizeService: HorizontalResizeService;
private gridOptionsWrapper: GridOptionsWrapper;
private eventService: EventService;
private startingWidth: number;
props: {
componentToResize: Component
};
constructor() {
super(`<div></div>`);
}
private postConstruct(): void {
let finishedWithResizeFunc = this.horizontalResizeService.addResizeBar({
eResizeBar: this.getGui(),
onResizeStart: this.onResizeStart.bind(this),
onResizing: this.onResizing.bind(this),
onResizeEnd: this.onResizing.bind(this)
});
this.addDestroyFunc(finishedWithResizeFunc);
}
private onResizeStart(): void {
this.startingWidth = this.props.componentToResize.getGui().clientWidth;
}
private onResizing(delta: number): void {
let newWidth = this.startingWidth - delta;
if (newWidth < 100) {
newWidth = 100;
}
this.props.componentToResize.getGui().style.width = newWidth + 'px';
}
}