Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timob-15773: reset translation values appropriately #5007

Merged
merged 1 commit into from
Nov 22, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,33 @@ public void setzIndexChanged(boolean zIndexChanged)
this.zIndexChanged = zIndexChanged;
}

/**
* On Honeycomb+ devices, we use property animations, which may affect
* translation values. We need to reset translationX when 'left', 'right'
* or 'center' property is changed.
*/
private void resetTranslationX() {
if (HONEYCOMB_OR_GREATER && nativeView != null) {
nativeView.setTranslationX(0);
}
}

/**
* On Honeycomb+ devices, we use property animations, which may affect
* translation values. We need to reset translationX when 'top', 'bottom'
* or 'center' property is changed.
*/
private void resetTranslationY() {
if (HONEYCOMB_OR_GREATER && nativeView != null) {
nativeView.setTranslationY(0);
}
}

public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy)
{
if (key.equals(TiC.PROPERTY_LEFT)) {
resetPostAnimationValues();
resetTranslationX();
if (newValue != null) {
layoutParams.optionLeft = TiConvert.toTiDimension(TiConvert.toString(newValue), TiDimension.TYPE_LEFT);
} else {
Expand All @@ -577,6 +600,7 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
layoutNativeView();
} else if (key.equals(TiC.PROPERTY_TOP)) {
resetPostAnimationValues();
resetTranslationY();
if (newValue != null) {
layoutParams.optionTop = TiConvert.toTiDimension(TiConvert.toString(newValue), TiDimension.TYPE_TOP);
} else {
Expand All @@ -585,10 +609,13 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
layoutNativeView();
} else if (key.equals(TiC.PROPERTY_CENTER)) {
resetPostAnimationValues();
resetTranslationX();
resetTranslationY();
TiConvert.updateLayoutCenter(newValue, layoutParams);
layoutNativeView();
} else if (key.equals(TiC.PROPERTY_RIGHT)) {
resetPostAnimationValues();
resetTranslationX();
if (newValue != null) {
layoutParams.optionRight = TiConvert.toTiDimension(TiConvert.toString(newValue), TiDimension.TYPE_RIGHT);
} else {
Expand All @@ -597,6 +624,7 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
layoutNativeView();
} else if (key.equals(TiC.PROPERTY_BOTTOM)) {
resetPostAnimationValues();
resetTranslationY();
if (newValue != null) {
layoutParams.optionBottom = TiConvert.toTiDimension(TiConvert.toString(newValue), TiDimension.TYPE_BOTTOM);
} else {
Expand Down