Skip to content

Commit

Permalink
* [android] fix list scroll to
Browse files Browse the repository at this point in the history
  • Loading branch information
sospartan committed Jul 6, 2016
1 parent d814bec commit 6355fc6
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
import com.taobao.weex.WXEnvironment;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.WXSDKManager;
import com.taobao.weex.common.Component;
import com.taobao.weex.common.OnWXScrollListener;
import com.taobao.weex.common.WXRuntimeException;
import com.taobao.weex.dom.WXDomObject;
Expand Down Expand Up @@ -433,7 +434,6 @@ public void unbindDisappearEvent(WXComponent component) {

@Override
public void scrollTo(WXComponent component,final int offset) {
//TODO: offset is unused.
if(bounceRecyclerView == null){
return;
}
Expand All @@ -451,15 +451,17 @@ public void scrollTo(WXComponent component,final int offset) {
int pos = mChildren.indexOf(cell);
final WXRecyclerView view = bounceRecyclerView.getInnerView();
view.scrollToPosition(pos);

final WXComponent cellComp = cell;
//scroll cell to top
view.postDelayed(new Runnable() {
@Override
public void run() {
if(mOrientation == VERTICAL){
view.smoothScrollBy(0,view.getHeight()+offset);
int scrollY = cellComp.getView().getTop()+offset;
view.smoothScrollBy(0,scrollY );
}else{
view.smoothScrollBy(view.getWidth()+offset,0);
int scrollX = cellComp.getView().getLeft()+offset;
view.smoothScrollBy(scrollX,0);
}
}
},50);
Expand Down

0 comments on commit 6355fc6

Please sign in to comment.