feat:scroller add scrollBy

This commit is contained in:
pengfei.zhou
2020-03-03 13:54:36 +08:00
committed by osborn
parent 6d7562877e
commit 0641f5e223
12 changed files with 73 additions and 8 deletions

View File

@@ -136,4 +136,20 @@ public class ScrollerNode extends SuperNode<HVScrollView> implements IDoricScrol
DoricUtils.dp2px(offset.getProperty("y").asNumber().toFloat()));
}
}
@DoricMethod
public void scrollBy(JSObject params) {
boolean animated = false;
if (params.getProperty("animated").isBoolean()) {
animated = params.getProperty("animated").asBoolean().value();
}
JSObject offset = params.getProperty("offset").asObject();
if (animated) {
this.mView.smoothScrollBy(DoricUtils.dp2px(offset.getProperty("x").asNumber().toFloat()),
DoricUtils.dp2px(offset.getProperty("y").asNumber().toFloat()));
} else {
this.mView.scrollBy(DoricUtils.dp2px(offset.getProperty("x").asNumber().toFloat()),
DoricUtils.dp2px(offset.getProperty("y").asNumber().toFloat()));
}
}
}