uicore-ts 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/uicore.iml +9 -0
- package/.idea/vcs.xml +6 -0
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/compiledScripts/UIActionIndicator.d.ts +12 -0
- package/compiledScripts/UIActionIndicator.js +54 -0
- package/compiledScripts/UIActionIndicator.js.map +1 -0
- package/compiledScripts/UIBaseButton.d.ts +52 -0
- package/compiledScripts/UIBaseButton.js +268 -0
- package/compiledScripts/UIBaseButton.js.map +1 -0
- package/compiledScripts/UIButton.d.ts +54 -0
- package/compiledScripts/UIButton.js +247 -0
- package/compiledScripts/UIButton.js.map +1 -0
- package/compiledScripts/UIColor.d.ts +41 -0
- package/compiledScripts/UIColor.js +286 -0
- package/compiledScripts/UIColor.js.map +1 -0
- package/compiledScripts/UICore.d.ts +27 -0
- package/compiledScripts/UICore.js +105 -0
- package/compiledScripts/UICore.js.map +1 -0
- package/compiledScripts/UICoreExtensions.d.ts +60 -0
- package/compiledScripts/UICoreExtensions.js +527 -0
- package/compiledScripts/UICoreExtensions.js.map +1 -0
- package/compiledScripts/UIDateTimeInput.d.ts +40 -0
- package/compiledScripts/UIDateTimeInput.js +38 -0
- package/compiledScripts/UIDateTimeInput.js.map +1 -0
- package/compiledScripts/UIDialogView.d.ts +23 -0
- package/compiledScripts/UIDialogView.js +118 -0
- package/compiledScripts/UIDialogView.js.map +1 -0
- package/compiledScripts/UIImageView.d.ts +36 -0
- package/compiledScripts/UIImageView.js +170 -0
- package/compiledScripts/UIImageView.js.map +1 -0
- package/compiledScripts/UIKeyValueStringFilter.d.ts +21 -0
- package/compiledScripts/UIKeyValueStringFilter.js +98 -0
- package/compiledScripts/UIKeyValueStringFilter.js.map +1 -0
- package/compiledScripts/UIKeyValueStringSorter.d.ts +38 -0
- package/compiledScripts/UIKeyValueStringSorter.js +117 -0
- package/compiledScripts/UIKeyValueStringSorter.js.map +1 -0
- package/compiledScripts/UILayoutGrid.d.ts +8 -0
- package/compiledScripts/UILayoutGrid.js +22 -0
- package/compiledScripts/UILayoutGrid.js.map +1 -0
- package/compiledScripts/UILink.d.ts +25 -0
- package/compiledScripts/UILink.js +81 -0
- package/compiledScripts/UILink.js.map +1 -0
- package/compiledScripts/UILinkButton.d.ts +18 -0
- package/compiledScripts/UILinkButton.js +60 -0
- package/compiledScripts/UILinkButton.js.map +1 -0
- package/compiledScripts/UINativeScrollView.d.ts +20 -0
- package/compiledScripts/UINativeScrollView.js +121 -0
- package/compiledScripts/UINativeScrollView.js.map +1 -0
- package/compiledScripts/UIObject.d.ts +69 -0
- package/compiledScripts/UIObject.js +442 -0
- package/compiledScripts/UIObject.js.map +1 -0
- package/compiledScripts/UIPoint.d.ts +18 -0
- package/compiledScripts/UIPoint.js +68 -0
- package/compiledScripts/UIPoint.js.map +1 -0
- package/compiledScripts/UIRectangle.d.ts +61 -0
- package/compiledScripts/UIRectangle.js +421 -0
- package/compiledScripts/UIRectangle.js.map +1 -0
- package/compiledScripts/UIRoute.d.ts +39 -0
- package/compiledScripts/UIRoute.js +202 -0
- package/compiledScripts/UIRoute.js.map +1 -0
- package/compiledScripts/UIScrollView.d.ts +19 -0
- package/compiledScripts/UIScrollView.js +121 -0
- package/compiledScripts/UIScrollView.js.map +1 -0
- package/compiledScripts/UISlideScrollerView.d.ts +40 -0
- package/compiledScripts/UISlideScrollerView.js +242 -0
- package/compiledScripts/UISlideScrollerView.js.map +1 -0
- package/compiledScripts/UIStringFilter.d.ts +26 -0
- package/compiledScripts/UIStringFilter.js +107 -0
- package/compiledScripts/UIStringFilter.js.map +1 -0
- package/compiledScripts/UITableView.d.ts +61 -0
- package/compiledScripts/UITableView.js +383 -0
- package/compiledScripts/UITableView.js.map +1 -0
- package/compiledScripts/UITextArea.d.ts +7 -0
- package/compiledScripts/UITextArea.js +27 -0
- package/compiledScripts/UITextArea.js.map +1 -0
- package/compiledScripts/UITextField.d.ts +44 -0
- package/compiledScripts/UITextField.js +83 -0
- package/compiledScripts/UITextField.js.map +1 -0
- package/compiledScripts/UITextView.d.ts +89 -0
- package/compiledScripts/UITextView.js +237 -0
- package/compiledScripts/UITextView.js.map +1 -0
- package/compiledScripts/UITimer.d.ts +13 -0
- package/compiledScripts/UITimer.js +45 -0
- package/compiledScripts/UITimer.js.map +1 -0
- package/compiledScripts/UIView.d.ts +330 -0
- package/compiledScripts/UIView.js +1533 -0
- package/compiledScripts/UIView.js.map +1 -0
- package/compiledScripts/UIViewController.d.ts +38 -0
- package/compiledScripts/UIViewController.js +153 -0
- package/compiledScripts/UIViewController.js.map +1 -0
- package/compiledScripts/index.d.ts +29 -0
- package/compiledScripts/index.js +46 -0
- package/compiledScripts/index.js.map +1 -0
- package/package.json +36 -0
- package/scripts/UIActionIndicator.ts +139 -0
- package/scripts/UIBaseButton.ts +563 -0
- package/scripts/UIButton.ts +552 -0
- package/scripts/UIColor.ts +427 -0
- package/scripts/UICore.ts +223 -0
- package/scripts/UICoreExtensions.ts +949 -0
- package/scripts/UIDateTimeInput.ts +109 -0
- package/scripts/UIDialogView.ts +297 -0
- package/scripts/UIImageView.ts +366 -0
- package/scripts/UIKeyValueStringFilter.ts +260 -0
- package/scripts/UIKeyValueStringSorter.ts +337 -0
- package/scripts/UILayoutGrid.ts +83 -0
- package/scripts/UILink.ts +292 -0
- package/scripts/UILinkButton.ts +238 -0
- package/scripts/UINativeScrollView.ts +254 -0
- package/scripts/UIObject.ts +827 -0
- package/scripts/UIPoint.ts +123 -0
- package/scripts/UIRectangle.ts +730 -0
- package/scripts/UIRoute.ts +391 -0
- package/scripts/UIScrollView.ts +290 -0
- package/scripts/UISlideScrollerView.ts +530 -0
- package/scripts/UIStringFilter.ts +293 -0
- package/scripts/UITableView.ts +790 -0
- package/scripts/UITextArea.ts +91 -0
- package/scripts/UITextField.ts +218 -0
- package/scripts/UITextView.ts +561 -0
- package/scripts/UITimer.ts +107 -0
- package/scripts/UIView.ts +2789 -0
- package/scripts/UIViewController.ts +304 -0
- package/scripts/index.ts +36 -0
- package/tsconfig.json +59 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import { IS_NIL, IS_NOT, nil, NO } from "./UIObject"
|
|
2
|
+
import { UIViewController } from "./UIViewController"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export type ValueOf<T> = T[keyof T];
|
|
6
|
+
export type PropType<TObj, TProp extends keyof TObj> = TObj[TProp];
|
|
7
|
+
|
|
8
|
+
export type UIRouteParameters<T = any> = {
|
|
9
|
+
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
|
|
12
|
+
} | T;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export interface UIRouteComponent<T = any> {
|
|
16
|
+
|
|
17
|
+
name: string;
|
|
18
|
+
parameters: UIRouteParameters<T>;
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
export class UIRoute extends Array<UIRouteComponent> {
|
|
25
|
+
|
|
26
|
+
_isHandled: boolean = NO
|
|
27
|
+
completedComponents: UIRouteComponent[] = []
|
|
28
|
+
|
|
29
|
+
parentRoute: UIRoute
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
constructor(hash?: string) {
|
|
33
|
+
|
|
34
|
+
super()
|
|
35
|
+
|
|
36
|
+
if (!hash || !hash.startsWith) {
|
|
37
|
+
|
|
38
|
+
return
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (hash.startsWith("#")) {
|
|
43
|
+
hash = hash.slice(1)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
hash = decodeURIComponent(hash)
|
|
47
|
+
|
|
48
|
+
const components = hash.split("]")
|
|
49
|
+
components.forEach(function (this: UIRoute, component: string, index: number, array: string[]) {
|
|
50
|
+
|
|
51
|
+
const componentName = component.split("[")[0]
|
|
52
|
+
const parameters = {}
|
|
53
|
+
|
|
54
|
+
if (!componentName) {
|
|
55
|
+
|
|
56
|
+
return
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const parametersString = component.split("[")[1] || ""
|
|
61
|
+
const parameterPairStrings = parametersString.split(",") || []
|
|
62
|
+
|
|
63
|
+
parameterPairStrings.forEach(function (pairString, index, array) {
|
|
64
|
+
|
|
65
|
+
const keyAndValueArray = pairString.split(":")
|
|
66
|
+
const key = decodeURIComponent(keyAndValueArray[0])
|
|
67
|
+
const value = decodeURIComponent(keyAndValueArray[1])
|
|
68
|
+
|
|
69
|
+
if (key) {
|
|
70
|
+
|
|
71
|
+
parameters[key] = value
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
this.push({
|
|
82
|
+
name: componentName,
|
|
83
|
+
parameters: parameters
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
}, this)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
static get currentRoute() {
|
|
98
|
+
|
|
99
|
+
return new UIRoute(window.location.hash)
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
apply() {
|
|
108
|
+
|
|
109
|
+
window.location.hash = this.stringRepresentation
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
applyByReplacingCurrentRouteInHistory() {
|
|
115
|
+
|
|
116
|
+
window.location.replace(this.linkRepresentation)
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
copy() {
|
|
123
|
+
var result = new UIRoute()
|
|
124
|
+
result = Object.assign(result, this)
|
|
125
|
+
return result
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
childRoute() {
|
|
130
|
+
|
|
131
|
+
var result = this.copy()
|
|
132
|
+
|
|
133
|
+
result.completedComponents.forEach(function (component, index, completedComponents) {
|
|
134
|
+
|
|
135
|
+
var indexInResult = result.indexOf(component)
|
|
136
|
+
|
|
137
|
+
if (indexInResult > -1) {
|
|
138
|
+
|
|
139
|
+
result.splice(indexInResult, 1)
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
result.completedComponents = []
|
|
146
|
+
|
|
147
|
+
result.parentRoute = this
|
|
148
|
+
return result
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
routeByRemovingComponentsOtherThanOnesNamed(componentNames: string[]) {
|
|
155
|
+
const result = this.copy()
|
|
156
|
+
const indexesToRemove: number[] = []
|
|
157
|
+
result.forEach(function (component, index, array) {
|
|
158
|
+
if (!componentNames.contains(component.name)) {
|
|
159
|
+
indexesToRemove.push(index)
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
indexesToRemove.forEach(function (indexToRemove, index, array) {
|
|
163
|
+
result.removeElementAtIndex(indexToRemove)
|
|
164
|
+
})
|
|
165
|
+
return result
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
routeByRemovingComponentNamed(componentName: string) {
|
|
171
|
+
const result = this.copy()
|
|
172
|
+
const componentIndex = result.findIndex(function (component, index) {
|
|
173
|
+
return (component.name == componentName)
|
|
174
|
+
})
|
|
175
|
+
if (componentIndex != -1) {
|
|
176
|
+
result.splice(componentIndex, 1)
|
|
177
|
+
}
|
|
178
|
+
return result
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
routeByRemovingParameterInComponent(componentName: string, parameterName: string, removeComponentIfEmpty = NO) {
|
|
183
|
+
var result = this.copy()
|
|
184
|
+
var parameters = result.componentWithName(componentName).parameters
|
|
185
|
+
if (IS_NOT(parameters)) {
|
|
186
|
+
parameters = {}
|
|
187
|
+
}
|
|
188
|
+
delete parameters[parameterName]
|
|
189
|
+
result = result.routeWithComponent(componentName, parameters)
|
|
190
|
+
if (removeComponentIfEmpty && Object.keys(parameters).length == 0) {
|
|
191
|
+
result = result.routeByRemovingComponentNamed(componentName)
|
|
192
|
+
}
|
|
193
|
+
return result
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
routeBySettingParameterInComponent(componentName: string, parameterName: string, valueToSet: string) {
|
|
197
|
+
var result = this.copy()
|
|
198
|
+
if (IS_NIL(valueToSet) || IS_NIL(parameterName)) {
|
|
199
|
+
return result
|
|
200
|
+
}
|
|
201
|
+
var parameters = result.componentWithName(componentName).parameters
|
|
202
|
+
if (IS_NOT(parameters)) {
|
|
203
|
+
parameters = {}
|
|
204
|
+
}
|
|
205
|
+
parameters[parameterName] = valueToSet
|
|
206
|
+
result = result.routeWithComponent(componentName, parameters)
|
|
207
|
+
return result
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
routeWithViewControllerComponent<T extends typeof UIViewController>(
|
|
212
|
+
viewController: T,
|
|
213
|
+
parameters: UIRouteParameters<{ [P in keyof T["ParameterIdentifierName"]]: string }>,
|
|
214
|
+
extendParameters: boolean = NO
|
|
215
|
+
) {
|
|
216
|
+
|
|
217
|
+
return this.routeWithComponent(viewController.routeComponentName, parameters, extendParameters)
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
routeWithComponent(name: string, parameters: UIRouteParameters, extendParameters: boolean = NO) {
|
|
222
|
+
|
|
223
|
+
const result = this.copy()
|
|
224
|
+
var component = result.componentWithName(name)
|
|
225
|
+
if (IS_NOT(component)) {
|
|
226
|
+
component = {
|
|
227
|
+
name: name,
|
|
228
|
+
parameters: {}
|
|
229
|
+
}
|
|
230
|
+
result.push(component)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (IS_NOT(parameters)) {
|
|
234
|
+
|
|
235
|
+
parameters = {}
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (extendParameters) {
|
|
240
|
+
component.parameters = Object.assign(component.parameters, parameters)
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
component.parameters = parameters
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return result
|
|
247
|
+
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
navigateBySettingComponent(name: string, parameters: UIRouteParameters, extendParameters: boolean = NO) {
|
|
251
|
+
|
|
252
|
+
this.routeWithComponent(name, parameters, extendParameters).apply()
|
|
253
|
+
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
componentWithViewController<T extends typeof UIViewController>(viewController: T): UIRouteComponent<{ [P in keyof T["ParameterIdentifierName"]]: string }> {
|
|
259
|
+
|
|
260
|
+
return this.componentWithName(viewController.routeComponentName)
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
componentWithName(name: string): UIRouteComponent {
|
|
265
|
+
var result = nil
|
|
266
|
+
this.forEach(function (component, index, self) {
|
|
267
|
+
if (component.name == name) {
|
|
268
|
+
result = component
|
|
269
|
+
}
|
|
270
|
+
})
|
|
271
|
+
return result
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
didcompleteComponent(component: UIRouteComponent) {
|
|
277
|
+
|
|
278
|
+
const self: UIRoute = this
|
|
279
|
+
const index = self.indexOf(component, 0)
|
|
280
|
+
if (index > -1) {
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
self.completedComponents.push(self.splice(index, 1)[0])
|
|
284
|
+
|
|
285
|
+
//self.completedComponents.push(component);
|
|
286
|
+
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
set isHandled(isHandled: boolean) {
|
|
292
|
+
|
|
293
|
+
this._isHandled = isHandled
|
|
294
|
+
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
get isHandled() {
|
|
298
|
+
|
|
299
|
+
return (this._isHandled || (this.length == 0 && this.completedComponents.length != 0))
|
|
300
|
+
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
get linkRepresentation() {
|
|
305
|
+
return "#" + this.stringRepresentation
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
get stringRepresentation() {
|
|
310
|
+
var result = ""
|
|
311
|
+
this.completedComponents.forEach(function (component, index, self) {
|
|
312
|
+
result = result + component.name
|
|
313
|
+
const parameters = component.parameters
|
|
314
|
+
result = result + "["
|
|
315
|
+
Object.keys(parameters).forEach(function (key, index, keys) {
|
|
316
|
+
if (index) {
|
|
317
|
+
result = result + ","
|
|
318
|
+
}
|
|
319
|
+
result = result + encodeURIComponent(key) + ":" + encodeURIComponent(parameters[key])
|
|
320
|
+
})
|
|
321
|
+
result = result + "]"
|
|
322
|
+
})
|
|
323
|
+
this.forEach(function (component, index, self) {
|
|
324
|
+
result = result + component.name
|
|
325
|
+
const parameters = component.parameters
|
|
326
|
+
result = result + "["
|
|
327
|
+
Object.keys(parameters).forEach(function (key, index, keys) {
|
|
328
|
+
if (index) {
|
|
329
|
+
result = result + ","
|
|
330
|
+
}
|
|
331
|
+
result = result + encodeURIComponent(key) + ":" + encodeURIComponent(parameters[key])
|
|
332
|
+
})
|
|
333
|
+
result = result + "]"
|
|
334
|
+
})
|
|
335
|
+
return result
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { nil, NO, YES } from "./UIObject"
|
|
2
|
+
import { UIPoint } from "./UIPoint"
|
|
3
|
+
import { UIRectangle } from "./UIRectangle"
|
|
4
|
+
import { UIView } from "./UIView"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export class UIScrollView extends UIView {
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
_contentOffset: UIPoint = new UIPoint(0, 0)
|
|
14
|
+
_contentScale: number = 1
|
|
15
|
+
|
|
16
|
+
containerView: UIView
|
|
17
|
+
|
|
18
|
+
_pointerDown: boolean
|
|
19
|
+
|
|
20
|
+
_scrollEnabled: boolean = YES
|
|
21
|
+
|
|
22
|
+
_previousClientPoint: UIPoint
|
|
23
|
+
|
|
24
|
+
_intrinsicContentFrame: UIRectangle
|
|
25
|
+
|
|
26
|
+
constructor(elementID: string, viewHTMLElement?: HTMLElement) {
|
|
27
|
+
|
|
28
|
+
super(elementID, viewHTMLElement)
|
|
29
|
+
|
|
30
|
+
this._class = UIScrollView
|
|
31
|
+
this.superclass = UIView
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
this.containerView = new UIView(elementID + "ContainerView")
|
|
35
|
+
|
|
36
|
+
super.addSubview(this.containerView)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
this.style.overflow = "hidden"
|
|
40
|
+
|
|
41
|
+
this.pausesPointerEvents = NO //YES;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
this.addTargetForControlEvent(UIView.controlEvent.PointerDown, function () {
|
|
45
|
+
|
|
46
|
+
this._pointerDown = YES
|
|
47
|
+
|
|
48
|
+
}.bind(this))
|
|
49
|
+
|
|
50
|
+
this.addTargetForControlEvent(UIView.controlEvent.PointerUp, function () {
|
|
51
|
+
|
|
52
|
+
this._pointerDown = NO
|
|
53
|
+
|
|
54
|
+
this._previousClientPoint = null
|
|
55
|
+
|
|
56
|
+
scrollStopped()
|
|
57
|
+
|
|
58
|
+
}.bind(this))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
function scrollStopped() {
|
|
62
|
+
|
|
63
|
+
// Handle paging if needed
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
this.addTargetForControlEvent(UIView.controlEvent.PointerMove, function (sender: UIScrollView, event: Event) {
|
|
69
|
+
|
|
70
|
+
if (!(this._pointerDown && this._scrollEnabled && this._enabled)) {
|
|
71
|
+
|
|
72
|
+
return
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const currentClientPoint = new UIPoint(nil, nil)
|
|
77
|
+
|
|
78
|
+
if ((window as any).MouseEvent && event instanceof MouseEvent) {
|
|
79
|
+
|
|
80
|
+
currentClientPoint.x = (event as MouseEvent).clientX
|
|
81
|
+
currentClientPoint.y = (event as MouseEvent).clientY
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if ((window as any).TouchEvent && event instanceof TouchEvent) {
|
|
86
|
+
|
|
87
|
+
const touchEvent: TouchEvent = event
|
|
88
|
+
|
|
89
|
+
if (touchEvent.touches.length != 1) {
|
|
90
|
+
|
|
91
|
+
this._pointerDown = NO
|
|
92
|
+
this._previousClientPoint = null
|
|
93
|
+
|
|
94
|
+
scrollStopped()
|
|
95
|
+
|
|
96
|
+
return
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
currentClientPoint.x = touchEvent.touches[0].clientX
|
|
101
|
+
currentClientPoint.y = touchEvent.touches[0].clientY
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!this._previousClientPoint) {
|
|
106
|
+
|
|
107
|
+
this._previousClientPoint = currentClientPoint
|
|
108
|
+
|
|
109
|
+
return
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const changePoint = currentClientPoint.copy().subtract(this._previousClientPoint)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
if (this.containerView.bounds.width <= this.bounds.width) {
|
|
117
|
+
changePoint.x = 0
|
|
118
|
+
}
|
|
119
|
+
if (0 < this.contentOffset.x + changePoint.x) {
|
|
120
|
+
changePoint.x = -this.contentOffset.x
|
|
121
|
+
}
|
|
122
|
+
if (this.contentOffset.x + changePoint.x < -this.bounds.width) {
|
|
123
|
+
changePoint.x = -this.bounds.width - this.contentOffset.x
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (this.containerView.bounds.height <= this.bounds.height) {
|
|
127
|
+
changePoint.y = 0
|
|
128
|
+
}
|
|
129
|
+
if (0 < this.contentOffset.y + changePoint.y) {
|
|
130
|
+
changePoint.y = -this.contentOffset.y
|
|
131
|
+
}
|
|
132
|
+
if (this.contentOffset.y + changePoint.y < -this.bounds.height) {
|
|
133
|
+
changePoint.y = -this.bounds.height - this.contentOffset.y
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
this.contentOffset = this.contentOffset.add(changePoint)
|
|
137
|
+
|
|
138
|
+
this._previousClientPoint = currentClientPoint
|
|
139
|
+
|
|
140
|
+
}.bind(this))
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
invalidateIntrinsicContentFrame() {
|
|
152
|
+
|
|
153
|
+
this._intrinsicContentFrame = nil
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
get contentOffset() {
|
|
162
|
+
|
|
163
|
+
return this._contentOffset
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
set contentOffset(offset: UIPoint) {
|
|
168
|
+
|
|
169
|
+
this._contentOffset = offset
|
|
170
|
+
this.setNeedsLayout()
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
layoutSubviews() {
|
|
177
|
+
|
|
178
|
+
super.layoutSubviews()
|
|
179
|
+
|
|
180
|
+
// var intrinsicContentFrame = this._intrinsicContentFrame;
|
|
181
|
+
// if (!IS(intrinsicContentFrame)) {
|
|
182
|
+
// intrinsicContentFrame = this.containerView.intrinsicContentSizeWithConstraints();
|
|
183
|
+
// }
|
|
184
|
+
// intrinsicContentFrame.offsetByPoint(this.contentOffset);
|
|
185
|
+
// intrinsicContentFrame.height = this.containerView.viewHTMLElement.scrollHeight;
|
|
186
|
+
// intrinsicContentFrame.width = this.containerView.viewHTMLElement.scrollWidth;
|
|
187
|
+
// this.containerView.frame = intrinsicContentFrame;
|
|
188
|
+
|
|
189
|
+
this.containerView.frame = this.containerView.bounds.offsetByPoint(this.contentOffset)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
// get _subviews() {
|
|
199
|
+
// return super.subviews;
|
|
200
|
+
// }
|
|
201
|
+
|
|
202
|
+
// set _subviews(subviews: UIView[]) {
|
|
203
|
+
// super.subviews = subviews;
|
|
204
|
+
// }
|
|
205
|
+
|
|
206
|
+
// get subviews() {
|
|
207
|
+
// return this.containerView.subviews;
|
|
208
|
+
// }
|
|
209
|
+
|
|
210
|
+
// set subviews(subviews: UIView[]) {
|
|
211
|
+
|
|
212
|
+
// this.containerView.subviews = subviews;
|
|
213
|
+
|
|
214
|
+
// this.invalidateIntrinsicContentFrame();
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
// }
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
hasSubview(view: UIView) {
|
|
221
|
+
return this.containerView.hasSubview(view)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
addSubview(view: UIView) {
|
|
225
|
+
|
|
226
|
+
this.containerView.addSubview(view)
|
|
227
|
+
|
|
228
|
+
this.invalidateIntrinsicContentFrame()
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|