pixuireactcomponents 1.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.
- package/package.json +11 -0
- package/ui/components/bulletscreen/BulletItemAnimation.tsx +117 -0
- package/ui/components/bulletscreen/BulletScreenAnimation.tsx +278 -0
- package/ui/components/bulletscreen/bullet.less +17 -0
- package/ui/components/dropdown/Dropdown.tsx +115 -0
- package/ui/components/dropdown/DropdownOptionUI.tsx +13 -0
- package/ui/components/dropdown/DropdownSpreadMainUI.tsx +11 -0
- package/ui/components/dropdown/DropdownUnspreadMainUI.tsx +11 -0
- package/ui/components/progress/Progress.tsx +166 -0
- package/ui/components/tab/Tab.tsx +12 -0
- package/ui/components/tab/Tabs.tsx +56 -0
- package/ui/components/videoplayer/VideoPlayer.tsx +200 -0
- package/ui/sample/Images.tsx +34 -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/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/bulletscreen/BulletDemo.tsx +86 -0
- package/ui/sample/dropdown/DropdownDemo.tsx +65 -0
- package/ui/sample/dropdown/MoneyDropdownOption.tsx +49 -0
- package/ui/sample/dropdown/MoneyDropdownSpreadMain.tsx +42 -0
- package/ui/sample/dropdown/MoneyDropdownUnspreadMain.tsx +44 -0
- package/ui/sample/less/video.less +143 -0
- package/ui/sample/progress/ProgressDemo.tsx +74 -0
- package/ui/sample/tab/TabDemo.tsx +67 -0
- package/ui/sample/tab/TopTab.tsx +74 -0
- package/ui/sample/videoplayer/VideoPlayerDemo.tsx +57 -0
- package/utils/EventDispatcherJs.tsx +74 -0
- package/utils/GenerateConstructorAndGeterSeter.js +223 -0
- package/utils/Logger.tsx +158 -0
- package/utils/MakeImage.js +204 -0
- package/utils/img/logger.png +0 -0
- package/utils/img/makeImage.png +0 -0
- package/utils/utils.md +145 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Component, createRef, CSSProperties } from "preact";
|
|
2
|
+
import videoLess from "./../../sample/less/video.less"
|
|
3
|
+
|
|
4
|
+
export interface ProgressProps{
|
|
5
|
+
percent: number, // 0-100,表示0%-100%
|
|
6
|
+
wrapperWidth: number,
|
|
7
|
+
wrapperHeight: number,
|
|
8
|
+
height: number,
|
|
9
|
+
dotWidth: number,
|
|
10
|
+
dotHeight: number,
|
|
11
|
+
dotWrapperWidth: number,
|
|
12
|
+
dotWrapperHeight: number
|
|
13
|
+
|
|
14
|
+
outerBg: string,
|
|
15
|
+
innerBg: string,
|
|
16
|
+
dotBg: string,
|
|
17
|
+
onDragStart: Function | null,
|
|
18
|
+
onDrag: Function | null,
|
|
19
|
+
onDragEnd: Function | null // 拖动结束的事件
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let wrapperStyle: CSSProperties;
|
|
23
|
+
let outerStyle: CSSProperties;
|
|
24
|
+
let innerStyle: CSSProperties;
|
|
25
|
+
let dotStyle: CSSProperties;
|
|
26
|
+
let dotWrapperStyle: CSSProperties;
|
|
27
|
+
|
|
28
|
+
let lastX = undefined;// 上一次位置的横坐标
|
|
29
|
+
let count = 0; // 拖动条距离最左端的位置 [0, this.props.wrapperWidth]
|
|
30
|
+
let rect:any = undefined; // 滑动区域
|
|
31
|
+
|
|
32
|
+
export class Progress extends Component<
|
|
33
|
+
ProgressProps,
|
|
34
|
+
{
|
|
35
|
+
percent: number
|
|
36
|
+
}>{
|
|
37
|
+
|
|
38
|
+
private refWrapper:any = createRef()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
constructor(props){
|
|
42
|
+
super(props)
|
|
43
|
+
|
|
44
|
+
this.state = {
|
|
45
|
+
percent: Math.floor(this.props.percent)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.computeWrapperStyle()
|
|
49
|
+
this.computeOuterStyle()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
componentDidMount(){
|
|
53
|
+
rect = this.refWrapper.current.getBoundingClientRect()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
componentWillReceiveProps(nextProps){
|
|
57
|
+
if(nextProps.percent == this.props.percent) return
|
|
58
|
+
this.setState({
|
|
59
|
+
percent: nextProps.percent
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
onDragStart = (event)=>{
|
|
64
|
+
console.log("【Progress】DragStart event.clientX--"+ event.clientX+"-----percent----"+this.state.percent+"-----currentX----"+(this.state.percent / 100 * this.props.wrapperWidth));
|
|
65
|
+
lastX = event.clentX
|
|
66
|
+
|
|
67
|
+
count = this.state.percent / 100 * this.props.wrapperWidth
|
|
68
|
+
|
|
69
|
+
if(this.props.onDragStart){
|
|
70
|
+
this.props.onDragStart()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
onDrag = (event)=>{
|
|
75
|
+
if(event.clientX < rect.left || event.clientX > rect.right) return
|
|
76
|
+
|
|
77
|
+
if(lastX == undefined){
|
|
78
|
+
lastX = event.clientX
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let move = Number(event.clientX) - Number(lastX)
|
|
83
|
+
count += move
|
|
84
|
+
count = Math.min(this.props.wrapperWidth, count)
|
|
85
|
+
count = Math.max(0, count)
|
|
86
|
+
|
|
87
|
+
let newPercent = count / this.props.wrapperWidth * 100
|
|
88
|
+
this.setState({
|
|
89
|
+
percent: newPercent
|
|
90
|
+
},()=>{
|
|
91
|
+
if(this.props.onDrag) this.props.onDrag(newPercent)
|
|
92
|
+
})
|
|
93
|
+
lastX = event.clientX
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
onDragEnd = (event)=>{
|
|
97
|
+
lastX = undefined
|
|
98
|
+
console.log("【Progress】DragEnd event.clientX--"+ event.clientX+"-----percent----"+this.state.percent+"-----currentX----"+(this.state.percent / 100 * this.props.wrapperWidth));
|
|
99
|
+
if(this.props.onDragEnd){
|
|
100
|
+
this.props.onDragEnd(this.state.percent)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
computeWrapperStyle = ()=>{
|
|
105
|
+
wrapperStyle = {
|
|
106
|
+
width: this.props.wrapperWidth + "px",
|
|
107
|
+
height: this.props.wrapperHeight + "px"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
computeOuterStyle = ()=>{
|
|
112
|
+
outerStyle = {
|
|
113
|
+
width: '100%',
|
|
114
|
+
height: this.props.height + "px",
|
|
115
|
+
backgroundImage: `url(${this.props.outerBg})`,
|
|
116
|
+
backgroundSize: '100% 100%'
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
computeInnerStyle = ()=>{
|
|
121
|
+
let _width = Math.floor(this.state.percent) + "%"
|
|
122
|
+
innerStyle = {
|
|
123
|
+
width: _width,
|
|
124
|
+
height: '100%',
|
|
125
|
+
backgroundImage: `url(${this.props.innerBg})`,
|
|
126
|
+
backgroundSize: '100% 100%'
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
computeDotWrapperStyle = ()=>{
|
|
131
|
+
dotWrapperStyle = {
|
|
132
|
+
position: 'absolute',
|
|
133
|
+
width: this.props.dotWrapperWidth + "px",
|
|
134
|
+
height: this.props.dotWrapperHeight + "px",
|
|
135
|
+
marginTop: (this.props.height - this.props.dotWrapperHeight) / 2 + "px",
|
|
136
|
+
marginLeft: (this.props.wrapperWidth * this.state.percent / 100 - this.props.dotWrapperWidth / 2) + "px",
|
|
137
|
+
// backgroundColor: '#FF000066'
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
computeDotStyle = ()=>{
|
|
142
|
+
dotStyle = {
|
|
143
|
+
width: this.props.dotWidth + "px",
|
|
144
|
+
height: this.props.dotHeight + "px",
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
render(){
|
|
149
|
+
this.computeInnerStyle()
|
|
150
|
+
this.computeDotWrapperStyle()
|
|
151
|
+
this.computeDotStyle()
|
|
152
|
+
|
|
153
|
+
return(
|
|
154
|
+
<div ref={this.refWrapper} style={wrapperStyle} className={videoLess.row_center_center}>
|
|
155
|
+
<div style={outerStyle}>
|
|
156
|
+
<div style={innerStyle}>
|
|
157
|
+
<div style={dotWrapperStyle} className={videoLess.row_center_center} draggable={true}
|
|
158
|
+
onDragStart={this.onDragStart} onDrag={this.onDrag} onDragEnd={this.onDragEnd}>
|
|
159
|
+
<img src={this.props.dotBg} style={dotStyle}/>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Component, CSSProperties } from "preact";
|
|
2
|
+
import { Tab } from "./Tab";
|
|
3
|
+
|
|
4
|
+
export class Tabs extends Component<
|
|
5
|
+
{
|
|
6
|
+
tabBarStyle: CSSProperties,
|
|
7
|
+
onChoose: Function,
|
|
8
|
+
defaultIndex: number | null
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
selectedIndex: number
|
|
12
|
+
}>{
|
|
13
|
+
constructor(props) {
|
|
14
|
+
super(props);
|
|
15
|
+
|
|
16
|
+
let initIndex: number = this.props.defaultIndex == null ? 0 : this.props.defaultIndex
|
|
17
|
+
|
|
18
|
+
this.state = {
|
|
19
|
+
selectedIndex: initIndex
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
SetCurrentIndex = (index: number)=>{
|
|
24
|
+
if(index < 0 || index >= (this.props.children as any).length) return
|
|
25
|
+
this.setState({
|
|
26
|
+
selectedIndex: index
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
render(){
|
|
31
|
+
return(
|
|
32
|
+
<div style={this.props.tabBarStyle}>
|
|
33
|
+
{(this.props.children as any).map((v, index)=>{
|
|
34
|
+
if(v.type != Tab) return v; // 留的口子,方便往Tabs里插入一些东西
|
|
35
|
+
return(
|
|
36
|
+
<div onClick={()=>{
|
|
37
|
+
if (this.state.selectedIndex == index) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.setState(
|
|
41
|
+
{
|
|
42
|
+
selectedIndex: index
|
|
43
|
+
},
|
|
44
|
+
()=>{
|
|
45
|
+
this.props.onChoose(this.state.selectedIndex)
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
}}>
|
|
49
|
+
{v}
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
})}
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { Component, createRef, CSSProperties } from "preact"
|
|
2
|
+
import { Images } from "../../sample/Images"
|
|
3
|
+
import videoLess from "./../../sample/less/video.less"
|
|
4
|
+
|
|
5
|
+
const videoWrapperStyle: CSSProperties = {
|
|
6
|
+
width: '100%',
|
|
7
|
+
height: '100%',
|
|
8
|
+
// backgroundColor: '#FFF00066'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const screenClickerStyle: CSSProperties = {
|
|
12
|
+
position: 'absolute',
|
|
13
|
+
width: '100%',
|
|
14
|
+
height: '100%',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const loadingContainerStyle: CSSProperties = {
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
width: '100%',
|
|
20
|
+
height: '100%',
|
|
21
|
+
backgroundColor: 'rgba(0, 0, 0)',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const controllerBarStyle: CSSProperties = {
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
bottom: '0px',
|
|
27
|
+
height: '80px',
|
|
28
|
+
width: '100%',
|
|
29
|
+
backgroundColor: 'rgba(0, 0, 0, 0.7)'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const playIconStyle: CSSProperties = {
|
|
33
|
+
width: '48px',
|
|
34
|
+
height: '48px',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const reloadIconStyle: CSSProperties = {
|
|
38
|
+
width: '34px',
|
|
39
|
+
height: '34px',
|
|
40
|
+
marginLeft: '40px',
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface VideoPlayerProps{
|
|
44
|
+
playUrl: string,
|
|
45
|
+
onPlaying: Function | null,
|
|
46
|
+
onError: Function | null,
|
|
47
|
+
onNetworkFailed: Function | null,
|
|
48
|
+
onEnded: Function | null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 4个视频播放态
|
|
52
|
+
enum VideoStatus{
|
|
53
|
+
Loading, LoadError, Playing, Pause
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class VideoPlayer extends Component<
|
|
57
|
+
{
|
|
58
|
+
config: VideoPlayerProps
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
showLoadingBar: boolean,
|
|
62
|
+
showBottomBar: boolean,
|
|
63
|
+
videoStatus: VideoStatus
|
|
64
|
+
}>{
|
|
65
|
+
private refVideo:any = createRef()
|
|
66
|
+
private hideTopBottomBarTimer:any = null
|
|
67
|
+
|
|
68
|
+
constructor(props){
|
|
69
|
+
super(props)
|
|
70
|
+
|
|
71
|
+
this.state = {
|
|
72
|
+
showLoadingBar: true,
|
|
73
|
+
showBottomBar: false,
|
|
74
|
+
videoStatus: VideoStatus.Loading
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
componentWillUnmount(){
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
onplaying =()=>{
|
|
82
|
+
// 加载第一帧画面
|
|
83
|
+
console.warn("----------first frame")
|
|
84
|
+
this.setState({
|
|
85
|
+
showLoadingBar: false,
|
|
86
|
+
videoStatus: VideoStatus.Playing
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
onerror = ()=>{
|
|
91
|
+
console.warn("----------onerror")
|
|
92
|
+
// 播放错误,比如给一个无法播放的url
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
onnetworkfailed = ()=>{
|
|
96
|
+
console.warn("----------onnetworkfailed")
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
onended = ()=>{
|
|
101
|
+
// 视频播放结束
|
|
102
|
+
console.warn("-----------end")
|
|
103
|
+
this.refVideo.current.load()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
onScreenClick = ()=>{
|
|
107
|
+
if(this.state.showBottomBar){ // 当前已显示bottomBar
|
|
108
|
+
this.clearHideBottomBarTimer()
|
|
109
|
+
this.setState({
|
|
110
|
+
showBottomBar: false
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
else{ // 当前未显示bottomBar
|
|
114
|
+
this.setState({
|
|
115
|
+
showBottomBar: true
|
|
116
|
+
}, this.setHideBottomBarTimer)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// 3秒钟自动隐藏TopBar BottomBar
|
|
121
|
+
setHideBottomBarTimer = ()=>{
|
|
122
|
+
this.clearHideBottomBarTimer()
|
|
123
|
+
|
|
124
|
+
let outThis = this
|
|
125
|
+
this.hideTopBottomBarTimer = setTimeout(function() {
|
|
126
|
+
outThis.setState({
|
|
127
|
+
showBottomBar: false
|
|
128
|
+
})
|
|
129
|
+
}, 3000)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// 清理3秒隐藏TopBar BottomBar的计时器
|
|
133
|
+
clearHideBottomBarTimer = ()=>{
|
|
134
|
+
if(this.hideTopBottomBarTimer != null){
|
|
135
|
+
clearTimeout(this.hideTopBottomBarTimer)
|
|
136
|
+
this.hideTopBottomBarTimer = null
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
switchPlayState = ()=>{
|
|
141
|
+
if(this.state.videoStatus == VideoStatus.Playing){
|
|
142
|
+
this.onPause()
|
|
143
|
+
}
|
|
144
|
+
else if(this.state.videoStatus == VideoStatus.Pause){
|
|
145
|
+
this.onPlay()
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
onPause = ()=>{
|
|
150
|
+
this.refVideo.current.pause()
|
|
151
|
+
this.setState({
|
|
152
|
+
videoStatus: VideoStatus.Pause
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
onPlay = ()=>{
|
|
157
|
+
this.refVideo.current.play()
|
|
158
|
+
|
|
159
|
+
this.setState({
|
|
160
|
+
videoStatus: VideoStatus.Playing
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
reloadVideo = ()=>{
|
|
165
|
+
this.refVideo.current.load()
|
|
166
|
+
this.setState({
|
|
167
|
+
videoStatus: VideoStatus.Loading,
|
|
168
|
+
showLoadingBar: true,
|
|
169
|
+
showBottomBar: false
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
render(){
|
|
174
|
+
let playIconUrl = this.state.videoStatus == VideoStatus.Playing ? Images.video_pause : Images.video_play;
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<div style={videoWrapperStyle}>
|
|
179
|
+
<video ref={this.refVideo} src={this.props.config.playUrl} object-fit="no" autoPlay="autoplay" muted
|
|
180
|
+
style={{width:'100%', height:'100%'}}
|
|
181
|
+
onplaying={this.onplaying} onerror={this.onerror}
|
|
182
|
+
onnetworkfailed={this.onnetworkfailed} onended={this.onended}>
|
|
183
|
+
</video>
|
|
184
|
+
<div style={screenClickerStyle} onClick={this.onScreenClick}></div>
|
|
185
|
+
{ this.state.showLoadingBar ?
|
|
186
|
+
<div style={loadingContainerStyle} className ={videoLess.row_center_center}>
|
|
187
|
+
<img src={Images.loading} style={{witdh: '42px', height: '42px'}} className={videoLess.loading_anim} />
|
|
188
|
+
</div> : null
|
|
189
|
+
}
|
|
190
|
+
{this.state.showBottomBar ?
|
|
191
|
+
<div style={controllerBarStyle}>
|
|
192
|
+
<div style={{height: '100%', marginLeft: '40px', flexGrow: 2}} className={videoLess.row_start_center}>
|
|
193
|
+
<img src={playIconUrl} style={playIconStyle} onClick={this.switchPlayState}/>
|
|
194
|
+
<img src={Images.video_reload} style={reloadIconStyle} onClick={this.reloadVideo}/>
|
|
195
|
+
</div>
|
|
196
|
+
</div> : null}
|
|
197
|
+
</div>
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import data_arrow_down from "./asset/data_arrow_down.png";
|
|
2
|
+
import data_arrow_up from "./asset/data_arrow_up.png";
|
|
3
|
+
import dot from "./asset/dot.png";
|
|
4
|
+
import inner from "./asset/inner.png";
|
|
5
|
+
import item_reddot from "./asset/item_reddot.png";
|
|
6
|
+
import loading from "./asset/loading.png";
|
|
7
|
+
import money_dropdown from "./asset/money_dropdown.png";
|
|
8
|
+
import money_dropdownall from "./asset/money_dropdownall.png";
|
|
9
|
+
import outer from "./asset/outer.png";
|
|
10
|
+
import tab_choosed from "./asset/tab_choosed.png";
|
|
11
|
+
import tabs_bg from "./asset/tabs_bg.png";
|
|
12
|
+
import video_pause from "./asset/video_pause.png";
|
|
13
|
+
import video_play from "./asset/video_play.png";
|
|
14
|
+
import video_reload from "./asset/video_reload.png";
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export const Images = {
|
|
19
|
+
data_arrow_down: data_arrow_down,
|
|
20
|
+
data_arrow_up: data_arrow_up,
|
|
21
|
+
dot: dot,
|
|
22
|
+
inner: inner,
|
|
23
|
+
item_reddot: item_reddot,
|
|
24
|
+
loading: loading,
|
|
25
|
+
money_dropdown: money_dropdown,
|
|
26
|
+
money_dropdownall: money_dropdownall,
|
|
27
|
+
outer: outer,
|
|
28
|
+
tab_choosed: tab_choosed,
|
|
29
|
+
tabs_bg: tabs_bg,
|
|
30
|
+
video_pause: video_pause,
|
|
31
|
+
video_play: video_play,
|
|
32
|
+
video_reload: video_reload,
|
|
33
|
+
}
|
|
34
|
+
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createRef } from "lib/preact/src/create-element";
|
|
2
|
+
import { h } from "preact";
|
|
3
|
+
import { Component, CSSProperties} from "preact";
|
|
4
|
+
import { BulletScreenAnimation, BulletScreenAnimationData } from "../../components/bulletscreen/BulletScreenAnimation";
|
|
5
|
+
|
|
6
|
+
let rootStyle: CSSProperties = {
|
|
7
|
+
width: '100%',
|
|
8
|
+
height: '750px',
|
|
9
|
+
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexDirection: 'row',
|
|
12
|
+
justifyContent: 'center',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
|
|
15
|
+
backgroundColor: '#FF000055'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let bulletScreenConfigData: BulletScreenAnimationData = {
|
|
19
|
+
generateCycle: 200,
|
|
20
|
+
channelHeight: 50,
|
|
21
|
+
screenWidth: 0,
|
|
22
|
+
screenHeight: 0,
|
|
23
|
+
totalTime: 8000
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let GetBulletData = (function(){
|
|
27
|
+
let _NUM = 1
|
|
28
|
+
return function(){
|
|
29
|
+
console.log("测试弹幕1")
|
|
30
|
+
return "测试弹幕" + _NUM++
|
|
31
|
+
}
|
|
32
|
+
}())
|
|
33
|
+
|
|
34
|
+
export class BulletDemo extends Component<
|
|
35
|
+
any,
|
|
36
|
+
{
|
|
37
|
+
screenWidth: number,
|
|
38
|
+
screenHeight: number
|
|
39
|
+
}>{
|
|
40
|
+
constructor(props){
|
|
41
|
+
super(props)
|
|
42
|
+
|
|
43
|
+
this.state = {
|
|
44
|
+
screenWidth: 0,
|
|
45
|
+
screenHeight: 0
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private refRoot = createRef()
|
|
50
|
+
private refBulletScreen = createRef()
|
|
51
|
+
|
|
52
|
+
componentDidMount(){
|
|
53
|
+
let _width = this.getRootComputedSize("width")
|
|
54
|
+
let _height = this.getRootComputedSize("height")
|
|
55
|
+
console.warn(_width, "___", _height)
|
|
56
|
+
|
|
57
|
+
this.setState({
|
|
58
|
+
screenWidth: _width,
|
|
59
|
+
screenHeight: _height
|
|
60
|
+
}, ()=>{
|
|
61
|
+
this.refBulletScreen.current.StartRunBullets()
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
getRootComputedSize = (key: string)=>{
|
|
66
|
+
if(key == "" || key == undefined) return undefined
|
|
67
|
+
|
|
68
|
+
let realWidthStr = window.getComputedStyle(this.refRoot.current, null).getPropertyValue(key);
|
|
69
|
+
let widthNum = parseInt(realWidthStr.substring(0, realWidthStr.length - 2));
|
|
70
|
+
|
|
71
|
+
return widthNum
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
render(){
|
|
75
|
+
console.warn("[[render]]---)))")
|
|
76
|
+
bulletScreenConfigData.screenWidth = this.state.screenWidth
|
|
77
|
+
bulletScreenConfigData.screenHeight = this.state.screenHeight
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div ref={this.refRoot} style = {rootStyle}>
|
|
81
|
+
<BulletScreenAnimation screenWidth={this.state.screenWidth} screenHeight={this.state.screenHeight} ref={this.refBulletScreen} isRun={true} screenData={bulletScreenConfigData} getBulletText={GetBulletData}/>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Component, CSSProperties } from "preact"
|
|
2
|
+
import { Dropdown, DropdownConfig } from "../../components/dropdown/Dropdown"
|
|
3
|
+
import { Images } from "../Images"
|
|
4
|
+
import { MoneyDropdownOption } from "./MoneyDropdownOption"
|
|
5
|
+
import { MoneyDropdownSpreadMain } from "./MoneyDropdownSpreadMain"
|
|
6
|
+
import { MoneyDropdownUnspreadMain } from "./MoneyDropdownUnspreadMain"
|
|
7
|
+
|
|
8
|
+
const dropdownAreaStyle:CSSProperties = {
|
|
9
|
+
position: 'absolute',
|
|
10
|
+
top: '0px',
|
|
11
|
+
right: '17px',
|
|
12
|
+
width: '98px',
|
|
13
|
+
height: '40px',
|
|
14
|
+
// backgroundColor: '#FF00FF33',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const TYPES: string[] = ["团队", "单人路", "打野", "中路", "射手", "辅助"]
|
|
18
|
+
|
|
19
|
+
export class DropdownDemo extends Component<any,any>{
|
|
20
|
+
constructor(props){
|
|
21
|
+
super(props)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
onChoose = ()=>{
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
render(){
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// dropdown展开的样式
|
|
32
|
+
const _spreadStyle:CSSProperties = {
|
|
33
|
+
position: 'absolute',
|
|
34
|
+
display: 'flex',
|
|
35
|
+
flexDirection: 'column',
|
|
36
|
+
justifyContent: 'flex-start',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
borderImage: `url(${Images.money_dropdownall}) 45 10 10 10`,
|
|
39
|
+
width:'98px',
|
|
40
|
+
height:'182px',
|
|
41
|
+
top:"4px",
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let _config: DropdownConfig<string> = {
|
|
45
|
+
spreadStyle: _spreadStyle,
|
|
46
|
+
datas: TYPES,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let _options:MoneyDropdownOption[] = Array(TYPES.length).fill("").map((value, index)=>{
|
|
50
|
+
return <MoneyDropdownOption index={index} info={TYPES[index]}/>
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div style={dropdownAreaStyle}>
|
|
55
|
+
<Dropdown<string, MoneyDropdownUnspreadMain, MoneyDropdownSpreadMain, MoneyDropdownOption>
|
|
56
|
+
config={_config}
|
|
57
|
+
onChoose={this.onChoose}
|
|
58
|
+
unspreadMainUI={<MoneyDropdownUnspreadMain/>}
|
|
59
|
+
spreadMainUI={<MoneyDropdownSpreadMain/>}
|
|
60
|
+
optionsUI={_options}
|
|
61
|
+
defaultIndex={this.state.selectedType}/>
|
|
62
|
+
</div>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
}
|