1 | import {Bean, Autowired, PostConstruct} from "../context/context";
|
2 | import {Utils as _} from "../utils";
|
3 | import {EventService} from "../eventService";
|
4 | import {Events, ScrollVisibilityChangedEvent} from "../events";
|
5 | import {ColumnController} from "../columnController/columnController";
|
6 | import {ColumnApi} from "../columnController/columnApi";
|
7 | import {GridApi} from "../gridApi";
|
8 | import {GridOptionsWrapper} from "../gridOptionsWrapper";
|
9 |
|
10 | export interface SetScrollsVisibleParams {
|
11 | bodyHorizontalScrollShowing: boolean;
|
12 | leftVerticalScrollShowing: boolean;
|
13 | rightVerticalScrollShowing: boolean;
|
14 | }
|
15 |
|
16 | @Bean('scrollVisibleService')
|
17 | export class ScrollVisibleService {
|
18 |
|
19 | @Autowired('eventService') private eventService: EventService;
|
20 | @Autowired('columnController') private columnController: ColumnController;
|
21 | @Autowired('columnApi') private columnApi: ColumnApi;
|
22 | @Autowired('gridApi') private gridApi: GridApi;
|
23 | @Autowired('gridOptionsWrapper') private gridOptionsWrapper: GridOptionsWrapper;
|
24 |
|
25 | private bodyHorizontalScrollShowing: boolean;
|
26 |
|
27 | private leftVerticalScrollShowing: boolean;
|
28 | private rightVerticalScrollShowing: boolean;
|
29 |
|
30 | public setScrollsVisible(params: SetScrollsVisibleParams): void {
|
31 |
|
32 | let atLeastOneDifferent =
|
33 | this.bodyHorizontalScrollShowing !== params.bodyHorizontalScrollShowing ||
|
34 | this.leftVerticalScrollShowing !== params.leftVerticalScrollShowing ||
|
35 | this.rightVerticalScrollShowing !== params.rightVerticalScrollShowing;
|
36 |
|
37 | if (atLeastOneDifferent) {
|
38 | this.bodyHorizontalScrollShowing = params.bodyHorizontalScrollShowing;
|
39 | this.leftVerticalScrollShowing = params.leftVerticalScrollShowing;
|
40 | this.rightVerticalScrollShowing = params.rightVerticalScrollShowing;
|
41 |
|
42 | let event: ScrollVisibilityChangedEvent = {
|
43 | type: Events.EVENT_SCROLL_VISIBILITY_CHANGED,
|
44 | api: this.gridApi,
|
45 | columnApi: this.columnApi
|
46 | };
|
47 | this.eventService.dispatchEvent(event);
|
48 | }
|
49 | }
|
50 |
|
51 |
|
52 | public isBodyHorizontalScrollShowing(): boolean {
|
53 | return this.bodyHorizontalScrollShowing;
|
54 | }
|
55 |
|
56 |
|
57 | public isLeftVerticalScrollShowing(): boolean {
|
58 | return this.leftVerticalScrollShowing;
|
59 | }
|
60 |
|
61 |
|
62 | public isRightVerticalScrollShowing(): boolean {
|
63 | return this.rightVerticalScrollShowing;
|
64 | }
|
65 |
|
66 | }
|