mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Merge pull request #1241 from NativeScript/unfix-1223
Reverted the changes made with commit 700818d (Resolves Issue #1223).…
This commit is contained in:
@ -25,8 +25,11 @@ export function pageLoaded(args: observable.EventData) {
|
|||||||
|
|
||||||
export function onSetOpacity(args: observable.EventData) {
|
export function onSetOpacity(args: observable.EventData) {
|
||||||
var newOpacity = opacitySlider.value / 100;
|
var newOpacity = opacitySlider.value / 100;
|
||||||
container._eachChildView((childView: view.View) => {
|
container._eachChildView((view: view.View) => {
|
||||||
childView.opacity = newOpacity;
|
//if (view.android) {
|
||||||
|
// view.android.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
|
||||||
|
//}
|
||||||
|
view.opacity = newOpacity;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -35,9 +38,12 @@ var animationSet: animationModule.Animation;
|
|||||||
export function onAnimateOpacity(args: observable.EventData) {
|
export function onAnimateOpacity(args: observable.EventData) {
|
||||||
var newOpacity = opacitySlider.value / 100;
|
var newOpacity = opacitySlider.value / 100;
|
||||||
var animationDefinitions = new Array<animationModule.AnimationDefinition>();
|
var animationDefinitions = new Array<animationModule.AnimationDefinition>();
|
||||||
container._eachChildView((childView: view.View) => {
|
container._eachChildView((view: view.View) => {
|
||||||
|
//if (view.android) {
|
||||||
|
// view.android.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
|
||||||
|
//}
|
||||||
animationDefinitions.push({
|
animationDefinitions.push({
|
||||||
target: childView,
|
target: view,
|
||||||
opacity: newOpacity,
|
opacity: newOpacity,
|
||||||
duration: 5000
|
duration: 5000
|
||||||
});
|
});
|
||||||
|
@ -159,18 +159,11 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
|
|
||||||
case common.Properties.opacity:
|
case common.Properties.opacity:
|
||||||
originalValue1 = nativeView.getAlpha();
|
originalValue1 = nativeView.getAlpha();
|
||||||
nativeArray = java.lang.reflect.Array.newInstance(floatType, 2);
|
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
|
||||||
nativeArray[0] = originalValue1;
|
nativeArray[0] = propertyAnimation.value;
|
||||||
nativeArray[1] = propertyAnimation.value;
|
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.opacity = propertyAnimation.value }));
|
||||||
animator = android.animation.ValueAnimator.ofFloat(nativeArray);
|
propertyResetCallbacks.push(checkAnimation(() => { nativeView.setAlpha(originalValue1); }));
|
||||||
animator.addUpdateListener(new android.animation.ValueAnimator.AnimatorUpdateListener({
|
animators.push(android.animation.ObjectAnimator.ofFloat(nativeView, "alpha", nativeArray));
|
||||||
onAnimationUpdate(animator: android.animation.ValueAnimator) {
|
|
||||||
propertyAnimation.target.opacity = (<java.lang.Float>animator.getAnimatedValue()).floatValue();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.opacity = propertyAnimation.value; }));
|
|
||||||
propertyResetCallbacks.push(checkAnimation(() => { propertyAnimation.target.opacity = originalValue1; }));
|
|
||||||
animators.push(animator);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case common.Properties.backgroundColor:
|
case common.Properties.backgroundColor:
|
||||||
|
@ -60,6 +60,9 @@ function onBackgroundOrBorderPropertyChanged(v: view.View) {
|
|||||||
// http://developer.android.com/guide/topics/graphics/hardware-accel.html
|
// http://developer.android.com/guide/topics/graphics/hardware-accel.html
|
||||||
nativeView.setLayerType(android.view.View.LAYER_TYPE_SOFTWARE, null);
|
nativeView.setLayerType(android.view.View.LAYER_TYPE_SOFTWARE, null);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
nativeView.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// reset the value with the default native value
|
// reset the value with the default native value
|
||||||
@ -341,25 +344,6 @@ export class ImageStyler implements definition.stylers.Styler {
|
|||||||
onBackgroundOrBorderPropertyChanged(view);
|
onBackgroundOrBorderPropertyChanged(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Opacity methods
|
|
||||||
private static setOpacityProperty(view: view.View, newValue: any) {
|
|
||||||
ImageStyler._setOpacity(view, newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static resetOpacityProperty(view: view.View, nativeValue: any) {
|
|
||||||
ImageStyler._setOpacity(view, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static _setOpacity(view: view.View, value: any) {
|
|
||||||
let opacity = float(value);
|
|
||||||
let nativeView = <android.view.View>view._nativeView;
|
|
||||||
nativeView.setAlpha(opacity);
|
|
||||||
let background = nativeView.getBackground();
|
|
||||||
if (background) {
|
|
||||||
background.setAlpha(opacity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static registerHandlers() {
|
public static registerHandlers() {
|
||||||
// Use the same handler for all background/border properties
|
// Use the same handler for all background/border properties
|
||||||
// Note: There is no default value getter - the default value is handled in onBackgroundOrBorderPropertyChanged
|
// Note: There is no default value getter - the default value is handled in onBackgroundOrBorderPropertyChanged
|
||||||
@ -371,10 +355,6 @@ export class ImageStyler implements definition.stylers.Styler {
|
|||||||
style.registerHandler(style.borderWidthProperty, new stylersCommon.StylePropertyChangedHandler(
|
style.registerHandler(style.borderWidthProperty, new stylersCommon.StylePropertyChangedHandler(
|
||||||
ImageStyler.setBorderWidthProperty,
|
ImageStyler.setBorderWidthProperty,
|
||||||
ImageStyler.resetBorderWidthProperty), "Image");
|
ImageStyler.resetBorderWidthProperty), "Image");
|
||||||
|
|
||||||
style.registerHandler(style.opacityProperty, new stylersCommon.StylePropertyChangedHandler(
|
|
||||||
ImageStyler.setOpacityProperty,
|
|
||||||
ImageStyler.resetOpacityProperty), "Image");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user