pixuireactcomponents 1.2.2 → 1.2.31
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 +15 -0
- package/index.js +16 -20
- package/package.json +9 -9
- package/tools/EventDispatcherJs.d.ts +10 -0
- package/tools/EventDispatcherJs.js +71 -0
- package/tools/Logger.d.ts +6 -0
- package/tools/Logger.js +138 -0
- package/ui/components/button/Button.d.ts +5 -0
- package/ui/components/button/Button.js +37 -0
- package/ui/components/carousel/Carousel.d.ts +5 -0
- package/ui/components/carousel/Carousel.js +219 -0
- package/ui/components/dropdown/Dropdown.d.ts +30 -0
- package/ui/components/dropdown/Dropdown.js +92 -0
- package/ui/components/dropdown/DropdownOptionUI.d.ts +11 -0
- package/ui/components/dropdown/DropdownOptionUI.js +28 -0
- package/ui/components/dropdown/DropdownSpreadMainUI.d.ts +9 -0
- package/ui/components/dropdown/DropdownSpreadMainUI.js +27 -0
- package/ui/components/dropdown/DropdownUnspreadMainUI.d.ts +9 -0
- package/ui/components/dropdown/DropdownUnspreadMainUI.js +27 -0
- package/ui/components/gradient/GradientText.d.ts +63 -0
- package/ui/components/gradient/{GradientText.tsx → GradientText.js} +174 -183
- package/ui/components/outlinetext/OutlineText.d.ts +94 -0
- package/ui/components/outlinetext/OutlineText.js +168 -0
- package/ui/components/progress/Progress.d.ts +34 -0
- package/ui/components/progress/Progress.js +142 -0
- package/ui/components/slapface/Slapface.d.ts +12 -0
- package/ui/components/slapface/Slapface.js +235 -0
- package/ui/components/slider/Slider.d.ts +57 -0
- package/ui/components/slider/Slider.js +289 -0
- package/ui/components/tab/Tab.d.ts +6 -0
- package/ui/components/tab/Tab.js +27 -0
- package/ui/components/tab/Tabs.d.ts +12 -0
- package/ui/components/tab/Tabs.js +54 -0
- package/cmdAfterTsBuild.js +0 -8
- package/tools/EventDispatcherJs.tsx +0 -74
- package/tools/Logger.tsx +0 -161
- package/tools/img/logger.png +0 -0
- package/tsconfig.json +0 -45
- package/ui/components/bulletscreen/BulletItemAnimation.tsx +0 -117
- package/ui/components/bulletscreen/BulletScreenAnimation.tsx +0 -278
- package/ui/components/bulletscreen/bullet.less +0 -17
- package/ui/components/button/Button.tsx +0 -18
- package/ui/components/carousel/Carousel.tsx +0 -279
- package/ui/components/checkBox/CheckBox.tsx +0 -40
- package/ui/components/dropdown/Dropdown.tsx +0 -126
- package/ui/components/dropdown/DropdownOptionUI.tsx +0 -14
- package/ui/components/dropdown/DropdownSpreadMainUI.tsx +0 -11
- package/ui/components/dropdown/DropdownUnspreadMainUI.tsx +0 -11
- package/ui/components/outlinetext/OutlineText.tsx +0 -184
- package/ui/components/progress/Progress.tsx +0 -174
- package/ui/components/slapface/Slapface.tsx +0 -284
- package/ui/components/slider/Slider.tsx +0 -366
- package/ui/components/tab/Tab.tsx +0 -12
- package/ui/components/tab/Tabs.tsx +0 -56
- package/ui/components/togglegroup/ToggleGroup.tsx +0 -105
- package/ui/components/videoplayer/VideoPlayer.tsx +0 -200
- package/ui/components/waterfallcomponent/WaterfallComponent.jsx +0 -687
- package/ui/components/waterfallcomponent/less/WaterfallComponent.less +0 -13
- package/ui/sample/Images.tsx +0 -60
- package/ui/sample/OutlineText/OutlineDemo.tsx +0 -61
- package/ui/sample/Slapface/SlapfaceDemo.tsx +0 -30
- package/ui/sample/asset/btn_close.png +0 -0
- package/ui/sample/asset/changtai_button.jpg +0 -0
- package/ui/sample/asset/checkbox0.png +0 -0
- package/ui/sample/asset/checkbox1.png +0 -0
- package/ui/sample/asset/data_arrow_down.png +0 -0
- package/ui/sample/asset/data_arrow_up.png +0 -0
- package/ui/sample/asset/dot.png +0 -0
- package/ui/sample/asset/inner.png +0 -0
- package/ui/sample/asset/item_reddot.png +0 -0
- package/ui/sample/asset/loading.png +0 -0
- package/ui/sample/asset/money_dropdown.png +0 -0
- package/ui/sample/asset/money_dropdownall.png +0 -0
- package/ui/sample/asset/outer.png +0 -0
- package/ui/sample/asset/slapface_samplepic1.png +0 -0
- package/ui/sample/asset/slapface_samplepic2.png +0 -0
- package/ui/sample/asset/slapface_samplepic3.png +0 -0
- package/ui/sample/asset/slapface_samplepic4.png +0 -0
- package/ui/sample/asset/slapface_samplepic5.png +0 -0
- package/ui/sample/asset/slapface_samplepic6.png +0 -0
- package/ui/sample/asset/tab_choosed.png +0 -0
- package/ui/sample/asset/tabs_bg.png +0 -0
- package/ui/sample/asset/video_pause.png +0 -0
- package/ui/sample/asset/video_play.png +0 -0
- package/ui/sample/asset/video_reload.png +0 -0
- package/ui/sample/asset/xuanfu_button.jpg +0 -0
- package/ui/sample/asset/yaxia_button.jpg +0 -0
- package/ui/sample/bulletscreen/BulletDemo.tsx +0 -84
- package/ui/sample/button/ButtonDemo.tsx +0 -19
- package/ui/sample/carousel/carouselDemo.tsx +0 -52
- package/ui/sample/checkBox/checkBoxDemo.tsx +0 -7
- package/ui/sample/dropdown/DropdownDemo.tsx +0 -65
- package/ui/sample/dropdown/MoneyDropdownOption.tsx +0 -50
- package/ui/sample/dropdown/MoneyDropdownSpreadMain.tsx +0 -42
- package/ui/sample/dropdown/MoneyDropdownUnspreadMain.tsx +0 -44
- package/ui/sample/gradient/GradientDemo.tsx +0 -51
- package/ui/sample/less/video.less +0 -144
- package/ui/sample/progress/ProgressDemo.tsx +0 -74
- package/ui/sample/slider/SliderDemo.tsx +0 -116
- package/ui/sample/tab/TabDemo.tsx +0 -67
- package/ui/sample/tab/TopTab.tsx +0 -74
- package/ui/sample/togglegroup/ToggleGroupDemo.tsx +0 -35
- package/ui/sample/videoplayer/VideoPlayerDemo.tsx +0 -57
- package/ui/sample/waterfallcomponent/WaterfallComponentDemo.jsx +0 -137
|
@@ -0,0 +1,168 @@
|
|
|
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
|
+
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 (!require) {
|
|
57
|
+
console.error('need puerts env');
|
|
58
|
+
}
|
|
59
|
+
var CS = require('csharp');
|
|
60
|
+
if (!CS) {
|
|
61
|
+
console.error('need puerts env');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
var puerts = 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));
|
|
168
|
+
export { OutlineText };
|
|
@@ -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,12 @@
|
|
|
1
|
+
import { h, Component } from "preact";
|
|
2
|
+
export declare class Slapface extends Component<any, any> {
|
|
3
|
+
private LoadGroup;
|
|
4
|
+
private jumpButton;
|
|
5
|
+
private settingsitems;
|
|
6
|
+
private btn_closeButton;
|
|
7
|
+
private pic_loading;
|
|
8
|
+
private actDisplay;
|
|
9
|
+
closeAct: () => void;
|
|
10
|
+
constructor(props: any);
|
|
11
|
+
render(): h.JSX.Element;
|
|
12
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
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 { h, Component } from "preact";
|
|
28
|
+
//@ts-ignore
|
|
29
|
+
import SlapfaceLess from "./less/Slapface.less";
|
|
30
|
+
//默认配置项
|
|
31
|
+
var settingsitems = {
|
|
32
|
+
ani_switch_type: 1,
|
|
33
|
+
is_mask: false
|
|
34
|
+
};
|
|
35
|
+
//默认无跳转按钮
|
|
36
|
+
var jumpButton = {
|
|
37
|
+
pic_changtai: '',
|
|
38
|
+
pic_yaxia: '',
|
|
39
|
+
pic_xuanfu: ''
|
|
40
|
+
};
|
|
41
|
+
var slapfaceNode = /** @class */ (function () {
|
|
42
|
+
function slapfaceNode(par_index) {
|
|
43
|
+
if (par_index == undefined)
|
|
44
|
+
this.index = -1;
|
|
45
|
+
else
|
|
46
|
+
this.index = par_index;
|
|
47
|
+
this.next = null;
|
|
48
|
+
}
|
|
49
|
+
return slapfaceNode;
|
|
50
|
+
}());
|
|
51
|
+
var slapfaceNodeList = /** @class */ (function () {
|
|
52
|
+
function slapfaceNodeList(groupArr) {
|
|
53
|
+
this.head = new slapfaceNode();
|
|
54
|
+
var cur = this.head;
|
|
55
|
+
this.size = 0;
|
|
56
|
+
if (groupArr) {
|
|
57
|
+
for (var i = 0; i < groupArr.length; i++) {
|
|
58
|
+
cur.next = new slapfaceNode(i);
|
|
59
|
+
cur = cur.next;
|
|
60
|
+
}
|
|
61
|
+
this.groupArr = groupArr;
|
|
62
|
+
this.size += groupArr.length;
|
|
63
|
+
}
|
|
64
|
+
this.tail = cur;
|
|
65
|
+
}
|
|
66
|
+
slapfaceNodeList.prototype.Add = function (index, next) {
|
|
67
|
+
this.tail.next = new slapfaceNode(index);
|
|
68
|
+
this.tail = this.tail.next;
|
|
69
|
+
++this.size;
|
|
70
|
+
return this.tail;
|
|
71
|
+
};
|
|
72
|
+
slapfaceNodeList.prototype.DeleteNext = function (curParam) {
|
|
73
|
+
if (curParam.next == null)
|
|
74
|
+
return;
|
|
75
|
+
else {
|
|
76
|
+
curParam.next = curParam.next.next;
|
|
77
|
+
}
|
|
78
|
+
--this.size;
|
|
79
|
+
};
|
|
80
|
+
slapfaceNodeList.prototype.CheckReady = function () {
|
|
81
|
+
var cur = this.head;
|
|
82
|
+
while (cur.next != null) {
|
|
83
|
+
if (this.groupArr[cur.next.index].isLoadDone) {
|
|
84
|
+
cur = cur.next;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
var retIndex = cur.next.index;
|
|
88
|
+
this.DeleteNext(cur);
|
|
89
|
+
return retIndex;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return -1;
|
|
93
|
+
};
|
|
94
|
+
return slapfaceNodeList;
|
|
95
|
+
}());
|
|
96
|
+
var Slapface = /** @class */ (function (_super) {
|
|
97
|
+
__extends(Slapface, _super);
|
|
98
|
+
function Slapface(props) {
|
|
99
|
+
var _this = _super.call(this, props) || this;
|
|
100
|
+
_this.closeAct = function () {
|
|
101
|
+
_this.actDisplay = "none";
|
|
102
|
+
_this.forceUpdate();
|
|
103
|
+
};
|
|
104
|
+
_this.LoadGroup = _this.props.LoadGroup;
|
|
105
|
+
for (var i = 0; i < _this.LoadGroup.length; i++) {
|
|
106
|
+
_this.LoadGroup[i].isLoadDone = false;
|
|
107
|
+
}
|
|
108
|
+
_this.jumpButton = _this.props.jumpButton ? _this.props.jumpButton : jumpButton;
|
|
109
|
+
_this.settingsitems = _this.props.settingsitems ? _this.props.settingsitems : settingsitems;
|
|
110
|
+
_this.btn_closeButton = _this.props.btn_closeButton ? _this.props.btn_closeButton : '';
|
|
111
|
+
_this.pic_loading = _this.props.pic_loading;
|
|
112
|
+
_this.actDisplay = "flex";
|
|
113
|
+
return _this;
|
|
114
|
+
}
|
|
115
|
+
Slapface.prototype.render = function () {
|
|
116
|
+
var slapfaceinfo = {
|
|
117
|
+
LoadGroup: this.LoadGroup,
|
|
118
|
+
jumpButton: this.jumpButton,
|
|
119
|
+
settingsitems: this.settingsitems,
|
|
120
|
+
btn_closeButton: this.btn_closeButton,
|
|
121
|
+
pic_loading: this.pic_loading
|
|
122
|
+
};
|
|
123
|
+
return (h("div", { style: { display: this.actDisplay, width: "100%", height: "100%" } },
|
|
124
|
+
h("div", { style: { width: '100%', height: '100%', backgroundColor: "rgba(0,0,0,0.5)" } }, h(Group, __assign({}, slapfaceinfo, { closeAct: this.closeAct })))));
|
|
125
|
+
};
|
|
126
|
+
return Slapface;
|
|
127
|
+
}(Component));
|
|
128
|
+
export { Slapface };
|
|
129
|
+
var Group = /** @class */ (function (_super) {
|
|
130
|
+
__extends(Group, _super);
|
|
131
|
+
function Group(props) {
|
|
132
|
+
var _this = _super.call(this, props) || this;
|
|
133
|
+
var emptyGroup = [
|
|
134
|
+
{
|
|
135
|
+
isLoadDone: false,
|
|
136
|
+
picture: "",
|
|
137
|
+
width: 0,
|
|
138
|
+
height: 0
|
|
139
|
+
}
|
|
140
|
+
];
|
|
141
|
+
_this.groupArr = emptyGroup.concat(_this.props.LoadGroup);
|
|
142
|
+
_this.groupIndexList = new slapfaceNodeList(_this.groupArr);
|
|
143
|
+
_this.loadDisplay = "hidden";
|
|
144
|
+
_this.elseDisplay = "visible";
|
|
145
|
+
_this.firstFrameDisplay = "none";
|
|
146
|
+
_this.state = {
|
|
147
|
+
curIndex: _this.groupIndexList.CheckReady()
|
|
148
|
+
};
|
|
149
|
+
return _this;
|
|
150
|
+
}
|
|
151
|
+
Group.prototype.componentDidMount = function () {
|
|
152
|
+
var _this = this;
|
|
153
|
+
// if(this.picBack.style.display == 'none'){
|
|
154
|
+
// setTimeout(()=>{this.picBack.style.display = 'flex';
|
|
155
|
+
// this.closeClick()},300)
|
|
156
|
+
// }
|
|
157
|
+
this.loadDisplay = "hidden";
|
|
158
|
+
if (this.firstFrameDisplay == "none") {
|
|
159
|
+
setTimeout(function () {
|
|
160
|
+
_this.firstFrameDisplay = 'flex';
|
|
161
|
+
_this.closeClick();
|
|
162
|
+
}, 300);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
Group.prototype.componentDidUpdate = function () {
|
|
166
|
+
var _this = this;
|
|
167
|
+
var curIndex = this.state.curIndex;
|
|
168
|
+
setTimeout(function () {
|
|
169
|
+
if (!_this.groupArr[curIndex].isLoadDone) {
|
|
170
|
+
_this.groupArr[curIndex].isLoadDone = true;
|
|
171
|
+
_this.closeClick();
|
|
172
|
+
}
|
|
173
|
+
}, 1000);
|
|
174
|
+
};
|
|
175
|
+
Group.prototype.closeClick = function (e) {
|
|
176
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
177
|
+
var nextIndex = this.groupIndexList.CheckReady();
|
|
178
|
+
// setTimeout(() => {
|
|
179
|
+
// this.loadDisplay = "visible"
|
|
180
|
+
// }, 50);
|
|
181
|
+
this.loadDisplay = "visible";
|
|
182
|
+
this.elseDisplay = "hidden";
|
|
183
|
+
if (nextIndex != -1) {
|
|
184
|
+
if (this.props.settingsitems.ani_switch_type == 2) {
|
|
185
|
+
this.picBack.className = SlapfaceLess.groupBack;
|
|
186
|
+
}
|
|
187
|
+
this.setState({ curIndex: nextIndex });
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
this.props.closeAct();
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
Group.prototype.render = function () {
|
|
194
|
+
var _this = this;
|
|
195
|
+
if (this.state.curIndex == -1) {
|
|
196
|
+
this.setState({ curIndex: this.groupIndexList.CheckReady() });
|
|
197
|
+
}
|
|
198
|
+
return (h("div", { style: { width: '100%', height: '100%', alignItems: 'center', justifyContent: 'center', position: 'absolute' } },
|
|
199
|
+
h("div", { onClick: function () { if (_this.props.settingsitems.is_mask == false)
|
|
200
|
+
return; _this.closeClick(); }, style: { position: "absolute", width: "100%", height: "100%" } }),
|
|
201
|
+
h("div", { ref: function (div) { _this.picBack = div; }, onAnimationEnd: function () { setTimeout(function () { _this.picBack.className = SlapfaceLess.groupBackReverse; }, 0); } },
|
|
202
|
+
h("img", { src: this.groupArr[this.state.curIndex].picture, style: { visibility: this.elseDisplay, width: this.groupArr[this.state.curIndex].width, height: this.groupArr[this.state.curIndex].height }, onLoad: function () { var curIndex = _this.state.curIndex; if (!_this.groupArr[curIndex].isLoadDone) {
|
|
203
|
+
_this.groupArr[curIndex].isLoadDone = true;
|
|
204
|
+
_this.loadDisplay = "hidden";
|
|
205
|
+
_this.elseDisplay = "visible";
|
|
206
|
+
_this.forceUpdate();
|
|
207
|
+
} } }),
|
|
208
|
+
h(CloseButton, { firstFrameDisplay: this.firstFrameDisplay, btn_closeButton: this.props.btn_closeButton, elseDisplay: this.elseDisplay, onClick: function (e) { _this.closeClick(e); } }),
|
|
209
|
+
h(JumpButton, { firstFrameDisplay: this.firstFrameDisplay, elseDisplay: this.elseDisplay, jumpButton: this.props.jumpButton })),
|
|
210
|
+
h("div", { ref: function (div) { _this.loadPic = div; }, className: SlapfaceLess.loading_anim, style: { backgroundImage: "url(".concat(this.props.pic_loading, ")"), width: "300px", height: "300px", position: "absolute", visibility: this.loadDisplay } }, " ")));
|
|
211
|
+
};
|
|
212
|
+
return Group;
|
|
213
|
+
}(Component));
|
|
214
|
+
var CloseButton = /** @class */ (function (_super) {
|
|
215
|
+
__extends(CloseButton, _super);
|
|
216
|
+
function CloseButton() {
|
|
217
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
218
|
+
}
|
|
219
|
+
CloseButton.prototype.render = function () {
|
|
220
|
+
return (h("button", { className: SlapfaceLess.closeButton, style: { display: this.props.firstFrameDisplay, visibility: this.props.elseDisplay, backgroundSize: "contain", backgroundImage: "url(".concat(this.props.btn_closeButton, ")") }, onClick: this.props.onClick }));
|
|
221
|
+
};
|
|
222
|
+
return CloseButton;
|
|
223
|
+
}(Component));
|
|
224
|
+
var JumpButton = /** @class */ (function (_super) {
|
|
225
|
+
__extends(JumpButton, _super);
|
|
226
|
+
function JumpButton() {
|
|
227
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
228
|
+
}
|
|
229
|
+
JumpButton.prototype.render = function () {
|
|
230
|
+
var _this = this;
|
|
231
|
+
return (h("div", { className: SlapfaceLess.jumpButton, style: { display: this.props.firstFrameDisplay, visibility: this.props.elseDisplay }, onMouseDown: function () { _this.jumpbtnImg.src = _this.props.jumpButton.pic_yaxia; }, onMouseUp: function () { _this.jumpbtnImg.src = _this.props.jumpButton.pic_xuanfu; }, onMouseOver: function () { _this.jumpbtnImg.src = _this.props.jumpButton.pic_xuanfu; }, onMouseOut: function () { _this.jumpbtnImg.src = _this.props.jumpButton.pic_changtai; } },
|
|
232
|
+
h("img", { ref: function (img) { _this.jumpbtnImg = img; }, src: this.props.jumpButton.pic_changtai })));
|
|
233
|
+
};
|
|
234
|
+
return JumpButton;
|
|
235
|
+
}(Component));
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Component, h } from 'preact';
|
|
2
|
+
export interface SliderProps {
|
|
3
|
+
percent: number;
|
|
4
|
+
wrapperWidth: number;
|
|
5
|
+
wrapperHeight: number;
|
|
6
|
+
height: number;
|
|
7
|
+
innerHeight?: number;
|
|
8
|
+
dotWidth: number;
|
|
9
|
+
dotHeight: number;
|
|
10
|
+
dotWrapperWidth: number;
|
|
11
|
+
dotWrapperHeight: number;
|
|
12
|
+
outerBg: string;
|
|
13
|
+
innerBg: string;
|
|
14
|
+
dotBg: string;
|
|
15
|
+
onDragStart: Function | null;
|
|
16
|
+
onDrag: Function | null;
|
|
17
|
+
onDragEnd: Function | null;
|
|
18
|
+
isDiscrete: boolean | null;
|
|
19
|
+
discrete?: number;
|
|
20
|
+
maxDiscrete?: number;
|
|
21
|
+
hasIncDecButton: boolean | null;
|
|
22
|
+
incButtonWidth?: number;
|
|
23
|
+
incButtonHeight?: number;
|
|
24
|
+
decButtonWidth?: number;
|
|
25
|
+
decButtonHeight?: number;
|
|
26
|
+
incButtonBg?: string;
|
|
27
|
+
decButtonBg?: string;
|
|
28
|
+
overallWidth?: number;
|
|
29
|
+
onIncClick?: Function | null;
|
|
30
|
+
onDecClick?: Function | null;
|
|
31
|
+
rangeControl?: boolean;
|
|
32
|
+
startRange?: number;
|
|
33
|
+
endRange?: number;
|
|
34
|
+
}
|
|
35
|
+
export declare class Slider extends Component<SliderProps, {
|
|
36
|
+
percent: number;
|
|
37
|
+
}> {
|
|
38
|
+
discrete: number;
|
|
39
|
+
private refWrapper;
|
|
40
|
+
constructor(props: any);
|
|
41
|
+
componentDidMount(): void;
|
|
42
|
+
componentWillReceiveProps(nextProps: any): void;
|
|
43
|
+
onDragStart: (event: any) => void;
|
|
44
|
+
onDrag: (event: any) => void;
|
|
45
|
+
onDragEnd: (event: any) => void;
|
|
46
|
+
onDecClick: () => void;
|
|
47
|
+
onIncClick: () => void;
|
|
48
|
+
computeWrapperStyle: () => void;
|
|
49
|
+
computeOuterStyle: () => void;
|
|
50
|
+
computeInnerStyle: () => void;
|
|
51
|
+
computeDotWrapperStyle: () => void;
|
|
52
|
+
computeDotStyle: () => void;
|
|
53
|
+
computeIncButtonStyle: () => void;
|
|
54
|
+
computeDecButtonStyle: () => void;
|
|
55
|
+
computeWithButtonStyle: () => void;
|
|
56
|
+
render(): h.JSX.Element;
|
|
57
|
+
}
|