diff --git a/doric-android/doric/src/main/java/pub/doric/shader/slider/SliderNode.java b/doric-android/doric/src/main/java/pub/doric/shader/slider/SliderNode.java index e467fa2b..70919521 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/slider/SliderNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/slider/SliderNode.java @@ -45,6 +45,7 @@ public class SliderNode extends SuperNode { private String onPageSlidedFuncId; private int lastPosition = 0; private int itemCount = 0; + private boolean scrollable = true; public SliderNode(DoricContext doricContext) { super(doricContext); @@ -55,7 +56,15 @@ public class SliderNode extends SuperNode { protected RecyclerView build() { RecyclerView recyclerView = new RecyclerView(getContext()); - final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); + final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()) { + @Override + public boolean canScrollHorizontally() { + if (!scrollable) { + return false; + } + return super.canScrollHorizontally(); + } + }; layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); recyclerView.setLayoutManager(layoutManager); final PagerSnapHelper snapHelper = new PagerSnapHelper(); @@ -146,6 +155,12 @@ public class SliderNode extends SuperNode { @Override protected void blend(RecyclerView view, String name, JSValue prop) { switch (name) { + case "scrollable": + if (!prop.isBoolean()) { + return; + } + this.scrollable = prop.asBoolean().value(); + break; case "itemCount": this.itemCount = prop.asNumber().toInt(); break; diff --git a/doric-iOS/Pod/Classes/Shader/DoricSliderNode.m b/doric-iOS/Pod/Classes/Shader/DoricSliderNode.m index b906b9ae..f1728150 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricSliderNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricSliderNode.m @@ -75,7 +75,9 @@ - (UICollectionView *)build { } - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValue:(id)prop { - if ([@"itemCount" isEqualToString:name]) { + if ([@"scrollable" isEqualToString:name]) { + self.view.scrollEnabled = [prop boolValue]; + } else if ([@"itemCount" isEqualToString:name]) { self.itemCount = [prop unsignedIntegerValue]; [self.view reloadData]; } else if ([@"renderPage" isEqualToString:name]) { diff --git a/doric-js/src/widget/slider.ts b/doric-js/src/widget/slider.ts index 00ee550c..33a58ad5 100644 --- a/doric-js/src/widget/slider.ts +++ b/doric-js/src/widget/slider.ts @@ -49,6 +49,9 @@ export class Slider extends Superview { @Property loop?: boolean + @Property + scrollable?: boolean + private getItem(itemIdx: number) { let view = this.renderPage(itemIdx) view.superview = this