Skip to content

Commit

Permalink
Stuck animator fix (#210)
Browse files Browse the repository at this point in the history
* 1.4.0-beta.7

* Itemanimtor fix for stuck cases

* Condition fix

* Removing member declaration
  • Loading branch information
naqvitalha authored and muskeinsingh committed Jul 12, 2018
1 parent 0a7b2d6 commit 1fbe745
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Animated, Easing, View, Platform } from "react-native";
import { Animated, Easing, View } from "react-native";
import { BaseItemAnimator } from "../../../../core/ItemAnimator";

interface UnmountAwareView extends View {
_isUnmountedForRecyclerListView?: boolean;
_lastAnimVal?: Animated.ValueXY | null;
}

const IS_WEB = Platform.OS === "web";

/**
* Default implementation of RLV layout animations for react native. These ones are purely JS driven. Also, check out DefaultNativeItemAnimator
* for an implementation on top of LayoutAnimation. We didn't use it by default due the fact that LayoutAnimation is quite
Expand Down Expand Up @@ -36,7 +34,7 @@ export class DefaultJSItemAnimator implements BaseItemAnimator {
const viewRef = itemRef as UnmountAwareView;
const animXY = new Animated.ValueXY({ x: fromX, y: fromY });
animXY.addListener((value) => {
if (viewRef._isUnmountedForRecyclerListView) {
if (viewRef._isUnmountedForRecyclerListView || (this.shouldAnimateOnce && this._hasAnimatedOnce)) {
animXY.stopAnimation();
return;
}
Expand Down Expand Up @@ -75,7 +73,6 @@ export class DefaultJSItemAnimator implements BaseItemAnimator {
}

private _getNativePropObject(x: number, y: number): object {
const point = { left: x, top: y };
return !IS_WEB ? point : { style: point };
return { style: { left: x, top: y } };
}
}

0 comments on commit 1fbe745

Please sign in to comment.