UNPKG

3.15 kBJavaScriptView Raw
1var ScrollViewBase_1;
2import { ContentView } from '../content-view';
3import { Property, makeParser, makeValidator } from '../core/properties';
4import { CSSType } from '../core/view';
5import { booleanConverter } from '../core/view-base';
6import { CoreTypes } from '../../core-types';
7let ScrollViewBase = ScrollViewBase_1 = class ScrollViewBase extends ContentView {
8 constructor() {
9 super(...arguments);
10 this._addedScrollEvent = false;
11 }
12 addEventListener(arg, callback, thisArg) {
13 const hasExistingScrollListeners = this.hasListeners(ScrollViewBase_1.scrollEvent);
14 super.addEventListener(arg, callback, thisArg);
15 // This indicates that a scroll listener was added for first time
16 if (!hasExistingScrollListeners && this.hasListeners(ScrollViewBase_1.scrollEvent)) {
17 this._addedScrollEvent = true;
18 if (this.nativeViewProtected) {
19 this.attachNative();
20 }
21 }
22 }
23 removeEventListener(arg, callback, thisArg) {
24 const hasExistingScrollListeners = this.hasListeners(ScrollViewBase_1.scrollEvent);
25 super.removeEventListener(arg, callback, thisArg);
26 // This indicates that the final scroll listener was removed
27 if (hasExistingScrollListeners && !this.hasListeners(ScrollViewBase_1.scrollEvent)) {
28 this._addedScrollEvent = false;
29 if (this.nativeViewProtected) {
30 this.detachNative();
31 }
32 }
33 }
34 initNativeView() {
35 super.initNativeView();
36 if (this._addedScrollEvent) {
37 this.attachNative();
38 }
39 }
40 disposeNativeView() {
41 if (this._addedScrollEvent) {
42 this.detachNative();
43 }
44 super.disposeNativeView();
45 }
46 attachNative() {
47 //
48 }
49 detachNative() {
50 //
51 }
52 get horizontalOffset() {
53 return 0;
54 }
55 get verticalOffset() {
56 return 0;
57 }
58 get scrollableWidth() {
59 return 0;
60 }
61 get scrollableHeight() {
62 return 0;
63 }
64};
65ScrollViewBase.scrollEvent = 'scroll';
66ScrollViewBase = ScrollViewBase_1 = __decorate([
67 CSSType('ScrollView')
68], ScrollViewBase);
69export { ScrollViewBase };
70const converter = makeParser(makeValidator(CoreTypes.Orientation.horizontal, CoreTypes.Orientation.vertical));
71export const orientationProperty = new Property({
72 name: 'orientation',
73 defaultValue: CoreTypes.Orientation.vertical,
74 affectsLayout: true,
75 valueChanged: (target, oldValue, newValue) => {
76 target._onOrientationChanged();
77 },
78 valueConverter: converter,
79});
80orientationProperty.register(ScrollViewBase);
81export const scrollBarIndicatorVisibleProperty = new Property({
82 name: 'scrollBarIndicatorVisible',
83 defaultValue: true,
84 valueConverter: booleanConverter,
85});
86scrollBarIndicatorVisibleProperty.register(ScrollViewBase);
87export const isScrollEnabledProperty = new Property({
88 name: 'isScrollEnabled',
89 defaultValue: true,
90 valueConverter: booleanConverter,
91});
92isScrollEnabledProperty.register(ScrollViewBase);
93//# sourceMappingURL=scroll-view-common.js.map
\No newline at end of file