mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
z-index support added
This commit is contained in:
@@ -700,6 +700,23 @@ export class ViewStyler implements style.Styler {
|
||||
private static getTranslateYProperty(view: View): any {
|
||||
return view.translateY;
|
||||
}
|
||||
|
||||
// z-index
|
||||
private static getZIndexProperty(view: View): any {
|
||||
return view.android.getZ ? view.android.getZ() : 0;
|
||||
}
|
||||
|
||||
private static setZIndexProperty(view: View, newValue: any) {
|
||||
if (view.android.setZ) {
|
||||
view.android.setZ(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
private static resetZIndexProperty(view: View, nativeValue: any) {
|
||||
if (view.android.setZ) {
|
||||
view.android.setZ(nativeValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static registerHandlers() {
|
||||
style.registerHandler(style.visibilityProperty, new style.StylePropertyChangedHandler(
|
||||
@@ -769,6 +786,11 @@ export class ViewStyler implements style.Styler {
|
||||
ViewStyler.setTranslateYProperty,
|
||||
ViewStyler.resetTranslateYProperty,
|
||||
ViewStyler.getTranslateYProperty));
|
||||
|
||||
style.registerHandler(style.zIndexProperty, new style.StylePropertyChangedHandler(
|
||||
ViewStyler.setZIndexProperty,
|
||||
ViewStyler.resetZIndexProperty,
|
||||
ViewStyler.getZIndexProperty));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -262,7 +262,7 @@ export class View extends viewCommon.View {
|
||||
return {
|
||||
x: utils.layout.toDeviceIndependentPixels(pointInWindow.x),
|
||||
y: utils.layout.toDeviceIndependentPixels(pointInWindow.y),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public getLocationOnScreen(): viewDefinition.Point {
|
||||
@@ -275,7 +275,7 @@ export class View extends viewCommon.View {
|
||||
return {
|
||||
x: utils.layout.toDeviceIndependentPixels(pointOnScreen.x),
|
||||
y: utils.layout.toDeviceIndependentPixels(pointOnScreen.y),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public getLocationRelativeTo(otherView: viewDefinition.View): viewDefinition.Point {
|
||||
@@ -290,7 +290,7 @@ export class View extends viewCommon.View {
|
||||
return {
|
||||
x: utils.layout.toDeviceIndependentPixels(myPointInWindow.x - otherPointInWindow.x),
|
||||
y: utils.layout.toDeviceIndependentPixels(myPointInWindow.y - otherPointInWindow.y),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _onSizeChanged() {
|
||||
@@ -340,17 +340,17 @@ export class View extends viewCommon.View {
|
||||
// This is done by calling CATransaction begin and commit methods.
|
||||
// This action should be disabled when updating those properties during an animation.
|
||||
public _suspendPresentationLayerUpdates() {
|
||||
this._suspendCATransaction = true;
|
||||
this._suspendCATransaction = true;
|
||||
}
|
||||
|
||||
public _resumePresentationLayerUpdates() {
|
||||
this._suspendCATransaction = false;
|
||||
this._suspendCATransaction = false;
|
||||
}
|
||||
|
||||
public _isPresentationLayerUpdateSuspeneded() {
|
||||
return this._suspendCATransaction;
|
||||
return this._suspendCATransaction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class CustomLayoutView extends View {
|
||||
|
||||
@@ -394,11 +394,11 @@ export class ViewStyler implements style.Styler {
|
||||
ensureBackground();
|
||||
var updateSuspended = view._isPresentationLayerUpdateSuspeneded();
|
||||
if (!updateSuspended) {
|
||||
CATransaction.begin();
|
||||
CATransaction.begin();
|
||||
}
|
||||
nativeView.backgroundColor = background.ios.createBackgroundUIColor(view);
|
||||
if (!updateSuspended) {
|
||||
CATransaction.commit();
|
||||
CATransaction.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -439,11 +439,11 @@ export class ViewStyler implements style.Styler {
|
||||
if (nativeView) {
|
||||
var updateSuspended = view._isPresentationLayerUpdateSuspeneded();
|
||||
if (!updateSuspended) {
|
||||
CATransaction.begin();
|
||||
CATransaction.begin();
|
||||
}
|
||||
var alpha = nativeView.alpha = newValue;
|
||||
if (!updateSuspended) {
|
||||
CATransaction.commit();
|
||||
CATransaction.commit();
|
||||
}
|
||||
return alpha;
|
||||
}
|
||||
@@ -581,6 +581,19 @@ export class ViewStyler implements style.Styler {
|
||||
private static getTranslateYProperty(view: View): any {
|
||||
return view.translateY;
|
||||
}
|
||||
|
||||
//z-index
|
||||
private static setZIndexProperty(view: View, newValue: any) {
|
||||
view.ios.layer.zPosition = newValue;
|
||||
}
|
||||
|
||||
private static resetZIndexProperty(view: View, nativeValue: any) {
|
||||
view.ios.layer.zPosition = nativeValue;
|
||||
}
|
||||
|
||||
private static getZIndexProperty(view: View): any {
|
||||
return view.ios.layer.zPosition;
|
||||
}
|
||||
|
||||
public static registerHandlers() {
|
||||
style.registerHandler(style.backgroundInternalProperty, new style.StylePropertyChangedHandler(
|
||||
@@ -635,6 +648,11 @@ export class ViewStyler implements style.Styler {
|
||||
ViewStyler.setTranslateYProperty,
|
||||
ViewStyler.resetTranslateYProperty,
|
||||
ViewStyler.getTranslateYProperty));
|
||||
|
||||
style.registerHandler(style.zIndexProperty, new style.StylePropertyChangedHandler(
|
||||
ViewStyler.setZIndexProperty,
|
||||
ViewStyler.resetZIndexProperty,
|
||||
ViewStyler.getZIndexProperty));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user