mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Add public instance methods to View class for getting locations and sizes
Resolves #1760
This commit is contained in:
@@ -363,6 +363,32 @@ export class View extends viewCommon.View {
|
||||
return false;
|
||||
}
|
||||
|
||||
public getLocationInWindow(): viewDefinition.Point {
|
||||
if (!this._nativeView || !this._nativeView.getWindowToken()) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var nativeArray = (<any>Array).create("int", 2);
|
||||
this._nativeView.getLocationInWindow(nativeArray);
|
||||
return {
|
||||
x: utils.layout.toDeviceIndependentPixels(nativeArray[0]),
|
||||
y: utils.layout.toDeviceIndependentPixels(nativeArray[1]),
|
||||
}
|
||||
}
|
||||
|
||||
public getLocationOnScreen(): viewDefinition.Point {
|
||||
if (!this._nativeView || !this._nativeView.getWindowToken()) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var nativeArray = (<any>Array).create("int", 2);
|
||||
this._nativeView.getLocationOnScreen(nativeArray);
|
||||
return {
|
||||
x: utils.layout.toDeviceIndependentPixels(nativeArray[0]),
|
||||
y: utils.layout.toDeviceIndependentPixels(nativeArray[1]),
|
||||
}
|
||||
}
|
||||
|
||||
public static resolveSizeAndState(size: number, specSize: number, specMode: number, childMeasuredState: number): number {
|
||||
var result = size;
|
||||
switch (specMode) {
|
||||
|
||||
Reference in New Issue
Block a user