Merge pull request #2547 from NativeScript/hhristov/zindex-fix-lower-apis

z-index handler added only for API 21+
This commit is contained in:
SvetoslavTsenov
2016-08-03 18:48:36 +03:00
committed by GitHub

View File

@@ -10,6 +10,7 @@ import style = require("ui/styling/style");
import enums = require("ui/enums");
import background = require("ui/styling/background");
import {CommonLayoutParams, Thickness} from "ui/styling/style";
import {device} from "platform";
global.moduleMerge(viewCommon, exports);
@@ -51,6 +52,8 @@ function onIsUserInteractionEnabledPropertyChanged(data: dependencyObservable.Pr
}
(<proxy.PropertyMetadata>viewCommon.View.isUserInteractionEnabledProperty.metadata).onSetNativeValue = onIsUserInteractionEnabledPropertyChanged;
let styleHandlersInitialized: boolean;
export class View extends viewCommon.View {
private _disableUserInteractionListener: android.view.View.OnTouchListener = new android.view.View.OnTouchListener({
onTouch: function (view: android.view.View, event: android.view.MotionEvent) {
@@ -58,6 +61,14 @@ export class View extends viewCommon.View {
}
});
constructor() {
super();
if (!styleHandlersInitialized) {
styleHandlersInitialized = true;
ViewStyler.registerHandlers();
}
}
public _updateOnTouchListener(isUserInteractionEnabled: boolean) {
// User interaction is disabled -- we stop it and we do not care whether someone wants to listen for gestures.
if (!isUserInteractionEnabled) {
@@ -784,12 +795,12 @@ export class ViewStyler implements style.Styler {
style.registerHandler(style.translateYProperty, new style.StylePropertyChangedHandler(
ViewStyler.setTranslateYProperty,
ViewStyler.resetTranslateYProperty));
style.registerHandler(style.zIndexProperty, new style.StylePropertyChangedHandler(
ViewStyler.setZIndexProperty,
ViewStyler.resetZIndexProperty,
ViewStyler.getZIndexProperty));
if (parseInt(device.sdkVersion, 10) >= 21) {
style.registerHandler(style.zIndexProperty, new style.StylePropertyChangedHandler(
ViewStyler.setZIndexProperty,
ViewStyler.resetZIndexProperty,
ViewStyler.getZIndexProperty));
}
}
}
ViewStyler.registerHandlers();
}