forked from NativeScript/NativeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscroll-view-common.ts
More file actions
104 lines (82 loc) · 2.46 KB
/
scroll-view-common.ts
File metadata and controls
104 lines (82 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import dependencyObservable = require("ui/core/dependency-observable");
import proxy = require("ui/core/proxy");
import enums = require("ui/enums");
import definition = require("ui/scroll-view");
import contentView = require("ui/content-view");
function isValidOrientation(value: any): boolean {
return value === enums.Orientation.vertical || value === enums.Orientation.horizontal;
}
export var orientationProperty = new dependencyObservable.Property(
"orientation",
"ScrollView",
new proxy.PropertyMetadata(enums.Orientation.vertical,
dependencyObservable.PropertyMetadataSettings.AffectsLayout,
undefined,
isValidOrientation)
);
export class ScrollView extends contentView.ContentView implements definition.ScrollView {
private _scrollChangeCount: number = 0;
public static scrollEvent = "scroll";
get orientation(): string {
return this._getValue(orientationProperty);
}
set orientation(value: string) {
this._setValue(orientationProperty, value);
}
public addEventListener(arg: string, callback: any, thisArg?: any) {
super.addEventListener(arg, callback, thisArg);
if (arg === ScrollView.scrollEvent) {
this._scrollChangeCount++;
this.attach();
}
}
public removeEventListener(arg: string, callback: any, thisArg?: any) {
super.addEventListener(arg, callback, thisArg);
if (arg === ScrollView.scrollEvent) {
this._scrollChangeCount--;
this.dettach();
}
}
public onLoaded() {
super.onLoaded();
this.attach();
}
public onUnloaded() {
super.onUnloaded();
this.dettach();
}
private attach() {
if (this._scrollChangeCount > 0 && this.isLoaded) {
this.attachNative();
}
}
private dettach() {
if (this._scrollChangeCount === 0 && this.isLoaded) {
this.dettachNative();
}
}
protected attachNative() {
//
}
protected dettachNative() {
//
}
get horizontalOffset(): number {
return 0;
}
get verticalOffset(): number {
return 0;
}
get scrollableWidth(): number {
return 0;
}
get scrollableHeight(): number {
return 0;
}
public scrollToVerticalOffset(value: number, animated: boolean) {
//
}
public scrollToHorizontalOffset(value: number, animated: boolean) {
//
}
}