@ray-js/lamp-saturation-slider 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,9 +2,7 @@ English | [简体中文](./README-zh_CN.md)
2
2
 
3
3
  # @ray-js/lamp-saturation-slider
4
4
 
5
- [![latest](https://img.shields.io/npm/v/@ray/lamp-saturation-slider/latest.svg)](https://www.npmjs.com/package/@ray/lamp-saturation-slider) [![download](https://img.shields.io/npm/dt/@ray/lamp-saturation-slider.svg)](https://www.npmjs.com/package/@ray/lamp-saturation-slider)
6
-
7
- > 照明彩光 Slider
5
+ > Lamp saturation Slider
8
6
 
9
7
  ## Installation
10
8
 
@@ -25,12 +23,6 @@ export interface IProps {
25
23
  * @default false
26
24
  */
27
25
  disable?: boolean;
28
- /**
29
- * @description.zh slider方向
30
- * @description.en slider direction
31
- * @default horizontal
32
- */
33
- direction?: 'horizontal' | 'vertical';
34
26
  /**
35
27
  * @description.zh 滑动槽样式
36
28
  * @description.en
@@ -43,6 +35,12 @@ export interface IProps {
43
35
  * @default 0
44
36
  */
45
37
  value: number;
38
+ /**
39
+ * @description.zh slider 展示的颜色值 对应hsv的hue
40
+ * @description.en slider value
41
+ * @default 0
42
+ */
43
+ hue: number; // 0 - 359
46
44
  /**
47
45
  * @description.zh slider 手指点击时触发
48
46
  * @description.en slider Value changes
@@ -72,27 +70,24 @@ export const defaultProps: IProps = {
72
70
  ```
73
71
 
74
72
  ```tsx
75
- import LampSaturationSlider from '@ray-js/components-ty-lamp';
73
+ import { LampSaturationSlider } from '@ray-js/components-ty-lamp';
76
74
 
77
75
  export default () => {
78
- const [hue, setHue] = useState(100);
76
+ const [saturation, setSaturation] = useState(100);
79
77
 
80
78
  useEffect(() => {
81
79
  // 模拟dp上报
82
80
  setTimeout(() => {
83
- setHue(321);
81
+ setSaturation(321);
84
82
  }, 3000);
85
83
  }, []);
86
84
 
87
85
  return (
88
86
  <LampSaturationSlider
89
- value={hue}
90
- disable
91
- onTouchMove={val => {
92
- setHue(val);
93
- }}
87
+ hue={100}
88
+ value={saturation}
94
89
  onTouchEnd={val => {
95
- setHue(val);
90
+ setSaturation(val);
96
91
  }}
97
92
  />
98
93
  );
@@ -738,7 +738,7 @@ const onChange = (ownerInstance, instanceId, position) => {
738
738
  });
739
739
 
740
740
  // publish
741
- ownerInstance.triggerEvent('onChange', {
741
+ ownerInstance.triggerEvent('move', {
742
742
  instanceId,
743
743
  start: nextStart,
744
744
  end: nextEnd,
@@ -768,7 +768,7 @@ const onEnd = (event, ownerInstance, instanceId) => {
768
768
  });
769
769
 
770
770
  // publish
771
- ownerInstance.triggerEvent('onEnd', {
771
+ ownerInstance.triggerEvent('end', {
772
772
  instanceId,
773
773
  start: nextStart,
774
774
  end: nextEnd,
@@ -794,7 +794,7 @@ const onStart = (event, ownerInstance, instanceId) => {
794
794
  });
795
795
 
796
796
  // publish
797
- ownerInstance.triggerEvent('onStart', {
797
+ ownerInstance.triggerEvent('start', {
798
798
  instanceId,
799
799
  start: nextStart,
800
800
  end: nextEnd,
package/lib/index.js CHANGED
@@ -23,6 +23,8 @@ function SaturationSlider(props) {
23
23
  onTouchStart = props.onTouchStart,
24
24
  onTouchMove = props.onTouchMove,
25
25
  onTouchEnd = props.onTouchEnd;
26
+ var startRefValue = useRef(-1);
27
+ var endRefValue = useRef(-1);
26
28
  var instanceId = useRef("Color_".concat(String(+new Date()).slice(-4), "_").concat(String(Math.random()).slice(-2)));
27
29
  var _useState = useState(-1),
28
30
  _useState2 = _slicedToArray(_useState, 2),
@@ -52,19 +54,17 @@ function SaturationSlider(props) {
52
54
  disable: disable,
53
55
  end: controllerSaturation,
54
56
  step: 1,
55
- enableTouch: true,
56
57
  maxRangeOffset: 16,
57
58
  bindstart: function handleTouchStart(_ref) {
58
59
  var detail = _ref.detail;
59
60
  if (!onTouchStart || disable) {
60
61
  return;
61
62
  }
62
- lastSaturation.current = detail.end;
63
- if (detail.end === lastSaturation.current) {
63
+ if (detail.end === startRefValue.current) {
64
64
  return;
65
65
  }
66
66
  onTouchStart && onTouchStart(detail.end);
67
- lastSaturation.current = detail.end;
67
+ startRefValue.current = detail.end;
68
68
  },
69
69
  bindmove: function handTouchMove(_ref2) {
70
70
  var detail = _ref2.detail;
@@ -99,11 +99,11 @@ function SaturationSlider(props) {
99
99
  if (!onTouchEnd || disable) {
100
100
  return;
101
101
  }
102
- if (detail.end === preSaturation.current) {
102
+ if (detail.end === endRefValue.current) {
103
103
  return;
104
104
  }
105
105
  onTouchEnd && onTouchEnd(detail.end);
106
- preSaturation.current = detail.end;
106
+ endRefValue.current = detail.end;
107
107
  },
108
108
  trackStyle: _objectSpread(_objectSpread({
109
109
  width: "".concat(646, "rpx"),
package/lib/props.d.ts CHANGED
@@ -6,12 +6,6 @@ export interface IProps {
6
6
  * @default false
7
7
  */
8
8
  disable?: boolean;
9
- /**
10
- * @description.zh slider方向
11
- * @description.en slider direction
12
- * @default horizontal
13
- */
14
- direction?: "horizontal" | "vertical";
15
9
  /**
16
10
  * @description.zh 滑动槽样式
17
11
  * @description.en Sliding groove style
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lamp-saturation-slider",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "照明色温Slider",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -28,7 +28,8 @@
28
28
  "start:wechat": "ray start ./example -t wechat --verbose",
29
29
  "start:web": "ray start ./example -t web",
30
30
  "prepublishOnly": "yarn build",
31
- "release-it": "standard-version"
31
+ "release-it": "standard-version",
32
+ "copy": "sh copy.sh"
32
33
  },
33
34
  "peerDependencies": {},
34
35
  "devDependencies": {
@@ -50,7 +51,7 @@
50
51
  "husky": {
51
52
  "hooks": {
52
53
  "commit-msg": "commitlint -E HUSKY_GIT_PARAMS --config commitlint.config.js",
53
- "pre-commit": "lint-staged"
54
+ "pre-commit": "lint-staged && npm run copy"
54
55
  }
55
56
  },
56
57
  "lint-staged": {