Skip to content

Commit

Permalink
[WEEX-138][android]WXParallax wat not reseted to right position, when…
Browse files Browse the repository at this point in the history
… scrollToElement with animated:false option. dx dy is zero when recycleview use scrollToPosition close apache#906
  • Loading branch information
jianbai.gbj authored and acton393 committed Nov 24, 2017
1 parent b37c51f commit 2e7535f
Showing 1 changed file with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.animation.Animation;
Expand All @@ -41,6 +43,9 @@
import com.taobao.weex.ui.component.WXComponent;
import com.taobao.weex.ui.component.WXDiv;
import com.taobao.weex.ui.component.WXVContainer;
import com.taobao.weex.ui.component.list.BasicListComponent;
import com.taobao.weex.ui.component.list.template.WXRecyclerTemplateList;
import com.taobao.weex.ui.view.listview.WXRecyclerView;
import com.taobao.weex.utils.WXLogUtils;
import com.taobao.weex.utils.WXResourceUtils;

Expand All @@ -62,6 +67,7 @@ public class WXParallax extends WXDiv implements OnWXScrollListener, ICheckBindi
ArrayList<TransformCreator> mTransformPropArrayList = new ArrayList<>();
BackgroundColorCreator mBackgroundColor;
String mBindingRef = "";
WXComponent mBindingComponent;

private int mBackGroundColor = 0;
private float mOffsetY = 0;
Expand Down Expand Up @@ -150,8 +156,22 @@ public boolean isNeedScroller(String ref, Object option) {

@Override
public void onScrolled(View view, int dx, int dy) {

mOffsetY = mOffsetY + dy;
if(ViewCompat.isInLayout(view)){
if(mBindingComponent == null && mBindingRef != null){
mBindingComponent = findComponent(mBindingRef);
}
if(mBindingComponent instanceof BasicListComponent
&& view instanceof RecyclerView){
BasicListComponent listComponent = (BasicListComponent) mBindingComponent;
mOffsetY = Math.abs(listComponent.calcContentOffset((RecyclerView) view));
}else if(mBindingComponent instanceof WXRecyclerTemplateList
&& view instanceof RecyclerView){
WXRecyclerTemplateList listComponent = (WXRecyclerTemplateList) mBindingComponent;
mOffsetY = Math.abs(listComponent.calcContentOffset((RecyclerView) view));
}
}else{
mOffsetY = mOffsetY + dy;
}

AnimationSet animationSet = new AnimationSet(true);
boolean hasAnimation = false;
Expand Down

0 comments on commit 2e7535f

Please sign in to comment.