Skip to content

Commit

Permalink
fix(android): fixed transition when element was scaled
Browse files Browse the repository at this point in the history
  • Loading branch information
IjzerenHein committed Sep 4, 2019
1 parent 09c6c56 commit ee27709
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Expand Up @@ -21,6 +21,7 @@

public class RNSharedElementTransition extends ViewGroup {
static private String LOG_TAG = "RNSharedElementTransition";
static private Rect EMPTY_RECT = new Rect();

enum Item {
START(0),
Expand Down Expand Up @@ -180,15 +181,17 @@ private void updateLayout() {
RNSharedElementContent endContent = endItem.getContent();

// Get layout
Rect startLayout = (startStyle != null) ? startStyle.layout : new Rect();
Rect endLayout = (endStyle != null) ? endStyle.layout : new Rect();
Rect startLayout = (startStyle != null) ? startStyle.layout : EMPTY_RECT;
Rect startFrame = (startStyle != null) ? startStyle.frame : EMPTY_RECT;
Rect endLayout = (endStyle != null) ? endStyle.layout : EMPTY_RECT;
Rect endFrame = (endStyle != null) ? endStyle.frame : EMPTY_RECT;
Rect parentLayout = new Rect(startLayout);
parentLayout.union(endLayout);

// Get clipped areas
Rect startClippedLayout = (startStyle != null) ? startItem.getClippedLayout() : new Rect();
Rect startClippedLayout = (startStyle != null) ? startItem.getClippedLayout() : EMPTY_RECT;
Rect startClipInsets = getClipInsets(startLayout, startClippedLayout);
Rect endClippedLayout = (endStyle != null) ? endItem.getClippedLayout() : new Rect();
Rect endClippedLayout = (endStyle != null) ? endItem.getClippedLayout() : EMPTY_RECT;
Rect endClipInsets = getClipInsets(endLayout, endClippedLayout);

// Get interpolated layout
Expand Down Expand Up @@ -260,8 +263,9 @@ private void updateLayout() {
mStartView.updateViewAndDrawable(
interpolatedLayout,
parentLayout,
startContent,
startLayout,
startFrame,
startContent,
interpolatedStyle,
startAlpha,
mResize,
Expand All @@ -275,8 +279,9 @@ private void updateLayout() {
mEndView.updateViewAndDrawable(
interpolatedLayout,
parentLayout,
endContent,
endLayout,
endFrame,
endContent,
interpolatedStyle,
endAlpha,
mResize,
Expand Down Expand Up @@ -464,4 +469,4 @@ private void fireMeasureEvent(String name, RNSharedElementTransitionItem item, R
"onMeasureNode",
eventData);
}
}
}
Expand Up @@ -27,8 +27,9 @@ public boolean hasOverlappingRendering() {
void updateViewAndDrawable(
Rect layout,
Rect parentLayout,
RNSharedElementContent content,
Rect originalLayout,
Rect originalFrame,
RNSharedElementContent content,
RNSharedElementStyle style,
float alpha,
RNSharedElementResize resize,
Expand All @@ -51,8 +52,8 @@ void updateViewAndDrawable(
int width = layout.width();
int height = layout.height();
if (useGPUScaling) {
int originalWidth = originalLayout.width();
int originalHeight = originalLayout.height();
int originalWidth = originalFrame.width();
int originalHeight = originalFrame.height();

// Update view
layout(0, 0, originalWidth, originalHeight);
Expand All @@ -71,8 +72,8 @@ void updateViewAndDrawable(
break;
case CLIP:
case NONE:
scaleX = 1.0f;
scaleY = 1.0f;
scaleX = (float) originalWidth / (float) originalLayout.width();
scaleY = (float) originalHeight / (float) originalLayout.height();
break;
}

Expand Down

0 comments on commit ee27709

Please sign in to comment.