pixuireactcomponents 0.0.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.
Files changed (39) hide show
  1. package/index.d.ts +17 -0
  2. package/index.js +18 -0
  3. package/package.json +11 -0
  4. package/tools/EventDispatcherJs.d.ts +10 -0
  5. package/tools/EventDispatcherJs.js +71 -0
  6. package/tools/Logger.d.ts +6 -0
  7. package/tools/Logger.js +138 -0
  8. package/ui/components/button/Button.d.ts +6 -0
  9. package/ui/components/button/Button.js +66 -0
  10. package/ui/components/carousel/Carousel.d.ts +5 -0
  11. package/ui/components/carousel/Carousel.js +226 -0
  12. package/ui/components/dropdown/Dropdown.d.ts +30 -0
  13. package/ui/components/dropdown/Dropdown.js +92 -0
  14. package/ui/components/dropdown/DropdownOptionUI.d.ts +11 -0
  15. package/ui/components/dropdown/DropdownOptionUI.js +28 -0
  16. package/ui/components/dropdown/DropdownSpreadMainUI.d.ts +9 -0
  17. package/ui/components/dropdown/DropdownSpreadMainUI.js +27 -0
  18. package/ui/components/dropdown/DropdownUnspreadMainUI.d.ts +9 -0
  19. package/ui/components/dropdown/DropdownUnspreadMainUI.js +27 -0
  20. package/ui/components/gradient/GradientText.d.ts +63 -0
  21. package/ui/components/gradient/GradientText.js +329 -0
  22. package/ui/components/imageViewer/imageViewer.d.ts +23 -0
  23. package/ui/components/imageViewer/imageViewer.js +149 -0
  24. package/ui/components/outlinetext/OutlineText.d.ts +94 -0
  25. package/ui/components/outlinetext/OutlineText.js +167 -0
  26. package/ui/components/progress/Progress.d.ts +34 -0
  27. package/ui/components/progress/Progress.js +142 -0
  28. package/ui/components/slapface/Slapface.d.ts +18 -0
  29. package/ui/components/slapface/Slapface.js +485 -0
  30. package/ui/components/slider/Slider.d.ts +57 -0
  31. package/ui/components/slider/Slider.js +289 -0
  32. package/ui/components/tab/Tab.d.ts +6 -0
  33. package/ui/components/tab/Tab.js +27 -0
  34. package/ui/components/tab/Tabs.d.ts +12 -0
  35. package/ui/components/tab/Tabs.js +54 -0
  36. package/ui/components/togglegroup/ToggleGroup.d.ts +13 -0
  37. package/ui/components/togglegroup/ToggleGroup.js +99 -0
  38. package/ui/sample/Images.d.ts +28 -0
  39. package/ui/sample/Images.js +54 -0
@@ -0,0 +1,149 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { Component, h } from 'preact';
17
+ { /* {isViewerOpen && (
18
+ <ImageViewer
19
+ src={images}
20
+ currentIndex={currentImage}
21
+ onClose={closeImageViewer}
22
+ disableScroll={false}
23
+ backgroundStyle={{
24
+ backgroundColor: "rgba(0,0,0,0.9)"
25
+ }}
26
+ closeOnClickOutside={true}
27
+ />
28
+ )} */
29
+ }
30
+ var ImageViewer = /** @class */ (function (_super) {
31
+ __extends(ImageViewer, _super);
32
+ function ImageViewer(props) {
33
+ var _this = _super.call(this, props) || this;
34
+ _this.onClose = function () {
35
+ _this.props.onClose();
36
+ };
37
+ _this.onBlock = function (event) {
38
+ event.stopPropagation();
39
+ };
40
+ /* 这种方式无法获取到div宽高,获取到的值都是0 */
41
+ // componentDidMount(){
42
+ // let imageArea = document.getElementById("imageArea");
43
+ // let y = imageArea?.clientHeight;
44
+ // let x = imageArea?.clientWidth;
45
+ // console.log(x,y);
46
+ // }
47
+ _this.handleImageLoad = function (event) {
48
+ // console.log(`img`, event.target.width, event.target.height);
49
+ var imageX = event.target.width;
50
+ var imageY = event.target.height;
51
+ var imageArea = document.getElementById("imageArea");
52
+ var imageAreaY = imageArea === null || imageArea === void 0 ? void 0 : imageArea.clientHeight;
53
+ var imageAreaX = imageArea === null || imageArea === void 0 ? void 0 : imageArea.clientWidth;
54
+ if (typeof imageAreaY !== 'undefined' && typeof imageAreaX !== 'undefined')
55
+ if (imageAreaX < imageX || imageAreaY < imageY) {
56
+ var scaleFactorX = imageAreaX / imageX;
57
+ var scaleFactorY = imageAreaY / imageY;
58
+ var scaleFactor = 1;
59
+ if (scaleFactorX > scaleFactorY)
60
+ scaleFactor = scaleFactorY;
61
+ else
62
+ scaleFactor = scaleFactorX;
63
+ // console.log(`需要缩放,缩放系数为${scaleFactor}`);
64
+ _this.setState({
65
+ imageHeight: imageY * scaleFactor,
66
+ imageWidth: imageX * scaleFactor,
67
+ reCalSize: true,
68
+ }, function () {
69
+ // console.log(`状态改变后${this.state.imageHeight},${this.state.imageWidth},${this.state.reCalSize}`)
70
+ });
71
+ }
72
+ };
73
+ _this.state = {
74
+ imageHeight: 0,
75
+ imageWidth: 0,
76
+ reCalSize: false,
77
+ };
78
+ return _this;
79
+ }
80
+ ImageViewer.prototype.render = function () {
81
+ //@ts-ignore
82
+ // this.props.imageAreaStyle.backgroundImage=`url(${this.props.src})`; //为backgroundimage选择src
83
+ // //@ts-ignore
84
+ // this.props.imageStyle.width=this.state.imageWidth;
85
+ // //@ts-ignore
86
+ // this.props.imageStyle.height=this.state.imageHeight;
87
+ // if (this.state.reCalSize == true && this.state.forceupdate == true) {
88
+ // console.log('强制刷新')
89
+ // this.setState({
90
+ // forceupdate: false,
91
+ // })
92
+ // }
93
+ return (h("div", { style: this.props.backgroundStyle, onClick: this.onClose },
94
+ h("div", { style: this.props.imageBoxStyle },
95
+ h("div", { id: "imageArea", style: this.props.imageAreaStyle },
96
+ this.state.reCalSize &&
97
+ h("img", { style: this.props.imageStyle, src: this.props.src, width: this.state.imageWidth, height: this.state.imageHeight, onClick: this.onBlock }),
98
+ !this.state.reCalSize &&
99
+ h("img", { onLoad: this.handleImageLoad, style: { display: 'hidden' }, src: this.props.src })))));
100
+ };
101
+ return ImageViewer;
102
+ }(Component));
103
+ export { ImageViewer };
104
+ var backgroundStyleDefault = {
105
+ position: 'absolute',
106
+ width: '100%',
107
+ height: '100%',
108
+ backgroundColor: 'rgba(0,0,0,0.8)',
109
+ display: 'flex',
110
+ flexDirection: 'row',
111
+ justifyContent: 'center',
112
+ alignItems: 'center',
113
+ zIndex: 99,
114
+ // top: 0,
115
+ // right: 0,
116
+ // bottom: 0,
117
+ // left: 0,
118
+ };
119
+ var imageBoxStyleDefault = {
120
+ width: '100%',
121
+ height: '100%',
122
+ display: 'flex',
123
+ flexDirection: 'row',
124
+ justifyContent: 'center',
125
+ alignItems: 'center',
126
+ };
127
+ var imageAreaStyleDefault = {
128
+ width: '80%',
129
+ height: '80%',
130
+ display: 'flex',
131
+ flexDirection: 'row',
132
+ justifyContent: 'center',
133
+ alignItems: 'center',
134
+ // backgroundSize: 'contain',
135
+ // backgroundRepeat:'no-repeat',
136
+ // backgroundPosition:'center'
137
+ };
138
+ var imageStyleDefault = {
139
+ maxWidth: '100%',
140
+ maxHeight: '100%',
141
+ // objectFit: 'contain', //pixui不支持object-fit属性
142
+ };
143
+ ImageViewer.defaultProps = {
144
+ backgroundStyle: backgroundStyleDefault,
145
+ imageBoxStyle: imageBoxStyleDefault,
146
+ imageAreaStyle: imageAreaStyleDefault,
147
+ imageStyle: imageStyleDefault,
148
+ closeOnClickOutside: true,
149
+ };
@@ -0,0 +1,94 @@
1
+ import { Component, CSSProperties, h } from 'preact';
2
+ export declare enum FontStyle {
3
+ Normal = 0,
4
+ Bold = 1,
5
+ Italic = 2,
6
+ BoldAndItalic = 3
7
+ }
8
+ export declare enum TextAnchor {
9
+ UpperLeft = 0,
10
+ UpperCenter = 1,
11
+ UpperRight = 2,
12
+ MiddleLeft = 3,
13
+ MiddleCenter = 4,
14
+ MiddleRight = 5,
15
+ LowerLeft = 6,
16
+ LowerCenter = 7,
17
+ LowerRight = 8
18
+ }
19
+ export declare enum HorizontalWrapMode {
20
+ Wrap = 0,
21
+ Overflow = 1
22
+ }
23
+ export declare enum VerticalWrapMode {
24
+ Truncate = 0,
25
+ Overflow = 1
26
+ }
27
+ export interface OutlineTextProps {
28
+ style?: CSSProperties;
29
+ text?: string;
30
+ font?: string;
31
+ fontStyle?: FontStyle;
32
+ fontSize?: number;
33
+ lineSpacing?: number;
34
+ alignment?: TextAnchor;
35
+ alignByGeometry?: boolean;
36
+ horizontalOverflow?: HorizontalWrapMode;
37
+ verticalOverflow?: VerticalWrapMode;
38
+ color: {
39
+ r: number;
40
+ g: number;
41
+ b: number;
42
+ a: number;
43
+ };
44
+ outlineColor: {
45
+ r: number;
46
+ g: number;
47
+ b: number;
48
+ a: number;
49
+ };
50
+ outlineDistance: {
51
+ x: number;
52
+ y: number;
53
+ };
54
+ }
55
+ export declare class OutlineText extends Component<OutlineTextProps, OutlineTextProps> {
56
+ text: any;
57
+ outline: any;
58
+ textColor: any;
59
+ effectColor: any;
60
+ constructor(props: any);
61
+ static defaultProps: {
62
+ style: import("../../../../../lib/preact/src/jsx").JCSSProperties;
63
+ text: string;
64
+ font: string;
65
+ fontStyle: FontStyle;
66
+ fontSize: number;
67
+ lineSpacing: number;
68
+ alignment: TextAnchor;
69
+ alignByGeometry: boolean;
70
+ horizontalOverflow: HorizontalWrapMode;
71
+ verticalOverflow: VerticalWrapMode;
72
+ color: {
73
+ r: number;
74
+ g: number;
75
+ b: number;
76
+ a: number;
77
+ };
78
+ outlineColor: {
79
+ r: number;
80
+ g: number;
81
+ b: number;
82
+ a: number;
83
+ };
84
+ outlineDistance: {
85
+ x: number;
86
+ y: number;
87
+ };
88
+ };
89
+ componentDidUpdate(): void;
90
+ OnLoad: (e: any) => void;
91
+ colorRgb(colorStr: any): any;
92
+ updateOutlineText(): void;
93
+ render(): h.JSX.Element;
94
+ }
@@ -0,0 +1,167 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { Component, h } from 'preact';
17
+ export var FontStyle;
18
+ (function (FontStyle) {
19
+ FontStyle[FontStyle["Normal"] = 0] = "Normal";
20
+ FontStyle[FontStyle["Bold"] = 1] = "Bold";
21
+ FontStyle[FontStyle["Italic"] = 2] = "Italic";
22
+ FontStyle[FontStyle["BoldAndItalic"] = 3] = "BoldAndItalic";
23
+ })(FontStyle || (FontStyle = {}));
24
+ export var TextAnchor;
25
+ (function (TextAnchor) {
26
+ TextAnchor[TextAnchor["UpperLeft"] = 0] = "UpperLeft";
27
+ TextAnchor[TextAnchor["UpperCenter"] = 1] = "UpperCenter";
28
+ TextAnchor[TextAnchor["UpperRight"] = 2] = "UpperRight";
29
+ TextAnchor[TextAnchor["MiddleLeft"] = 3] = "MiddleLeft";
30
+ TextAnchor[TextAnchor["MiddleCenter"] = 4] = "MiddleCenter";
31
+ TextAnchor[TextAnchor["MiddleRight"] = 5] = "MiddleRight";
32
+ TextAnchor[TextAnchor["LowerLeft"] = 6] = "LowerLeft";
33
+ TextAnchor[TextAnchor["LowerCenter"] = 7] = "LowerCenter";
34
+ TextAnchor[TextAnchor["LowerRight"] = 8] = "LowerRight";
35
+ })(TextAnchor || (TextAnchor = {}));
36
+ export var HorizontalWrapMode;
37
+ (function (HorizontalWrapMode) {
38
+ HorizontalWrapMode[HorizontalWrapMode["Wrap"] = 0] = "Wrap";
39
+ HorizontalWrapMode[HorizontalWrapMode["Overflow"] = 1] = "Overflow";
40
+ })(HorizontalWrapMode || (HorizontalWrapMode = {}));
41
+ export var VerticalWrapMode;
42
+ (function (VerticalWrapMode) {
43
+ VerticalWrapMode[VerticalWrapMode["Truncate"] = 0] = "Truncate";
44
+ VerticalWrapMode[VerticalWrapMode["Overflow"] = 1] = "Overflow";
45
+ })(VerticalWrapMode || (VerticalWrapMode = {}));
46
+ var defaultStyle = {
47
+ width: 200,
48
+ height: 200
49
+ };
50
+ export var OutlineText = /** @class */ (function (_super) {
51
+ __extends(OutlineText, _super);
52
+ function OutlineText(props) {
53
+ var _this = _super.call(this, props) || this;
54
+ _this.OnLoad = function (e) {
55
+ console.log('!!!!!!!!!!!!!!');
56
+ if (!window.require) {
57
+ console.error('need puerts env');
58
+ }
59
+ var CS = window.require('csharp');
60
+ if (!CS) {
61
+ console.error('need puerts env');
62
+ return;
63
+ }
64
+ var puerts = window.require('puerts');
65
+ console.log('?????');
66
+ var windowId = window.external.id;
67
+ var handle = e.target.attachment.handle;
68
+ var attachment = CS.com.tencent.pandora.CSharpInterface.GetSlotAttachmentByHandle(windowId, handle);
69
+ if (!attachment) {
70
+ console.error("can't get relected attachment, handle:".concat(handle));
71
+ return;
72
+ }
73
+ console.log('windowId:' + windowId.toString() + ' handle:' + handle.toString());
74
+ var placeholder = attachment.GetMountingGameObject();
75
+ var text = placeholder.AddComponent(puerts.$typeof(CS.UnityEngine.UI.Text));
76
+ _this.text = text;
77
+ var outline = placeholder.AddComponent(puerts.$typeof(CS.UnityEngine.UI.Outline));
78
+ _this.outline = outline;
79
+ _this.updateOutlineText();
80
+ };
81
+ return _this;
82
+ }
83
+ OutlineText.prototype.componentDidUpdate = function () {
84
+ console.log('componentDidUpdate');
85
+ this.updateOutlineText();
86
+ };
87
+ OutlineText.prototype.colorRgb = function (colorStr) {
88
+ //十六进制颜色值的正则表达式
89
+ var reg = /^#([0-9a-fA-f]{0,}|)$/;
90
+ var matchRes = colorStr.toString().toLowerCase().match(reg);
91
+ var transColor = '';
92
+ if (matchRes.length > 0)
93
+ transColor = matchRes[matchRes.length - 1];
94
+ // eslint-disable-next-line @typescript-eslint/no-array-constructor
95
+ var colorList = new Array();
96
+ while (transColor != '') {
97
+ var hex = '0x' + transColor.substring(0, 2);
98
+ colorList.push(parseInt(hex, 16));
99
+ transColor = transColor.substring(2, transColor.length);
100
+ }
101
+ var r, g, b, a = 1;
102
+ for (var i = 0; i < colorList.length; i++) {
103
+ if (i == 0 && colorList[i] != null && colorList[i] != undefined) {
104
+ r = colorList[i] / 255;
105
+ }
106
+ if (i == 1 && colorList[i] != null && colorList[i] != undefined) {
107
+ g = colorList[i] / 255;
108
+ }
109
+ if (i == 2 && colorList[i] != null && colorList[i] != undefined) {
110
+ b = colorList[i] / 255;
111
+ }
112
+ if (i == 3 && colorList[i] != null && colorList[i] != undefined) {
113
+ a = colorList[i] / 255;
114
+ }
115
+ }
116
+ var CS = window.require('csharp');
117
+ return CS.UnityEngine.Color(r, g, b, a);
118
+ };
119
+ OutlineText.prototype.updateOutlineText = function () {
120
+ var CS = window.require('csharp');
121
+ this.text.text = this.props.text;
122
+ this.text.font = CS.com.tencent.pandora.TextPartner.GetFont.Invoke(this.props.font);
123
+ this.text.fontStyle = this.props.fontStyle;
124
+ this.text.fontSize = this.props.fontSize;
125
+ this.text.lineSpacing = this.props.lineSpacing;
126
+ this.text.alignment = this.props.alignment;
127
+ this.text.alignByGeometry = this.props.alignByGeometry;
128
+ this.text.horizontalOverflow = this.props.horizontalOverflow;
129
+ this.text.verticalOverflow = this.props.verticalOverflow;
130
+ this.text.color = CS.UnityEngine.Color(this.props.color.r, this.props.color.g, this.props.color.b, this.props.color.a);
131
+ this.outline.effectColor = CS.UnityEngine.Color(this.props.outlineColor.r, this.props.outlineColor.g, this.props.outlineColor.b, this.props.outlineColor.a);
132
+ this.outline.effectDistance = new CS.UnityEngine.Vector2(this.props.outlineDistance.x, this.props.outlineDistance.y);
133
+ };
134
+ OutlineText.prototype.render = function () {
135
+ return (h("div", { style: this.props.style },
136
+ h("pixslot", { style: { width: '100%', height: '100%' }, src: 'pixui://method:placeholder', onLoad: this.OnLoad.bind(this) })));
137
+ };
138
+ OutlineText.defaultProps = {
139
+ style: defaultStyle,
140
+ text: 'NEW TEXT',
141
+ font: 'gamefont',
142
+ fontStyle: FontStyle.Normal,
143
+ fontSize: 14,
144
+ lineSpacing: 1,
145
+ alignment: TextAnchor.UpperLeft,
146
+ alignByGeometry: false,
147
+ horizontalOverflow: HorizontalWrapMode.Wrap,
148
+ verticalOverflow: VerticalWrapMode.Truncate,
149
+ color: {
150
+ r: 1,
151
+ g: 1,
152
+ b: 1,
153
+ a: 1
154
+ },
155
+ outlineColor: {
156
+ r: 0,
157
+ g: 0,
158
+ b: 0,
159
+ a: 1
160
+ },
161
+ outlineDistance: {
162
+ x: 1,
163
+ y: -1
164
+ },
165
+ };
166
+ return OutlineText;
167
+ }(Component));
@@ -0,0 +1,34 @@
1
+ import { Component, h } from 'preact';
2
+ export interface ProgressProps {
3
+ percent: number;
4
+ wrapperWidth: number;
5
+ wrapperHeight: number;
6
+ height: number;
7
+ dotWidth: number;
8
+ dotHeight: number;
9
+ dotWrapperWidth: number;
10
+ dotWrapperHeight: number;
11
+ outerBg: string;
12
+ innerBg: string;
13
+ dotBg: string;
14
+ onDragStart: Function | null;
15
+ onDrag: Function | null;
16
+ onDragEnd: Function | null;
17
+ }
18
+ export declare class Progress extends Component<ProgressProps, {
19
+ percent: number;
20
+ }> {
21
+ private refWrapper;
22
+ constructor(props: any);
23
+ componentDidMount(): void;
24
+ componentWillReceiveProps(nextProps: any): void;
25
+ onDragStart: (event: any) => void;
26
+ onDrag: (event: any) => void;
27
+ onDragEnd: (event: any) => void;
28
+ computeWrapperStyle: () => void;
29
+ computeOuterStyle: () => void;
30
+ computeInnerStyle: () => void;
31
+ computeDotWrapperStyle: () => void;
32
+ computeDotStyle: () => void;
33
+ render(): h.JSX.Element;
34
+ }
@@ -0,0 +1,142 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ import { Component, createRef, h } from 'preact';
28
+ var row_center_center = {
29
+ display: 'flex',
30
+ flexDirection: 'row',
31
+ justifyContent: 'center',
32
+ alignItems: 'center'
33
+ };
34
+ var wrapperStyle;
35
+ var outerStyle;
36
+ var innerStyle;
37
+ var dotStyle;
38
+ var dotWrapperStyle;
39
+ var lastX = undefined; // 上一次位置的横坐标
40
+ var count = 0; // 拖动条距离最左端的位置 [0, this.props.wrapperWidth]
41
+ var rect = undefined; // 滑动区域
42
+ var Progress = /** @class */ (function (_super) {
43
+ __extends(Progress, _super);
44
+ function Progress(props) {
45
+ var _this = _super.call(this, props) || this;
46
+ _this.refWrapper = createRef();
47
+ _this.onDragStart = function (event) {
48
+ console.log('【Progress】DragStart event.clientX--' + event.clientX + '-----percent----' + _this.state.percent + '-----currentX----' + (_this.state.percent / 100 * _this.props.wrapperWidth));
49
+ lastX = event.clentX;
50
+ count = _this.state.percent / 100 * _this.props.wrapperWidth;
51
+ if (_this.props.onDragStart) {
52
+ _this.props.onDragStart();
53
+ }
54
+ };
55
+ _this.onDrag = function (event) {
56
+ if (event.clientX < rect.left || event.clientX > rect.right)
57
+ return;
58
+ if (lastX == undefined) {
59
+ lastX = event.clientX;
60
+ return;
61
+ }
62
+ var move = Number(event.clientX) - Number(lastX);
63
+ count += move;
64
+ count = Math.min(_this.props.wrapperWidth, count);
65
+ count = Math.max(0, count);
66
+ var newPercent = count / _this.props.wrapperWidth * 100;
67
+ _this.setState({
68
+ percent: newPercent
69
+ }, function () {
70
+ if (_this.props.onDrag)
71
+ _this.props.onDrag(newPercent);
72
+ });
73
+ lastX = event.clientX;
74
+ };
75
+ _this.onDragEnd = function (event) {
76
+ lastX = undefined;
77
+ console.log('【Progress】DragEnd event.clientX--' + event.clientX + '-----percent----' + _this.state.percent + '-----currentX----' + (_this.state.percent / 100 * _this.props.wrapperWidth));
78
+ if (_this.props.onDragEnd) {
79
+ _this.props.onDragEnd(_this.state.percent);
80
+ }
81
+ };
82
+ _this.computeWrapperStyle = function () {
83
+ wrapperStyle = __assign({ width: _this.props.wrapperWidth + 'px', height: _this.props.wrapperHeight + 'px' }, row_center_center);
84
+ };
85
+ _this.computeOuterStyle = function () {
86
+ outerStyle = {
87
+ width: '100%',
88
+ height: _this.props.height + 'px',
89
+ backgroundImage: "url(".concat(_this.props.outerBg, ")"),
90
+ backgroundSize: '100% 100%'
91
+ };
92
+ };
93
+ _this.computeInnerStyle = function () {
94
+ var _width = Math.floor(_this.state.percent) + '%';
95
+ innerStyle = {
96
+ width: _width,
97
+ height: '100%',
98
+ backgroundImage: "url(".concat(_this.props.innerBg, ")"),
99
+ backgroundSize: '100% 100%'
100
+ };
101
+ };
102
+ _this.computeDotWrapperStyle = function () {
103
+ dotWrapperStyle = __assign({ position: 'absolute', width: _this.props.dotWrapperWidth + 'px', height: _this.props.dotWrapperHeight + 'px', marginTop: (_this.props.height - _this.props.dotWrapperHeight) / 2 + 'px', marginLeft: (_this.props.wrapperWidth * _this.state.percent / 100 - _this.props.dotWrapperWidth / 2) + 'px' }, row_center_center
104
+ // backgroundColor: '#FF000066'
105
+ );
106
+ };
107
+ _this.computeDotStyle = function () {
108
+ dotStyle = {
109
+ width: _this.props.dotWidth + 'px',
110
+ height: _this.props.dotHeight + 'px',
111
+ };
112
+ };
113
+ _this.state = {
114
+ percent: Math.floor(_this.props.percent)
115
+ };
116
+ _this.computeWrapperStyle();
117
+ _this.computeOuterStyle();
118
+ return _this;
119
+ }
120
+ Progress.prototype.componentDidMount = function () {
121
+ rect = this.refWrapper.current.getBoundingClientRect();
122
+ };
123
+ Progress.prototype.componentWillReceiveProps = function (nextProps) {
124
+ if (nextProps.percent == this.props.percent)
125
+ return;
126
+ this.setState({
127
+ percent: nextProps.percent
128
+ });
129
+ };
130
+ Progress.prototype.render = function () {
131
+ this.computeInnerStyle();
132
+ this.computeDotWrapperStyle();
133
+ this.computeDotStyle();
134
+ return (h("div", { ref: this.refWrapper, style: wrapperStyle },
135
+ h("div", { style: outerStyle },
136
+ h("div", { style: innerStyle },
137
+ h("div", { style: dotWrapperStyle, draggable: true, onDragStart: this.onDragStart, onDrag: this.onDrag, onDragEnd: this.onDragEnd },
138
+ h("img", { src: this.props.dotBg, style: dotStyle }))))));
139
+ };
140
+ return Progress;
141
+ }(Component));
142
+ export { Progress };
@@ -0,0 +1,18 @@
1
+ import { h, Component } from '../../../../../lib/preact/src';
2
+ export declare class Slapface extends Component<any, any> {
3
+ componentWillMount(): Promise<void>;
4
+ private loadGroup;
5
+ private switchItems;
6
+ private btn_closeButton;
7
+ private pic_loading;
8
+ private actDisplay;
9
+ private JumpFun;
10
+ private isNewDay;
11
+ private controlShowToday;
12
+ private nextDayTime;
13
+ private cstRightPos;
14
+ private cstBottomPos;
15
+ closeAct: () => void;
16
+ constructor(props: any);
17
+ render(): h.JSX.Element;
18
+ }