UNPKG

2.54 kBTypeScriptView Raw
1import { ContentView } from '../content-view';
2import { Property } from '../core/properties';
3import { EventData } from '../../data/observable';
4import { CoreTypes } from '../../core-types';
5
6/**
7 * Represents a scrollable area that can have content that is larger than its bounds.
8 */
9export class ScrollView extends ContentView {
10 /**
11 * String value used when hooking to scroll event.
12 */
13 public static scrollEvent: string;
14
15 /**
16 * Gets or sets a value indicating whether scroll is enabled.
17 */
18 isScrollEnabled: boolean;
19
20 /**
21 * Gets a value that contains the vertical offset of the scrolled content.
22 */
23 verticalOffset: number;
24
25 /**
26 * Gets a value that contains the horizontal offset of the scrolled content.
27 */
28 horizontalOffset: number;
29
30 /**
31 * Gets the maximum value for the verticalOffset.
32 */
33 scrollableHeight: number;
34
35 /**
36 * Gets the maximum value for the horizontalOffset.
37 */
38 scrollableWidth: number;
39
40 /**
41 * Toggles scrollbar indicator visibility
42 */
43 scrollBarIndicatorVisible: boolean;
44
45 /**
46 * Scrolls the content the specified vertical offset position.
47 * @param value The offset value
48 * @param animated true for animated scroll, false for immediate scroll.
49 */
50 scrollToVerticalOffset(value: number, animated: boolean);
51
52 /**
53 * Scrolls the content the specified horizontal offset position.
54 * @param value The offset value
55 * @param animated true for animated scroll, false for immediate scroll.
56 */
57 scrollToHorizontalOffset(value: number, animated: boolean);
58
59 /**
60 * Gets or sets direction in which the content can be scrolled.
61 */
62 orientation: CoreTypes.OrientationType;
63
64 /**
65 * A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
66 * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
67 * @param callback - Callback function which will be executed when event is raised.
68 * @param thisArg - An optional parameter which will be used as `this` context for callback execution.
69 */
70 on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void;
71
72 /**
73 * Raised when a scroll event occurs.
74 */
75 on(event: 'scroll', callback: (args: ScrollEventData) => void, thisArg?: any): void;
76
77 _onOrientationChanged(): void;
78}
79
80export interface ScrollEventData extends EventData {
81 scrollX: number;
82 scrollY: number;
83}
84
85export const orientationProperty: Property<ScrollView, CoreTypes.OrientationType>;