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.
Files changed (104) hide show
  1. package/index.d.ts +15 -0
  2. package/index.js +16 -20
  3. package/package.json +9 -9
  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 +5 -0
  9. package/ui/components/button/Button.js +37 -0
  10. package/ui/components/carousel/Carousel.d.ts +5 -0
  11. package/ui/components/carousel/Carousel.js +219 -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.tsx → GradientText.js} +174 -183
  22. package/ui/components/outlinetext/OutlineText.d.ts +94 -0
  23. package/ui/components/outlinetext/OutlineText.js +168 -0
  24. package/ui/components/progress/Progress.d.ts +34 -0
  25. package/ui/components/progress/Progress.js +142 -0
  26. package/ui/components/slapface/Slapface.d.ts +12 -0
  27. package/ui/components/slapface/Slapface.js +235 -0
  28. package/ui/components/slider/Slider.d.ts +57 -0
  29. package/ui/components/slider/Slider.js +289 -0
  30. package/ui/components/tab/Tab.d.ts +6 -0
  31. package/ui/components/tab/Tab.js +27 -0
  32. package/ui/components/tab/Tabs.d.ts +12 -0
  33. package/ui/components/tab/Tabs.js +54 -0
  34. package/cmdAfterTsBuild.js +0 -8
  35. package/tools/EventDispatcherJs.tsx +0 -74
  36. package/tools/Logger.tsx +0 -161
  37. package/tools/img/logger.png +0 -0
  38. package/tsconfig.json +0 -45
  39. package/ui/components/bulletscreen/BulletItemAnimation.tsx +0 -117
  40. package/ui/components/bulletscreen/BulletScreenAnimation.tsx +0 -278
  41. package/ui/components/bulletscreen/bullet.less +0 -17
  42. package/ui/components/button/Button.tsx +0 -18
  43. package/ui/components/carousel/Carousel.tsx +0 -279
  44. package/ui/components/checkBox/CheckBox.tsx +0 -40
  45. package/ui/components/dropdown/Dropdown.tsx +0 -126
  46. package/ui/components/dropdown/DropdownOptionUI.tsx +0 -14
  47. package/ui/components/dropdown/DropdownSpreadMainUI.tsx +0 -11
  48. package/ui/components/dropdown/DropdownUnspreadMainUI.tsx +0 -11
  49. package/ui/components/outlinetext/OutlineText.tsx +0 -184
  50. package/ui/components/progress/Progress.tsx +0 -174
  51. package/ui/components/slapface/Slapface.tsx +0 -284
  52. package/ui/components/slider/Slider.tsx +0 -366
  53. package/ui/components/tab/Tab.tsx +0 -12
  54. package/ui/components/tab/Tabs.tsx +0 -56
  55. package/ui/components/togglegroup/ToggleGroup.tsx +0 -105
  56. package/ui/components/videoplayer/VideoPlayer.tsx +0 -200
  57. package/ui/components/waterfallcomponent/WaterfallComponent.jsx +0 -687
  58. package/ui/components/waterfallcomponent/less/WaterfallComponent.less +0 -13
  59. package/ui/sample/Images.tsx +0 -60
  60. package/ui/sample/OutlineText/OutlineDemo.tsx +0 -61
  61. package/ui/sample/Slapface/SlapfaceDemo.tsx +0 -30
  62. package/ui/sample/asset/btn_close.png +0 -0
  63. package/ui/sample/asset/changtai_button.jpg +0 -0
  64. package/ui/sample/asset/checkbox0.png +0 -0
  65. package/ui/sample/asset/checkbox1.png +0 -0
  66. package/ui/sample/asset/data_arrow_down.png +0 -0
  67. package/ui/sample/asset/data_arrow_up.png +0 -0
  68. package/ui/sample/asset/dot.png +0 -0
  69. package/ui/sample/asset/inner.png +0 -0
  70. package/ui/sample/asset/item_reddot.png +0 -0
  71. package/ui/sample/asset/loading.png +0 -0
  72. package/ui/sample/asset/money_dropdown.png +0 -0
  73. package/ui/sample/asset/money_dropdownall.png +0 -0
  74. package/ui/sample/asset/outer.png +0 -0
  75. package/ui/sample/asset/slapface_samplepic1.png +0 -0
  76. package/ui/sample/asset/slapface_samplepic2.png +0 -0
  77. package/ui/sample/asset/slapface_samplepic3.png +0 -0
  78. package/ui/sample/asset/slapface_samplepic4.png +0 -0
  79. package/ui/sample/asset/slapface_samplepic5.png +0 -0
  80. package/ui/sample/asset/slapface_samplepic6.png +0 -0
  81. package/ui/sample/asset/tab_choosed.png +0 -0
  82. package/ui/sample/asset/tabs_bg.png +0 -0
  83. package/ui/sample/asset/video_pause.png +0 -0
  84. package/ui/sample/asset/video_play.png +0 -0
  85. package/ui/sample/asset/video_reload.png +0 -0
  86. package/ui/sample/asset/xuanfu_button.jpg +0 -0
  87. package/ui/sample/asset/yaxia_button.jpg +0 -0
  88. package/ui/sample/bulletscreen/BulletDemo.tsx +0 -84
  89. package/ui/sample/button/ButtonDemo.tsx +0 -19
  90. package/ui/sample/carousel/carouselDemo.tsx +0 -52
  91. package/ui/sample/checkBox/checkBoxDemo.tsx +0 -7
  92. package/ui/sample/dropdown/DropdownDemo.tsx +0 -65
  93. package/ui/sample/dropdown/MoneyDropdownOption.tsx +0 -50
  94. package/ui/sample/dropdown/MoneyDropdownSpreadMain.tsx +0 -42
  95. package/ui/sample/dropdown/MoneyDropdownUnspreadMain.tsx +0 -44
  96. package/ui/sample/gradient/GradientDemo.tsx +0 -51
  97. package/ui/sample/less/video.less +0 -144
  98. package/ui/sample/progress/ProgressDemo.tsx +0 -74
  99. package/ui/sample/slider/SliderDemo.tsx +0 -116
  100. package/ui/sample/tab/TabDemo.tsx +0 -67
  101. package/ui/sample/tab/TopTab.tsx +0 -74
  102. package/ui/sample/togglegroup/ToggleGroupDemo.tsx +0 -35
  103. package/ui/sample/videoplayer/VideoPlayerDemo.tsx +0 -57
  104. package/ui/sample/waterfallcomponent/WaterfallComponentDemo.jsx +0 -137
@@ -1,117 +0,0 @@
1
- import { createRef } from 'lib/preact/src/create-element';
2
- import { Component, CSSProperties } from 'preact';
3
-
4
- // 弹幕相关个性化信息
5
- export class BulletInfo {
6
- key: number;
7
- text: string;
8
- channel: number;
9
- color: string;
10
- fontSize: number;
11
-
12
- constructor(
13
- key: number,
14
- text: string,
15
- channel: number,
16
- color: string,
17
- fontSize: number
18
- ) {
19
- this.key = key;
20
- this.text = text;
21
- this.channel = channel;
22
- this.color = color;
23
- this.fontSize = fontSize;
24
- }
25
- }
26
-
27
- // 同一行弹幕的间距
28
- const BULLET_DISTANCE = 50;
29
- // 弹幕超出屏幕后滑行距离
30
- const BULLET_MAX_LEN = 400;
31
-
32
- // 弹幕相关配置信息
33
- export class BulletConfig {
34
- screenWidth: number; //弹幕宽度
35
- channelHeight: number; //弹幕高度
36
- totalTime: number; //单条弹幕滑行时间
37
-
38
- constructor(
39
- screenWidth: number,
40
- channelHeight: number,
41
- totalTime: number
42
- ) {
43
- this.screenWidth = screenWidth;
44
- this.channelHeight = channelHeight;
45
- this.totalTime = totalTime;
46
- }
47
- }
48
-
49
- // 使用Animation
50
- export class BulletItemAnimation extends Component<
51
- {
52
- bulletInfo: BulletInfo;
53
- bulletConfig: BulletConfig;
54
- onItemFree: Function;
55
- onChannelFree: Function;
56
- }, {}>{
57
-
58
- private freeChannelTimer: any = undefined;
59
- private refText = createRef()
60
-
61
- constructor(props) {
62
- super(props);
63
- }
64
-
65
- componentDidMount() {
66
- this.refText.current.addEventListener('animationstart', this.onAnimationStart);
67
- this.refText.current.addEventListener('animationend', this.onAnimationEnd);
68
-
69
- window.requestAnimationFrame(this.setFreeChannelTimer);
70
- }
71
-
72
- onAnimationStart = () => {
73
- }
74
-
75
- onAnimationEnd = () => {
76
- this.props.onItemFree();
77
- }
78
-
79
- setFreeChannelTimer = () => {
80
- let realWidthStr = window.getComputedStyle(this.refText.current, null).getPropertyValue('width');
81
- let widthNum = parseInt(realWidthStr.substring(0, realWidthStr.length - 2));
82
- this.freeChannelTimer = setTimeout(this.freeChannel, (widthNum + BULLET_DISTANCE) / (this.props.bulletConfig.screenWidth + BULLET_MAX_LEN) * this.props.bulletConfig.totalTime);
83
- }
84
-
85
- freeChannel = () => {
86
- this.props.onChannelFree(this.props.bulletInfo.channel);
87
- clearTimeout(this.freeChannelTimer);
88
- }
89
-
90
- render() {
91
-
92
- let isMe = false;
93
-
94
- const bulletStyle: CSSProperties = {
95
- marginTop: (this.props.bulletInfo.channel * this.props.bulletConfig.channelHeight) + 'px',
96
- height: this.props.bulletConfig.channelHeight + 'px',
97
- left: this.props.bulletConfig.screenWidth + 'px',
98
- animation: 'bulletKeyframe 10s linear 1',
99
-
100
- position: 'absolute',
101
- display: 'flex',
102
- flexDirection: 'row',
103
- justifyContent: 'flex-start',
104
- alignItems: 'center',
105
- border: isMe ? '1px solid ' + this.props.bulletInfo.color : '',
106
-
107
- fontSize: this.props.bulletInfo.fontSize + 'px', //'16px',
108
- color: this.props.bulletInfo.color,
109
- };
110
-
111
- return (
112
- <div ref={this.refText} style={bulletStyle}>
113
- <text>{this.props.bulletInfo.text}</text>
114
- </div>
115
- );
116
- }
117
- }
@@ -1,278 +0,0 @@
1
- /* eslint-disable linebreak-style */
2
- import { Component, CSSProperties } from 'preact';
3
- import { BulletInfo, BulletConfig, BulletItemAnimation } from './BulletItemAnimation';
4
- import { Logger } from './../../../tools/Logger';
5
- // item数据类型
6
- // {
7
- // key : number,
8
- // value : '人闲桂花落', string
9
- // channel : number
10
- // }
11
- let bulletDataList: Array<BulletInfo> = [];
12
-
13
- // 弹幕组件相关初始化信息
14
- export class BulletScreenAnimationData {
15
- generateCycle: number; //弹幕生成的周期
16
- channelHeight: number; //每行弹幕的高度
17
- screenWidth: number; //弹幕区域宽度
18
- screenHeight: number; //弹幕区域高度
19
- totalTime: number; //单条弹幕的滑行时间 单位ms
20
-
21
- constructor(
22
- generateCycle: number,
23
- channelHeight: number,
24
- screenWidth: number,
25
- screenHeight: number,
26
- totalTime: number
27
- ) {
28
- this.generateCycle = generateCycle;
29
- this.channelHeight = channelHeight;
30
- this.screenWidth = screenWidth;
31
- this.screenHeight = screenHeight;
32
- this.totalTime = totalTime;
33
- }
34
- }
35
-
36
-
37
- // 使用Animaiton
38
- export class BulletScreenAnimation extends Component<
39
- {
40
- screenData: BulletScreenAnimationData;
41
- getBulletText: Function;
42
- isRun: boolean; //暂停生产弹幕,
43
- screenWidth: number;
44
- screenHeight: number;
45
- },
46
- {
47
- refreshIndex: number;
48
- }>{
49
-
50
- private positionSize = 0;
51
- private hasPosition: Array<boolean> = [];
52
-
53
- private bulletIndex = 0;
54
- private consumeBulletTimer: any = undefined;
55
- private isStart = false; //弹幕是否开始播放
56
- private isScreenSizeChanging = false; // 弹幕屏幕尺寸是否在改变中
57
-
58
- constructor(props) {
59
- super(props);
60
- this.setState({
61
- refreshIndex: 0
62
- });
63
-
64
- this.initChannels();
65
-
66
- this.consumeBulletTimer = setInterval(() => {
67
- let curChannel = -1;
68
- if ((curChannel = this.getChannel()) != -1) {
69
- if (!this.isStart) return;
70
- if (this.isScreenSizeChanging) return;
71
-
72
- let bulletText = this.props.getBulletText();
73
- if (bulletText == undefined) return; //没有弹幕
74
-
75
- if (!this.props.isRun) return; //弹幕开关关闭
76
-
77
- bulletDataList.push(this.generateNewBulletInfo(bulletText, curChannel));
78
- this.hasPosition[curChannel] = false;
79
-
80
- let newIndex = this.state.refreshIndex + 1;
81
- this.setState({
82
- refreshIndex: newIndex
83
- });
84
-
85
- }
86
- }, this.props.screenData.generateCycle);
87
- }
88
-
89
- generateNewBulletInfo = (text, channel) => {
90
- let _fontSize = 20;
91
- let _transparencyPercent = 0;
92
- // console.warn("_________________fontSize:", _fontSize)
93
- let _color = `rgba(255,255,255,${1 - _transparencyPercent / 100})`;
94
- return new BulletInfo(this.bulletIndex++, text, channel, _color, _fontSize);
95
- }
96
-
97
- componentWillUnmount() {
98
- if (this.consumeBulletTimer != undefined) {
99
- clearInterval(this.consumeBulletTimer);
100
- this.consumeBulletTimer = undefined;
101
- }
102
- }
103
-
104
- // 首字母大写表示可供外部调用
105
- // 开始播放弹幕
106
- StartRunBullets = () => {
107
- this.isStart = true;
108
- }
109
-
110
- // 停止播放弹幕
111
- StopRunBullets = () => {
112
- this.isStart = false;
113
- }
114
-
115
- // 清空屏幕上的弹幕
116
- ClearScreenBullets = () => {
117
- bulletDataList = [];
118
- this.initChannels();
119
-
120
- let newIndex = this.state.refreshIndex + 1;
121
- this.setState({
122
- refreshIndex: newIndex
123
- });
124
- }
125
-
126
- SetScreenSizeChanging = () => {
127
- this.isScreenSizeChanging = true;
128
- }
129
-
130
- setScreenSizeChanged = () => {
131
- this.isScreenSizeChanging = false;
132
- }
133
-
134
- componentWillReceiveProps(nextProps) {
135
- // Logger.ObjectPrinter(nextProps, "# nextProps #")
136
- if (this.isScreenSizeSame(this.props, nextProps)) return;
137
-
138
- console.log('ScreenSizeChanged, generate new Animation!!!============');
139
- Logger.ObjectPrinter(nextProps, '# nextProps #');
140
-
141
- this.generateTargetAnimation(nextProps);
142
- this.initChannels(nextProps);
143
- this.setScreenSizeChanged();
144
- }
145
-
146
- generateTargetAnimation = (currentProps) => {
147
- this.generateDynamicAnimation('bulletKeyframe',
148
- `from{
149
- left: ${currentProps.screenWidth}px
150
- }
151
- to{
152
- left: -400px;
153
- }`
154
- );
155
- }
156
-
157
- isScreenSizeSame = (oldProps, newProps) => {
158
- if (oldProps.screenWidth == newProps.screenWidth &&
159
- oldProps.screenHeight == newProps.screenHeight) {
160
- return true;
161
- }
162
- return false;
163
- }
164
-
165
- generateDynamicAnimation = (name, styles) => {
166
- console.log('&&&&&&&&&&&&&&&&&&&&&&=====================================');
167
-
168
- let css = `@keyframes ${name}{${styles}}`;
169
- let head = document.getElementsByTagName('head')[0];
170
- let style: any = document.createElement('style');
171
- style.type = 'text/css';
172
- if (style.styleSheet) {
173
- style.styleSheet.cssText = css;
174
- } else {
175
- style.appendChild(document.createTextNode(css));
176
- }
177
- head.appendChild(style);
178
- }
179
-
180
- initChannels(currentProps = this.props) {
181
- this.positionSize = Math.floor(currentProps.screenHeight / currentProps.screenData.channelHeight);
182
- this.hasPosition = [];
183
-
184
- //初始化 所有信道当前可用;每个信道都有一个缓存池;
185
- for (let index = 0; index < this.positionSize; index++) {
186
- this.hasPosition[index] = true;
187
- }
188
- console.warn('position:', this.hasPosition.length);
189
- }
190
-
191
- //先尝试随机取3次位置,取不到可用位置就从头开始遍历位置
192
- getChannel = () => {
193
- let tryCount = 3;
194
-
195
- while (tryCount > 0) {
196
- let channel = this.getRandomChannelByPosition();
197
- if (this.hasPosition[channel]) {
198
- return channel;
199
- }
200
- tryCount--;
201
- }
202
-
203
- return this.getAvailableChannelByPosition();
204
- }
205
-
206
- getRandomChannelByPosition = () => {
207
- // 根据position 配置,决定随机的位置
208
- let _random;
209
- // if(Settings.bulletSettings.position == BulletPositon.TopHalf){
210
- // let _topHalfsize = Math.floor(this.positionSize / 2)
211
- // _random = Math.random() * _topHalfsize
212
- // }
213
- // else if(Settings.bulletSettings.position == BulletPositon.BottomHalf){
214
- // let _topHalfsize = Math.floor(this.positionSize / 2)
215
- // _random = Math.random() * (this.positionSize - _topHalfsize) + _topHalfsize
216
- // }
217
- // else{ //Settings.bulletSettings.position == BulletPositon.Full
218
- _random = Math.random() * this.positionSize;
219
- // }
220
-
221
- return Math.floor(_random);
222
- }
223
-
224
- getAvailableChannelByPosition = () => {
225
- let start, end; //闭区间
226
- // if(Settings.bulletSettings.position == BulletPositon.TopHalf){
227
- // let _topHalfsize = Math.floor(this.positionSize / 2)
228
- // start = 0
229
- // end = _topHalfsize - 1
230
- // }
231
- // else if(Settings.bulletSettings.position == BulletPositon.BottomHalf){
232
- // let _topHalfsize = Math.floor(this.positionSize / 2)
233
- // start = _topHalfsize
234
- // end = this.positionSize - 1
235
- // }
236
- // else{ //Settings.bulletSettings.position == BulletPositon.Full
237
- start = 0;
238
- end = this.positionSize - 1;
239
- // }
240
-
241
- for (let index = start; index <= end; index++) {
242
- if (this.hasPosition[index]) {
243
- return index;
244
- }
245
- }
246
-
247
- return -1;
248
- }
249
-
250
- onItemFree = () => {
251
- bulletDataList.shift();
252
- }
253
-
254
- onChannelFree = (channel) => {
255
- this.hasPosition[channel] = true;
256
- }
257
-
258
- render() {
259
- let container: CSSProperties = {
260
- width: this.props.screenWidth + 'px',
261
- height: this.props.screenHeight + 'px',
262
- position: 'absolute',
263
- overflow: 'hidden',
264
- // backgroundColor: '#00FFFF66'
265
- };
266
-
267
- let screenData = this.props.screenData;
268
- let commonInfo = new BulletConfig(this.props.screenWidth, screenData.channelHeight, screenData.totalTime);
269
-
270
- return (
271
- <div style={container}>
272
- {bulletDataList.map((value, index) => {
273
- return (<BulletItemAnimation key={value.key} bulletInfo={value} bulletConfig={commonInfo}
274
- onItemFree={this.onItemFree} onChannelFree={this.onChannelFree} />);
275
- })}
276
- </div>);
277
- }
278
- }
@@ -1,17 +0,0 @@
1
- .bullet_animation{
2
- animation-name: barrage;
3
- animation-duration: 10s;
4
- animation-timing-function: linear;
5
- animation-iteration-count: 1
6
- // background-color: aqua;
7
- }
8
-
9
- @keyframes barrage{
10
- from{
11
- left: 1334px
12
- }
13
-
14
- to{
15
- left: -400px;
16
- }
17
- }
@@ -1,18 +0,0 @@
1
- import { h, Component, CSSProperties } from "preact";
2
-
3
- export class Button extends Component<any, any>
4
- {
5
- private btnImg
6
- render(props) {
7
- return (
8
- <div
9
- onClick = {()=>{ if(this.props.clickEvent){if(this.props.clickArr) this.props.clickEvent(...props.clickArr); else this.props.clickEvent()}}}
10
- onMouseDown={() => {(this.btnImg as HTMLImageElement).src = this.props.pic_yaxia }}
11
- onMouseUp={() => { (this.btnImg as HTMLImageElement).src = this.props.pic_xuanfu }}
12
- onMouseOver={() => { (this.btnImg as HTMLImageElement).src = this.props.pic_xuanfu; }}
13
- onMouseOut={() => { (this.btnImg as HTMLImageElement).src = this.props.pic_changtai; }}>
14
- <img ref = {(img)=>{this.btnImg = img}} src={this.props.pic_changtai}></img>
15
- </div>
16
- )
17
- }
18
- }