@momo-kits/slider 0.0.73-beta → 0.72.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/converters.js CHANGED
@@ -2,78 +2,79 @@
2
2
  /* eslint-disable no-else-return */
3
3
  // Find closest index for a given value
4
4
  const closest = (array, n) => {
5
- let minI = 0;
6
- let maxI = array.length - 1;
5
+ let minI = 0;
6
+ let maxI = array.length - 1;
7
7
 
8
- if (array[minI] > n) {
9
- return minI;
10
- } else if (array[maxI] < n) {
11
- return maxI;
12
- } else if (array[minI] <= n && n <= array[maxI]) {
13
- let closestIndex = null;
8
+ if (array[minI] > n) {
9
+ return minI;
10
+ } else if (array[maxI] < n) {
11
+ return maxI;
12
+ } else if (array[minI] <= n && n <= array[maxI]) {
13
+ let closestIndex = null;
14
14
 
15
- while (closestIndex === null) {
16
- const midI = Math.round((minI + maxI) / 2);
17
- const midVal = array[midI];
15
+ while (closestIndex === null) {
16
+ const midI = Math.round((minI + maxI) / 2);
17
+ const midVal = array[midI];
18
18
 
19
- if (midVal === n) {
20
- closestIndex = midI;
21
- } else if (maxI === minI + 1) {
22
- const minValue = array[minI];
23
- const maxValue = array[maxI];
24
- const deltaMin = Math.abs(minValue - n);
25
- const deltaMax = Math.abs(maxValue - n);
19
+ if (midVal === n) {
20
+ closestIndex = midI;
21
+ } else if (maxI === minI + 1) {
22
+ const minValue = array[minI];
23
+ const maxValue = array[maxI];
24
+ const deltaMin = Math.abs(minValue - n);
25
+ const deltaMax = Math.abs(maxValue - n);
26
26
 
27
- closestIndex = deltaMax <= deltaMin ? maxI : minI;
28
- } else if (midVal < n) {
29
- minI = midI;
30
- } else if (midVal > n) {
31
- maxI = midI;
32
- } else {
33
- closestIndex = -1;
34
- }
35
- }
36
-
37
- return closestIndex;
27
+ closestIndex = deltaMax <= deltaMin ? maxI : minI;
28
+ } else if (midVal < n) {
29
+ minI = midI;
30
+ } else if (midVal > n) {
31
+ maxI = midI;
32
+ } else {
33
+ closestIndex = -1;
34
+ }
38
35
  }
39
36
 
40
- return -1;
37
+ return closestIndex;
38
+ }
39
+
40
+ return -1;
41
41
  };
42
42
 
43
43
  export function valueToPosition(value, valuesArray, sliderLength) {
44
- const index = closest(valuesArray, value);
44
+ const index = closest(valuesArray, value);
45
45
 
46
- const arrLength = valuesArray.length - 1;
47
- const validIndex = index === -1 ? arrLength : index;
46
+ const arrLength = valuesArray.length - 1;
47
+ const validIndex = index === -1 ? arrLength : index;
48
48
 
49
- return (sliderLength * validIndex) / arrLength;
49
+ return (sliderLength * validIndex) / arrLength;
50
50
  }
51
51
 
52
52
  export function positionToValue(position, valuesArray, sliderLength) {
53
- let arrLength;
54
- let index;
53
+ let arrLength;
54
+ let index;
55
55
 
56
- if (position < 0 || sliderLength < position) {
57
- return null;
58
- } else {
59
- arrLength = valuesArray.length - 1;
60
- index = (arrLength * position) / sliderLength;
61
- return valuesArray[Math.round(index)];
62
- }
56
+ if (position < 0 || sliderLength < position) {
57
+ return null;
58
+ } else {
59
+ arrLength = valuesArray.length - 1;
60
+ index = (arrLength * position) / sliderLength;
61
+ return valuesArray[Math.round(index)];
62
+ }
63
63
  }
64
64
 
65
65
  export function createArray(start, end, step) {
66
- let i;
67
- let length;
68
- const direction = start - end > 0 ? -1 : 1;
69
- const result = [];
70
- if (!step) {
71
- return result;
72
- } else {
73
- length = Math.abs((start - end) / step);
74
- for (i = 0; i <= length; i++) {
75
- result.push(start + i * Math.abs(step) * direction);
76
- }
77
- return result;
66
+ let i;
67
+ let length;
68
+ const direction = start - end > 0 ? -1 : 1;
69
+ const result = [];
70
+ if (!step) {
71
+ return result;
72
+ } else {
73
+ length = Math.abs((start - end) / step);
74
+ for (i = 0; i <= length; i++) {
75
+ result.push(start + i * Math.abs(step) * direction);
78
76
  }
77
+ if (result[length - 1] != end) result.push(end);
78
+ return result;
79
+ }
79
80
  }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
- "name": "@momo-kits/slider",
3
- "version": "0.0.73-beta",
4
- "private": false,
5
- "main": "index.js",
6
- "dependencies": {},
7
- "peerDependencies": {
8
- "react-native": ">=0.55",
9
- "prop-types": "^15.7.2",
10
- "react": "16.9.0",
11
- "lodash": "^4.17.15",
12
- "@momo-kits/core": ">=0.0.5-beta"
13
- },
14
- "devDependencies": {},
15
- "license": "MoMo"
2
+ "name": "@momo-kits/slider",
3
+ "version": "0.72.1",
4
+ "private": false,
5
+ "main": "index.js",
6
+ "dependencies": {},
7
+ "peerDependencies": {
8
+ "@momo-kits/core-v2": ">=0.0.5-beta",
9
+ "lodash": "^4.17.15",
10
+ "prop-types": "^15.7.2",
11
+ "react": "16.9.0",
12
+ "react-native": ">=0.55"
13
+ },
14
+ "devDependencies": {},
15
+ "license": "MoMo"
16
16
  }
package/publish.sh CHANGED
@@ -21,9 +21,9 @@ rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type
21
21
  #npm login
22
22
  #publish dist to npm
23
23
  cd dist
24
- npm publish --access=public
24
+ npm publish --tag beta --access=public
25
25
  cd ..
26
26
  rm -rf dist
27
27
 
28
28
 
29
- curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/stepper new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/stepper"}'
29
+ #curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/stepper new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/stepper"}'