Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

[WEEX-138][android]WXParallax wat not reseted to right position, when scrollToElement with animated:false option #906

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ private boolean shouldReport(int offsetX, int offsetY) {



private int calcContentOffset(RecyclerView recyclerView) {
public int calcContentOffset(RecyclerView recyclerView) {
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
int firstVisibleItemPosition = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ private int calcContentSize() {
return totalHeight;
}

private int calcContentOffset(RecyclerView recyclerView) {
public int calcContentOffset(RecyclerView recyclerView) {
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
int firstVisibleItemPosition = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
Expand Down