pixuireactcomponents 1.4.13 → 1.5.0
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/index.d.ts +0 -1
- package/index.js +2 -1
- package/package.json +1 -1
- package/src/components/react/app/button/Button.d.ts +1 -0
- package/src/components/react/app/button/Button.js +57 -1
- package/src/components/react/app/carousel/Carousel.d.ts +3 -3
- package/src/components/react/app/carouselMulti/CarouselMulti.d.ts +5 -7
- package/src/components/react/app/carouselMulti/CarouselMulti.js +69 -44
- package/src/components/react/app/checkBox/CheckBox.d.ts +17 -8
- package/src/components/react/app/checkBox/CheckBox.js +95 -12
- package/src/components/react/app/checkBox/CheckBoxGroup.d.ts +19 -0
- package/src/components/react/app/checkBox/CheckBoxGroup.js +56 -0
- package/src/components/react/app/dropDown/DropDown.d.ts +18 -25
- package/src/components/react/app/dropDown/DropDown.js +85 -32
- package/src/components/react/app/scratchCard/ScratchCard.d.ts +4 -3
- package/src/components/react/app/scratchCard/ScratchCard.js +10 -17
- package/src/components/react/app/scrollBar/ScrollBar.d.ts +17 -2
- package/src/components/react/app/scrollBar/ScrollBar.js +71 -39
- package/src/components/react/app/slider/Slider.d.ts +22 -93
- package/src/components/react/app/slider/Slider.js +149 -358
- package/src/components/react/app/videoPlayer/VideoPlayer.d.ts +13 -11
- package/src/components/react/app/videoPlayer/VideoPlayer.js +118 -62
- package/src/components/react/app/wheelPicker/WheelPicker.d.ts +17 -9
- package/src/components/react/app/wheelPicker/WheelPicker.js +86 -28
|
@@ -1,40 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { useEffect, useRef, useState } from 'preact/hooks';
|
|
13
|
+
import { h, isValidElement } from 'preact';
|
|
14
|
+
import { cloneElement } from 'preact';
|
|
15
|
+
var defaultDropDownStyle = {
|
|
16
|
+
margin: 0,
|
|
17
|
+
padding: '4px 0',
|
|
18
|
+
backgroundColor: '#fff',
|
|
19
|
+
borderRadius: '5px',
|
|
20
|
+
border: '2px solid rgba(5, 5, 5, 0.06)',
|
|
21
|
+
boxShadow: '0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 9px 28px 8px rgba(0, 0, 0, 0.05)'
|
|
22
|
+
};
|
|
15
23
|
export var DropDown = function (props) {
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
var rootId = props.rootId, rootClassName = props.rootClassName, options = props.options, element = props.element, children = props.children, onChange = props.onChange, onSpread = props.onSpread;
|
|
25
|
+
var getElementStyleOrClass = function () {
|
|
26
|
+
if (element == undefined) {
|
|
27
|
+
return {
|
|
28
|
+
dropdownBg: defaultDropDownStyle
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return element;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var elementStyleOrClass = getElementStyleOrClass();
|
|
36
|
+
var _a = useState(false), spread = _a[0], setSpread = _a[1];
|
|
37
|
+
var dropdownRef = useRef(null);
|
|
38
|
+
// if(compRef) {
|
|
39
|
+
// compRef.current = {
|
|
40
|
+
// setSpread: setSpread
|
|
41
|
+
// }
|
|
42
|
+
// }
|
|
25
43
|
useEffect(function () {
|
|
26
44
|
onSpread && onSpread(spread);
|
|
27
45
|
}, [spread]);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
useEffect(function () {
|
|
47
|
+
if (spread) {
|
|
48
|
+
console.log('开始监听mousedown', spread);
|
|
49
|
+
document.body.addEventListener('mousedown', handleClickOutside);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
document.body.removeEventListener('mousedown', handleClickOutside);
|
|
53
|
+
}
|
|
54
|
+
return function () {
|
|
55
|
+
document.body.removeEventListener('mousedown', handleClickOutside);
|
|
56
|
+
};
|
|
57
|
+
}, [spread]);
|
|
58
|
+
var handleClickOutside = function (event) {
|
|
59
|
+
console.log('handleClickOutside, ', event.target, typeof dropdownRef.current.contains === 'function');
|
|
60
|
+
// if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
61
|
+
// setSpread(false);
|
|
62
|
+
// }
|
|
63
|
+
};
|
|
64
|
+
var handleOverlayClick = function (event) {
|
|
65
|
+
console.log("handleOverLayClick");
|
|
66
|
+
event.stopPropagation();
|
|
67
|
+
setSpread(!spread);
|
|
68
|
+
};
|
|
69
|
+
var overlayRender = isValidElement(children) ? cloneElement(children, { onClick: handleOverlayClick }) : children;
|
|
70
|
+
var optionRender = function (option) {
|
|
71
|
+
if (!isValidElement(option.label)) {
|
|
72
|
+
return option.label;
|
|
73
|
+
}
|
|
74
|
+
var element = option.label;
|
|
75
|
+
var originalClick = element.props.onClick;
|
|
76
|
+
var newOnClick = function (event) {
|
|
77
|
+
console.log('new onClick');
|
|
78
|
+
if (originalClick) {
|
|
79
|
+
originalClick(event);
|
|
80
|
+
}
|
|
81
|
+
onChange && onChange(option.value);
|
|
82
|
+
setSpread(false);
|
|
83
|
+
};
|
|
84
|
+
return cloneElement(option.label, { onClick: newOnClick });
|
|
85
|
+
};
|
|
86
|
+
return (h("div", { style: { flexDirection: 'column', flexShrink: 0 }, className: rootClassName, id: rootId, ref: dropdownRef },
|
|
87
|
+
overlayRender,
|
|
32
88
|
spread && (
|
|
33
89
|
//在下方展开
|
|
34
|
-
h("div", { className:
|
|
35
|
-
return (h("div",
|
|
36
|
-
onClick && onClick(i);
|
|
37
|
-
setSpread(false);
|
|
38
|
-
}, className: "".concat(spreadFrameClassName, " ").concat(itemClassName), style: { flexShrink: 0 } }, v));
|
|
90
|
+
h("div", { className: typeof elementStyleOrClass.dropdownBg === 'string' ? elementStyleOrClass.dropdownBg : '', style: __assign({ flexDirection: 'column', overflow: 'scroll' }, (typeof elementStyleOrClass.dropdownBg === 'object' ? elementStyleOrClass.dropdownBg : undefined)) }, options.map(function (option, index) {
|
|
91
|
+
return (h("div", null, optionRender(option)));
|
|
39
92
|
})))));
|
|
40
93
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CSSProperties, h } from 'preact';
|
|
2
2
|
export interface ScratchCardProps {
|
|
3
|
-
|
|
3
|
+
rootId?: string;
|
|
4
|
+
rootClassName?: string;
|
|
4
5
|
ratio?: number;
|
|
5
6
|
moveRadius?: number;
|
|
6
7
|
startCallback?: Function;
|
|
@@ -9,7 +10,7 @@ export interface ScratchCardProps {
|
|
|
9
10
|
coverColor?: string;
|
|
10
11
|
coverWidth: number;
|
|
11
12
|
coverHeight: number;
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
coverElement?: string | CSSProperties;
|
|
14
|
+
resultElement?: string | CSSProperties;
|
|
14
15
|
}
|
|
15
16
|
export declare const ScratchCard: (props: ScratchCardProps, ref: any) => h.JSX.Element;
|
|
@@ -52,17 +52,10 @@ import { useEffect, useRef, useState } from 'preact/hooks';
|
|
|
52
52
|
// // initDone: boolean;
|
|
53
53
|
// clearCard: () => void;
|
|
54
54
|
// };
|
|
55
|
-
var defaultStyle = {
|
|
56
|
-
width: '100%',
|
|
57
|
-
height: '100%',
|
|
58
|
-
display: 'flex',
|
|
59
|
-
justifyContent: 'center',
|
|
60
|
-
alignItems: 'center'
|
|
61
|
-
};
|
|
62
55
|
export var ScratchCard = function (props, ref) {
|
|
63
|
-
var
|
|
56
|
+
var rootId = props.rootId, rootClassName = props.rootClassName, _a = props.ratio, ratio = _a === void 0 ? 1 : _a, startCallback = props.startCallback, clearCallback = props.clearCallback, coverImage = props.coverImage, coverColor = props.coverColor, coverWidth = props.coverWidth, coverHeight = props.coverHeight, coverElement = props.coverElement, resultElement = props.resultElement, _b = props.moveRadius, moveRadius = _b === void 0 ? 10 : _b;
|
|
64
57
|
var canvasRef = useRef(null);
|
|
65
|
-
var
|
|
58
|
+
var _c = useState(false), isResultLoad = _c[0], setIsResultLoad = _c[1];
|
|
66
59
|
// 记录鼠标位置,用作平滑效果
|
|
67
60
|
var lastPos = { x: 0, y: 0 };
|
|
68
61
|
// 记录首次刮卡
|
|
@@ -79,7 +72,7 @@ export var ScratchCard = function (props, ref) {
|
|
|
79
72
|
return __generator(this, function (_a) {
|
|
80
73
|
canvas = canvasRef.current;
|
|
81
74
|
ctx = canvas.getContext('2d');
|
|
82
|
-
console.log("canvas: ", canvas, ctx)
|
|
75
|
+
// console.log("canvas: ", canvas, ctx)
|
|
83
76
|
if (ctx) {
|
|
84
77
|
if (coverColor) {
|
|
85
78
|
ctx.fillStyle = coverColor;
|
|
@@ -101,7 +94,7 @@ export var ScratchCard = function (props, ref) {
|
|
|
101
94
|
var canvas = canvasRef.current;
|
|
102
95
|
var ctx = canvas.getContext('2d');
|
|
103
96
|
if (ctx) {
|
|
104
|
-
var image = document.getElementById("".concat(
|
|
97
|
+
var image = document.getElementById("".concat(rootId, "_img"));
|
|
105
98
|
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
106
99
|
setIsResultLoad(true);
|
|
107
100
|
}
|
|
@@ -152,8 +145,8 @@ export var ScratchCard = function (props, ref) {
|
|
|
152
145
|
if (ctx) {
|
|
153
146
|
for (var i = -moveRadius; i <= moveRadius; i++) {
|
|
154
147
|
for (var j = -moveRadius; j <= moveRadius; j++) {
|
|
155
|
-
var dx = x + i;
|
|
156
|
-
var dy = y + j;
|
|
148
|
+
var dx = Math.round(x) + i;
|
|
149
|
+
var dy = Math.round(y) + j;
|
|
157
150
|
if (dx >= 0 && dx < canvas.width && dy >= 0 && dy < canvas.height && !scratchMap[dy][dx]) {
|
|
158
151
|
scratchMap[dy][dx] = true;
|
|
159
152
|
scratchedPixels++;
|
|
@@ -210,8 +203,8 @@ export var ScratchCard = function (props, ref) {
|
|
|
210
203
|
canvas.removeEventListener('mousemove', handleMouseMove);
|
|
211
204
|
}
|
|
212
205
|
};
|
|
213
|
-
return (h("div", { id:
|
|
214
|
-
isResultLoad && h("div", { style: __assign({},
|
|
215
|
-
coverImage && h("img", { style: { position: 'absolute', width: "1px", height: "1px" }, id: "".concat(
|
|
216
|
-
h("canvas", { ref: canvasRef, width: coverWidth, height: coverHeight, style: __assign(__assign({},
|
|
206
|
+
return (h("div", { id: rootId, className: rootClassName },
|
|
207
|
+
isResultLoad && h("div", { className: typeof resultElement === 'string' ? resultElement : '', style: __assign({}, (typeof resultElement === 'object' ? resultElement : undefined)) }),
|
|
208
|
+
coverImage && h("img", { style: { position: 'absolute', width: "1px", height: "1px" }, id: "".concat(rootId, "_img"), src: coverImage, onLoad: drawImage }),
|
|
209
|
+
h("canvas", { ref: canvasRef, width: coverWidth, height: coverHeight, className: typeof coverElement === 'string' ? coverElement : '', style: __assign(__assign({}, (typeof coverElement === 'object' ? coverElement : undefined)), { position: 'absolute' }) })));
|
|
217
210
|
};
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
import { h } from 'preact';
|
|
2
|
-
export
|
|
1
|
+
import { h, CSSProperties } from 'preact';
|
|
2
|
+
export interface ScrollBarElement {
|
|
3
|
+
block?: string | CSSProperties;
|
|
4
|
+
frame?: string | CSSProperties;
|
|
5
|
+
blockClick?: string | CSSProperties;
|
|
6
|
+
frameClick?: string | CSSProperties;
|
|
7
|
+
blockHover?: string | CSSProperties;
|
|
8
|
+
frameHover?: string | CSSProperties;
|
|
9
|
+
}
|
|
10
|
+
export interface ScrollBarProps {
|
|
11
|
+
rootId?: string;
|
|
12
|
+
rootClassName?: string;
|
|
13
|
+
scrollRef: any;
|
|
14
|
+
cRef?: any;
|
|
15
|
+
element?: ScrollBarElement;
|
|
16
|
+
}
|
|
17
|
+
export declare const ScrollBar: (props: ScrollBarProps) => h.JSX.Element;
|
|
@@ -11,27 +11,79 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { h } from 'preact';
|
|
13
13
|
import { useImperativeHandle, useState, useEffect } from 'preact/hooks';
|
|
14
|
+
var defaultScrollBarStyle = {
|
|
15
|
+
block: { width: '15px', height: '10%', backgroundColor: '#0958D9', borderRadius: '5px', left: '0' },
|
|
16
|
+
frame: { width: '15px', height: '500px', backgroundColor: '#d9d9d9', borderRadius: '5px', left: '10', border: '1px solid grey' },
|
|
17
|
+
blockClick: { width: '15px', height: '10%', backgroundColor: '#4096ff', borderRadius: '5px', left: '0' },
|
|
18
|
+
frameClick: { width: '15px', height: '500px', backgroundColor: '#d9d9d9', borderRadius: '5px', left: '10', border: '1px solid grey' },
|
|
19
|
+
blockHover: { width: '15px', height: '10%', backgroundColor: '#0E6AFF', borderRadius: '5px', left: '0' },
|
|
20
|
+
frameHover: { width: '15px', height: '500px', backgroundColor: '#d9d9d9', borderRadius: '5px', left: '10', border: '1px solid grey' },
|
|
21
|
+
};
|
|
14
22
|
var sWindow; // 滚动窗口
|
|
15
23
|
var sBlock; // 滚动条
|
|
16
24
|
var sFrame; // 滚动条外框
|
|
17
|
-
var isDragingSBlock = false;
|
|
18
25
|
var clientYtoBlockTop = 0; //鼠标Y坐标距离滑块top, 记录这个值是为了记住拖动位置和滑块的偏移,并在后续滑动时保持这个偏移
|
|
19
|
-
export function
|
|
26
|
+
export var ScrollBar = function (props) {
|
|
27
|
+
var rootId = props.rootId, rootClassName = props.rootClassName, scrollRef = props.scrollRef, cRef = props.cRef, element = props.element;
|
|
28
|
+
var getElementStyleOrClass = function () {
|
|
29
|
+
if (element == undefined) {
|
|
30
|
+
return defaultScrollBarStyle;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return element;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var elementStyleOrClass = getElementStyleOrClass();
|
|
37
|
+
var getFrameClass = function () {
|
|
38
|
+
if (isDraging && elementStyleOrClass.frameClick) {
|
|
39
|
+
return typeof elementStyleOrClass.frameClick === 'string' ? elementStyleOrClass.frameClick : '';
|
|
40
|
+
}
|
|
41
|
+
else if (isHover && elementStyleOrClass.frameHover) {
|
|
42
|
+
return typeof elementStyleOrClass.frameHover === 'string' ? elementStyleOrClass.frameHover : '';
|
|
43
|
+
}
|
|
44
|
+
return typeof elementStyleOrClass.frame === 'string' ? elementStyleOrClass.frame : '';
|
|
45
|
+
};
|
|
46
|
+
var getFrameStyle = function () {
|
|
47
|
+
if (isDraging && elementStyleOrClass.frameClick) {
|
|
48
|
+
return typeof elementStyleOrClass.frameClick === 'object' ? elementStyleOrClass.frameClick : undefined;
|
|
49
|
+
}
|
|
50
|
+
else if (isHover && elementStyleOrClass.frameHover) {
|
|
51
|
+
return typeof elementStyleOrClass.frameHover === 'object' ? elementStyleOrClass.frameHover : undefined;
|
|
52
|
+
}
|
|
53
|
+
return typeof elementStyleOrClass.frame === 'object' ? elementStyleOrClass.frame : undefined;
|
|
54
|
+
};
|
|
55
|
+
var getBlockClass = function () {
|
|
56
|
+
if (isDraging && elementStyleOrClass.blockClick) {
|
|
57
|
+
return typeof elementStyleOrClass.blockClick === 'string' ? elementStyleOrClass.blockClick : '';
|
|
58
|
+
}
|
|
59
|
+
else if (isHover && elementStyleOrClass.blockHover) {
|
|
60
|
+
return typeof elementStyleOrClass.blockHover === 'string' ? elementStyleOrClass.blockHover : '';
|
|
61
|
+
}
|
|
62
|
+
return typeof elementStyleOrClass.block === 'string' ? elementStyleOrClass.block : '';
|
|
63
|
+
};
|
|
64
|
+
var getBlockStyle = function () {
|
|
65
|
+
if (isDraging && elementStyleOrClass.blockClick) {
|
|
66
|
+
return typeof elementStyleOrClass.blockClick === 'object' ? elementStyleOrClass.blockClick : undefined;
|
|
67
|
+
}
|
|
68
|
+
else if (isHover && elementStyleOrClass.blockHover) {
|
|
69
|
+
return typeof elementStyleOrClass.blockHover === 'object' ? elementStyleOrClass.blockHover : undefined;
|
|
70
|
+
}
|
|
71
|
+
return typeof elementStyleOrClass.block === 'object' ? elementStyleOrClass.block : undefined;
|
|
72
|
+
};
|
|
20
73
|
var _a = useState(0), sBlockY = _a[0], setSBlockY = _a[1]; // sBlock的Top值, block顶部相对于frames上边的差值
|
|
21
|
-
var _b = useState(
|
|
22
|
-
var _c = useState(
|
|
23
|
-
setSFrameStyle(props.style);
|
|
74
|
+
var _b = useState(false), isDraging = _b[0], setIsDraging = _b[1];
|
|
75
|
+
var _c = useState(false), isHover = _c[0], setIsHover = _c[1];
|
|
24
76
|
useEffect(function () {
|
|
25
77
|
// 初始化的 useEffect,其中只能添加初始化方法
|
|
26
78
|
setTimeout(function () {
|
|
27
79
|
// pixui限制,必须异步获取元素,也可以用userRef, 但效率似乎不如初始化时查找
|
|
28
|
-
if (!
|
|
29
|
-
console.warn('[CustomScrollBar][Error] 未设置
|
|
80
|
+
if (!scrollRef) {
|
|
81
|
+
console.warn('[CustomScrollBar][Error] 未设置 scrollRef!');
|
|
30
82
|
return;
|
|
31
83
|
}
|
|
32
|
-
sWindow =
|
|
33
|
-
sBlock = document.getElementById(
|
|
34
|
-
sFrame = document.getElementById(
|
|
84
|
+
sWindow = scrollRef.current;
|
|
85
|
+
sBlock = document.getElementById("".concat(rootId, "_block"));
|
|
86
|
+
sFrame = document.getElementById("".concat(rootId, "_frame"));
|
|
35
87
|
if (!sWindow) {
|
|
36
88
|
console.warn('[CustomScrollBar][Error] 未找到sWindow,请确认设置的scrollWindowRef是否正确!');
|
|
37
89
|
return;
|
|
@@ -41,29 +93,15 @@ export function ScrollBar(props) {
|
|
|
41
93
|
return;
|
|
42
94
|
}
|
|
43
95
|
sWindow === null || sWindow === void 0 ? void 0 : sWindow.addEventListener('scroll', sWindowScrolling);
|
|
44
|
-
// 设置背景图
|
|
45
|
-
sBlock.style.backgroundImage = "url(".concat(props.sBlockImgNormal, ")");
|
|
46
|
-
sFrame.style.backgroundImage = "url(".concat(props.sFrameImgNormal, ")");
|
|
47
|
-
sBlock.addEventListener('mousedown', function () {
|
|
48
|
-
sBlock.style.backgroundImage = "url(".concat(props.sBlockImgClick, ")");
|
|
49
|
-
sFrame.style.backgroundImage = "url(".concat(props.sFrameImgClick, ")");
|
|
50
|
-
});
|
|
51
|
-
sBlock.addEventListener('mouseup', function () {
|
|
52
|
-
sBlock.style.backgroundImage = "url(".concat(props.sBlockImgNormal, ")");
|
|
53
|
-
sFrame.style.backgroundImage = "url(".concat(props.sFrameImgNormal, ")");
|
|
54
|
-
});
|
|
55
96
|
}, 1);
|
|
56
97
|
// 释放时删除监听
|
|
57
98
|
return function () {
|
|
58
99
|
sWindow === null || sWindow === void 0 ? void 0 : sWindow.removeEventListener('scroll', sWindowScrolling);
|
|
59
100
|
};
|
|
60
101
|
}, []);
|
|
61
|
-
useEffect(function () {
|
|
62
|
-
setSBlockStyle(function (prevStyle) { return (__assign(__assign({}, props.blockStyle), { marginTop: sBlockY })); });
|
|
63
|
-
}, [sBlockY, props.blockStyle]);
|
|
64
102
|
// 页面滑动时,滑块也跟着移动
|
|
65
103
|
var sWindowScrolling = function (event) {
|
|
66
|
-
if (
|
|
104
|
+
if (isDraging) {
|
|
67
105
|
// 这个事件是处理窗口滚动的。如果是拖动滑块,则不处理事件。否则会造成死循环。
|
|
68
106
|
return;
|
|
69
107
|
}
|
|
@@ -114,7 +152,7 @@ export function ScrollBar(props) {
|
|
|
114
152
|
sWindow.scrollTop = content_scrollTop;
|
|
115
153
|
}
|
|
116
154
|
};
|
|
117
|
-
useImperativeHandle(
|
|
155
|
+
useImperativeHandle(cRef, function () { return ({
|
|
118
156
|
scrollTo: scrollTo,
|
|
119
157
|
}); });
|
|
120
158
|
// 重设滚动轴, x预留, y为距离顶部的像素值
|
|
@@ -127,12 +165,10 @@ export function ScrollBar(props) {
|
|
|
127
165
|
sWindow.style.overflow = 'scroll';
|
|
128
166
|
};
|
|
129
167
|
var handleMouseEnter = function () {
|
|
130
|
-
|
|
131
|
-
sFrame.style.backgroundImage = "url(".concat(props.sFrameImgHavor, ")");
|
|
168
|
+
setIsHover(true);
|
|
132
169
|
};
|
|
133
170
|
var handleMouseLeave = function () {
|
|
134
|
-
|
|
135
|
-
sFrame.style.backgroundImage = "url(".concat(props.sFrameImgNormal, ")");
|
|
171
|
+
setIsHover(false);
|
|
136
172
|
};
|
|
137
173
|
var dragendMouseLeave = function (event) {
|
|
138
174
|
// 获取鼠标位置
|
|
@@ -148,18 +184,14 @@ export function ScrollBar(props) {
|
|
|
148
184
|
};
|
|
149
185
|
return (
|
|
150
186
|
// <div id="sframe" style={sFrameStyle}>
|
|
151
|
-
h("div", { id: "
|
|
152
|
-
h("div", { id: "
|
|
153
|
-
sBlock.style.backgroundImage = "url(".concat(props.sBlockImgClick, ")");
|
|
154
|
-
sFrame.style.backgroundImage = "url(".concat(props.sFrameImgClick, ")");
|
|
187
|
+
h("div", { id: "".concat(rootId, "_frame"), className: "".concat(rootClassName, ", ").concat(getFrameClass()), style: getFrameStyle(), onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave },
|
|
188
|
+
h("div", { id: "".concat(rootId, "_block"), className: getBlockClass(), style: __assign(__assign({}, getBlockStyle()), { marginTop: sBlockY }), draggable: true, onDragStart: function (event) {
|
|
155
189
|
//@ts-ignore
|
|
156
190
|
clientYtoBlockTop = event.clientY - event.target.getBoundingClientRect().top;
|
|
157
|
-
|
|
191
|
+
setIsDraging(true);
|
|
158
192
|
}, onDragEnd: function (event) {
|
|
159
|
-
|
|
160
|
-
sBlock.style.backgroundImage = "url(".concat(props.sBlockImgNormal, ")");
|
|
161
|
-
sFrame.style.backgroundImage = "url(".concat(props.sFrameImgNormal, ")");
|
|
193
|
+
setIsDraging(false);
|
|
162
194
|
// pixui bug fix: drag end 时判断鼠标区域是否在滚动条外
|
|
163
195
|
dragendMouseLeave(event);
|
|
164
196
|
}, onDrag: sBlockScrolling })));
|
|
165
|
-
}
|
|
197
|
+
};
|
|
@@ -1,97 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
percent?: number;
|
|
6
|
-
wrapperWidth?: number;
|
|
7
|
-
wrapperHeight?: number;
|
|
8
|
-
height?: number;
|
|
9
|
-
innerHeight?: number;
|
|
10
|
-
dotWidth?: number;
|
|
11
|
-
dotHeight?: number;
|
|
12
|
-
dotWrapperWidth?: number;
|
|
13
|
-
dotWrapperHeight?: number;
|
|
14
|
-
outerBg: string;
|
|
15
|
-
innerBg: string;
|
|
16
|
-
dotBg: string;
|
|
17
|
-
outerCss?: CSSProperties;
|
|
18
|
-
innerCss?: CSSProperties;
|
|
19
|
-
dotCss?: CSSProperties;
|
|
20
|
-
onDragStart: Function | null;
|
|
21
|
-
onDrag: Function | null;
|
|
22
|
-
onDragEnd: Function | null;
|
|
23
|
-
isDiscrete: boolean | null;
|
|
24
|
-
discrete?: number;
|
|
25
|
-
maxDiscrete?: number;
|
|
26
|
-
hasIncDecButton?: boolean | null;
|
|
27
|
-
incButtonWidth?: number;
|
|
28
|
-
incButtonHeight?: number;
|
|
29
|
-
decButtonWidth?: number;
|
|
30
|
-
decButtonHeight?: number;
|
|
31
|
-
incButtonBg?: string;
|
|
32
|
-
decButtonBg?: string;
|
|
33
|
-
overallWidth?: number;
|
|
34
|
-
onIncClick?: Function | null;
|
|
35
|
-
onDecClick?: Function | null;
|
|
36
|
-
rangeControl?: boolean;
|
|
37
|
-
startRange?: number;
|
|
38
|
-
endRange?: number;
|
|
39
|
-
hasDot?: boolean;
|
|
1
|
+
import { CSSProperties, h } from 'preact';
|
|
2
|
+
interface range {
|
|
3
|
+
minCount: number;
|
|
4
|
+
maxCount: number;
|
|
40
5
|
}
|
|
41
|
-
interface
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
outerStyle: CSSProperties;
|
|
46
|
-
innerStyle: CSSProperties;
|
|
47
|
-
dotStyle: CSSProperties;
|
|
48
|
-
dotWrapperStyle: CSSProperties;
|
|
49
|
-
incButtonStyle: CSSProperties;
|
|
50
|
-
decButtonStyle: CSSProperties;
|
|
51
|
-
withButtonStyle: CSSProperties;
|
|
6
|
+
export interface sliderElement {
|
|
7
|
+
rail?: string | CSSProperties;
|
|
8
|
+
track?: string | CSSProperties;
|
|
9
|
+
handle?: string | CSSProperties;
|
|
52
10
|
}
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
isDiscrete: boolean;
|
|
67
|
-
discrete: number;
|
|
68
|
-
maxDiscrete: number;
|
|
69
|
-
hasIncDecButton: boolean;
|
|
70
|
-
overallWidth: number;
|
|
71
|
-
rangeControl: boolean;
|
|
72
|
-
hasDot: boolean;
|
|
73
|
-
};
|
|
74
|
-
private lastX;
|
|
75
|
-
private count;
|
|
76
|
-
private rect;
|
|
77
|
-
private discrete;
|
|
78
|
-
private refWrapper;
|
|
79
|
-
constructor(props: any);
|
|
80
|
-
componentDidMount(): void;
|
|
81
|
-
componentWillReceiveProps(nextProps: any): void;
|
|
82
|
-
onDragStart: (event: any) => void;
|
|
83
|
-
onDrag: (event: any) => void;
|
|
84
|
-
onDragEnd: (event: any) => void;
|
|
85
|
-
onDecClick: () => void;
|
|
86
|
-
onIncClick: () => void;
|
|
87
|
-
wrapperStyle: () => import("../../../../../lib/preact/src/jsx").JCSSProperties;
|
|
88
|
-
outerStyle: () => import("../../../../../lib/preact/src/jsx").JCSSProperties;
|
|
89
|
-
innerStyle: () => import("../../../../../lib/preact/src/jsx").JCSSProperties;
|
|
90
|
-
dotWrapperStyle: () => import("../../../../../lib/preact/src/jsx").JCSSProperties;
|
|
91
|
-
dotStyle: () => import("../../../../../lib/preact/src/jsx").JCSSProperties;
|
|
92
|
-
incButtonStyle: () => import("../../../../../lib/preact/src/jsx").JCSSProperties;
|
|
93
|
-
decButtonStyle: () => import("../../../../../lib/preact/src/jsx").JCSSProperties;
|
|
94
|
-
withButtonStyle: () => import("../../../../../lib/preact/src/jsx").JCSSProperties;
|
|
95
|
-
render(): h.JSX.Element;
|
|
11
|
+
export interface SliderProps {
|
|
12
|
+
id?: string;
|
|
13
|
+
rootClassName?: string;
|
|
14
|
+
min?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
value?: number;
|
|
17
|
+
step?: number;
|
|
18
|
+
vertical?: boolean;
|
|
19
|
+
range?: boolean | range;
|
|
20
|
+
onChangeStart?: (value: any) => void;
|
|
21
|
+
onChange?: (value: any) => void;
|
|
22
|
+
onChangeComplete?: (value: any) => void;
|
|
23
|
+
element?: sliderElement;
|
|
96
24
|
}
|
|
25
|
+
export declare const Slider: (props: SliderProps) => h.JSX.Element;
|
|
97
26
|
export {};
|