@ray-js/lamp-saturation-slider 1.1.8-beta-1 → 1.1.8-beta-3

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.
Files changed (2) hide show
  1. package/lib/index.js +5 -48
  2. package/package.json +6 -1
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
- import React, { useRef, useState, useEffect, useMemo } from 'react';
3
+ import React, { useRef, useMemo } from 'react';
4
4
  import { View } from '@ray-js/components';
5
5
  import Slider from '@ray-js/components-ty-slider/lib/SjsSlider';
6
6
  import { toStyle } from '@ray-js/components-ty-slider';
@@ -8,10 +8,6 @@ import { hsvToRgb } from './utils';
8
8
  import { defaultProps } from './props';
9
9
  function LampSaturationSlider(props) {
10
10
  var _trackStyle$width, _trackStyle$height;
11
- const preSaturation = useRef(-1);
12
- const lastSaturation = useRef(null);
13
- const timer = useRef(null);
14
- const timer1 = useRef(null);
15
11
  const {
16
12
  value: saturation,
17
13
  hue,
@@ -26,15 +22,7 @@ function LampSaturationSlider(props) {
26
22
  useCustomThumbStyle,
27
23
  useCustomTrackStyle
28
24
  } = props;
29
- const startRefValue = useRef(-1);
30
- const endRefValue = useRef(-1);
31
25
  const instanceId = useRef(`Color_${String(+new Date()).slice(-4)}_${String(Math.random()).slice(-10)}`);
32
- const [controllerSaturation, setControllerSaturation] = useState(-1);
33
- useEffect(() => {
34
- if (preSaturation.current !== saturation) {
35
- setControllerSaturation(saturation);
36
- }
37
- }, [saturation]);
38
26
  const {
39
27
  r,
40
28
  g,
@@ -53,7 +41,7 @@ function LampSaturationSlider(props) {
53
41
  min: 0,
54
42
  max: max,
55
43
  disable: disable,
56
- end: controllerSaturation,
44
+ end: saturation,
57
45
  enableTouch: enableTouch,
58
46
  step: 1,
59
47
  bindstart: _ref => {
@@ -63,11 +51,8 @@ function LampSaturationSlider(props) {
63
51
  if (!onTouchStart || disable) {
64
52
  return;
65
53
  }
66
- if (detail.end === startRefValue.current) {
67
- return;
68
- }
69
- onTouchStart && onTouchStart(detail.end);
70
- startRefValue.current = detail.end;
54
+ const value = Math.max(detail.end, 1);
55
+ onTouchStart && onTouchStart(value);
71
56
  },
72
57
  bindmove: _ref2 => {
73
58
  let {
@@ -76,31 +61,7 @@ function LampSaturationSlider(props) {
76
61
  if (!onTouchMove || disable) {
77
62
  return;
78
63
  }
79
- lastSaturation.current = detail.end;
80
- if (detail.end === preSaturation.current) {
81
- return;
82
- }
83
- if (timer.current) {
84
- return;
85
- }
86
-
87
- // 移动更新的频率
88
-
89
- // 移动结束后多久进行更新
90
-
91
- timer.current = setTimeout(() => {
92
- onTouchMove && onTouchMove(detail.end);
93
- preSaturation.current = detail.end;
94
- clearTimeout(timer.current);
95
- timer.current = null;
96
- clearTimeout(timer1.current);
97
- timer1.current = null;
98
- timer1.current = setTimeout(() => {
99
- if (lastSaturation.current !== preSaturation.current) {
100
- onTouchMove && onTouchMove(lastSaturation.current);
101
- }
102
- }, 200);
103
- }, 50);
64
+ onTouchMove && onTouchMove(detail.end);
104
65
  },
105
66
  bindend: _ref3 => {
106
67
  let {
@@ -109,11 +70,7 @@ function LampSaturationSlider(props) {
109
70
  if (!onTouchEnd || disable) {
110
71
  return;
111
72
  }
112
- if (detail.end === endRefValue.current) {
113
- return;
114
- }
115
73
  onTouchEnd && onTouchEnd(detail.end);
116
- endRefValue.current = detail.end;
117
74
  },
118
75
  trackStyle: toStyle(_objectSpread(_objectSpread({
119
76
  width: `${646}rpx`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lamp-saturation-slider",
3
- "version": "1.1.8-beta-1",
3
+ "version": "1.1.8-beta-3",
4
4
  "description": "照明色温Slider",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -43,6 +43,11 @@
43
43
  "lint-staged": "^10.2.11",
44
44
  "standard-version": "9.3.2"
45
45
  },
46
+ "resolutions": {
47
+ "follow-redirects": "1.15.6",
48
+ "shell-quote": "1.7.3",
49
+ "ip": "2.0.1"
50
+ },
46
51
  "husky": {
47
52
  "hooks": {
48
53
  "commit-msg": "commitlint -E HUSKY_GIT_PARAMS --config commitlint.config.js",