Browse Source

1.修改SeekBar组件,最下增加使用方法注释

zhangmengjie 5 years ago
parent
commit
a6feb1572c
1 changed files with 37 additions and 0 deletions
  1. 37 0
      pages/components/SeekBar.js

+ 37 - 0
pages/components/SeekBar.js

@@ -195,3 +195,40 @@ export default class SeekBar extends BasePage {
 }
 
 const styles = StyleSheet.create({});
+
+/**
+         <SeekBar
+            ref={view => (this.seekbar = view)}
+            max={100}
+            //必须带此方法,作为滑动之后抬起的回调
+            touchUpCallBack={this.touch_up_callback.bind(this)}
+            progress={this.state.curprogress}
+          />
+
+
+ touch_up_callback(progress) {
+    //抬起之后,获取算出来的progress
+    this.setState({
+      curprogress: progress
+    });
+  }
+
+  setProgressIcon() {
+    //轮询设置值,超过max则停止
+    setTimeout(() => {
+      if (!this.seekbar.getTouchDown()) {
+        this.setState({
+          curprogress: this.state.curprogress + 1
+        });
+      }
+
+      if (this.state.curprogress >= 100) {
+        alert("100了");
+      } else {
+        this.setProgressIcon();
+      }
+      this.seekbar.setProgress(this.state.curprogress);
+    }, 1000);
+  }
+
+ */