UNPKG

2.95 kBJavaScriptView Raw
1var ScrollViewBase_1;
2import { ContentView } from '../content-view';
3import { profile } from '../../profiling';
4import { Property, makeParser, makeValidator } from '../core/properties';
5import { CSSType } from '../core/view';
6import { booleanConverter } from '../core/view-base';
7import { CoreTypes } from '../../core-types';
8let ScrollViewBase = ScrollViewBase_1 = class ScrollViewBase extends ContentView {
9 constructor() {
10 super(...arguments);
11 this._scrollChangeCount = 0;
12 }
13 addEventListener(arg, callback, thisArg) {
14 super.addEventListener(arg, callback, thisArg);
15 if (arg === ScrollViewBase_1.scrollEvent) {
16 this._scrollChangeCount++;
17 this.attach();
18 }
19 }
20 removeEventListener(arg, callback, thisArg) {
21 super.removeEventListener(arg, callback, thisArg);
22 if (arg === ScrollViewBase_1.scrollEvent) {
23 this._scrollChangeCount--;
24 this.dettach();
25 }
26 }
27 onLoaded() {
28 super.onLoaded();
29 this.attach();
30 }
31 onUnloaded() {
32 super.onUnloaded();
33 this.dettach();
34 }
35 attach() {
36 if (this._scrollChangeCount > 0 && this.isLoaded) {
37 this.attachNative();
38 }
39 }
40 dettach() {
41 if (this._scrollChangeCount === 0 && this.isLoaded) {
42 this.dettachNative();
43 }
44 }
45 attachNative() {
46 //
47 }
48 dettachNative() {
49 //
50 }
51 get horizontalOffset() {
52 return 0;
53 }
54 get verticalOffset() {
55 return 0;
56 }
57 get scrollableWidth() {
58 return 0;
59 }
60 get scrollableHeight() {
61 return 0;
62 }
63};
64ScrollViewBase.scrollEvent = 'scroll';
65__decorate([
66 profile,
67 __metadata("design:type", Function),
68 __metadata("design:paramtypes", []),
69 __metadata("design:returntype", void 0)
70], ScrollViewBase.prototype, "onLoaded", null);
71ScrollViewBase = ScrollViewBase_1 = __decorate([
72 CSSType('ScrollView')
73], ScrollViewBase);
74export { ScrollViewBase };
75const converter = makeParser(makeValidator(CoreTypes.Orientation.horizontal, CoreTypes.Orientation.vertical));
76export const orientationProperty = new Property({
77 name: 'orientation',
78 defaultValue: CoreTypes.Orientation.vertical,
79 affectsLayout: true,
80 valueChanged: (target, oldValue, newValue) => {
81 target._onOrientationChanged();
82 },
83 valueConverter: converter,
84});
85orientationProperty.register(ScrollViewBase);
86export const scrollBarIndicatorVisibleProperty = new Property({
87 name: 'scrollBarIndicatorVisible',
88 defaultValue: true,
89 valueConverter: booleanConverter,
90});
91scrollBarIndicatorVisibleProperty.register(ScrollViewBase);
92export const isScrollEnabledProperty = new Property({
93 name: 'isScrollEnabled',
94 defaultValue: true,
95 valueConverter: booleanConverter,
96});
97isScrollEnabledProperty.register(ScrollViewBase);
98//# sourceMappingURL=scroll-view-common.js.map
\No newline at end of file