mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Eliminate rounding errors
This commit is contained in:
@@ -389,6 +389,23 @@ export class View extends viewCommon.View {
|
||||
}
|
||||
}
|
||||
|
||||
public getLocationRelativeTo(otherView: viewDefinition.View): viewDefinition.Point {
|
||||
if (!this._nativeView || !this._nativeView.getWindowToken() ||
|
||||
!otherView._nativeView || !otherView._nativeView.getWindowToken() ||
|
||||
this._nativeView.getWindowToken() !== otherView._nativeView.getWindowToken()) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var myArray = (<any>Array).create("int", 2);
|
||||
this._nativeView.getLocationOnScreen(myArray);
|
||||
var otherArray = (<any>Array).create("int", 2);
|
||||
otherView._nativeView.getLocationOnScreen(otherArray);
|
||||
return {
|
||||
x: utils.layout.toDeviceIndependentPixels(myArray[0] - otherArray[0]),
|
||||
y: utils.layout.toDeviceIndependentPixels(myArray[1] - otherArray[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