@@ -22,7 +22,7 @@ import Lightning from '../Lightning'
22
22
export default class SubtitleComponent extends Lightning . Component {
23
23
static _template ( ) {
24
24
return {
25
- visibility : false ,
25
+ visible : false ,
26
26
rect : true ,
27
27
color : 0x90000000 ,
28
28
shader : { type : Lightning . shaders . RoundedRectangle , radius : 5 } ,
@@ -66,25 +66,43 @@ export default class SubtitleComponent extends Lightning.Component {
66
66
}
67
67
68
68
show ( ) {
69
- this . visibility = true
69
+ this . visible = true
70
70
}
71
71
72
72
hide ( ) {
73
- this . visibilty = false
73
+ this . visible = false
74
74
}
75
75
76
76
position ( ) {
77
77
this . x = this . _calculateX ( this . xPos )
78
78
this . y = this . _calculateY ( this . yPos )
79
79
}
80
80
81
+ set viewportW ( v ) {
82
+ this . _viewportW = v
83
+ this . x = this . _calculateX ( this . xPos )
84
+ }
85
+
86
+ get viewportW ( ) {
87
+ return this . _viewportW || this . application . finalW
88
+ }
89
+
90
+ set viewportH ( v ) {
91
+ this . _viewportH = v
92
+ this . y = this . _calculateY ( this . yPos )
93
+ }
94
+
95
+ get viewportH ( ) {
96
+ return this . _viewportH || this . application . finalH
97
+ }
98
+
81
99
_calculateX ( x ) {
82
100
if ( x === 'center' ) {
83
- x = ( this . application . finalW - this . finalW ) / 2
101
+ x = ( this . viewportW - this . finalW ) / 2
84
102
} else if ( x === 'left' ) {
85
103
x = 60
86
104
} else if ( x === 'right' ) {
87
- x = this . application . finalW - this . finalW - 60
105
+ x = this . viewportW - this . finalW - 60
88
106
}
89
107
return x
90
108
}
@@ -100,11 +118,11 @@ export default class SubtitleComponent extends Lightning.Component {
100
118
101
119
_calculateY ( y ) {
102
120
if ( y === 'center' ) {
103
- return ( this . application . finalH - this . finalH ) / 2
121
+ return ( this . viewportH - this . finalH ) / 2
104
122
} else if ( y === 'top' ) {
105
123
return 60
106
124
} else if ( y === 'bottom' ) {
107
- return this . application . finalH - this . finalH - 60
125
+ return this . viewportH - this . finalH - 60
108
126
}
109
127
return y
110
128
}
@@ -162,9 +180,7 @@ export default class SubtitleComponent extends Lightning.Component {
162
180
163
181
this . tag ( 'Text' ) . text . wordWrapWidth = breakpoint
164
182
this . tag ( 'Text' ) . text = v
165
- setTimeout ( ( ) => {
166
- this . setSmooth ( 'alpha' , 1 , { duration : 0.2 } )
167
- } , 100 )
183
+ this . alpha = 1
168
184
}
169
185
}
170
186
0 commit comments