@mixd-id/web-scaffold 0.1.230406216 → 0.1.230406217
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
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div :class="$style.comp" :style="computedStyle">
|
|
3
3
|
<div :class="videoClass" class="absolute top-0 left-0 right-0 bottom-0 z-10"
|
|
4
4
|
:style="{ opacity:ready ? 1 : 0 }">
|
|
5
|
-
<div id="
|
|
5
|
+
<div :id="id"></div>
|
|
6
6
|
</div>
|
|
7
7
|
<div :class="videoClass" class="relative flex items-center justify-center"
|
|
8
8
|
:style="thumbnailStyle">
|
|
@@ -20,6 +20,27 @@
|
|
|
20
20
|
|
|
21
21
|
import { componentMixin } from '../mixin/component'
|
|
22
22
|
|
|
23
|
+
const callbacks = []
|
|
24
|
+
const initScript = (callback, id) => {
|
|
25
|
+
|
|
26
|
+
callbacks.push([ callback, id ])
|
|
27
|
+
|
|
28
|
+
let script = document.getElementById('youtube-iframe-api')
|
|
29
|
+
if(!script){
|
|
30
|
+
const script = document.createElement('script')
|
|
31
|
+
script.src = 'https://www.youtube.com/iframe_api'
|
|
32
|
+
script.id = 'youtube-iframe-api'
|
|
33
|
+
document.head.appendChild(script)
|
|
34
|
+
|
|
35
|
+
window.onYouTubeIframeAPIReady = () => {
|
|
36
|
+
while(callbacks.length > 0){
|
|
37
|
+
const [ callback, id ] = callbacks.pop()
|
|
38
|
+
callback()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
23
44
|
export default{
|
|
24
45
|
|
|
25
46
|
mixins: [ componentMixin ],
|
|
@@ -29,7 +50,7 @@ export default{
|
|
|
29
50
|
videoId: String,
|
|
30
51
|
|
|
31
52
|
delay: {
|
|
32
|
-
type: Number,
|
|
53
|
+
type: [ Number, String ],
|
|
33
54
|
default: 0
|
|
34
55
|
},
|
|
35
56
|
|
|
@@ -62,14 +83,13 @@ export default{
|
|
|
62
83
|
data(){
|
|
63
84
|
return {
|
|
64
85
|
ready: false,
|
|
65
|
-
player: null
|
|
86
|
+
player: null,
|
|
87
|
+
id: null
|
|
66
88
|
}
|
|
67
89
|
},
|
|
68
90
|
|
|
69
91
|
mounted() {
|
|
70
|
-
|
|
71
|
-
this.loadVideo()
|
|
72
|
-
}
|
|
92
|
+
this.id = this.uniqid()
|
|
73
93
|
|
|
74
94
|
if(parseInt(this.delay) > 0){
|
|
75
95
|
window.setTimeout(() => {
|
|
@@ -91,14 +111,9 @@ export default{
|
|
|
91
111
|
|
|
92
112
|
loadVideo(){
|
|
93
113
|
|
|
94
|
-
|
|
95
|
-
const script = document.createElement('script')
|
|
96
|
-
script.src = 'https://www.youtube.com/iframe_api'
|
|
97
|
-
document.head.appendChild(script)
|
|
98
|
-
}
|
|
99
|
-
else{
|
|
114
|
+
initScript(() => {
|
|
100
115
|
if(!this.player){
|
|
101
|
-
this.player = new YT.Player(
|
|
116
|
+
this.player = new YT.Player(this.id, {
|
|
102
117
|
height: '100%',
|
|
103
118
|
width: '100%',
|
|
104
119
|
videoId: this.videoId,
|
|
@@ -116,7 +131,7 @@ export default{
|
|
|
116
131
|
else{
|
|
117
132
|
this.player.loadVideoById(this.videoId)
|
|
118
133
|
}
|
|
119
|
-
}
|
|
134
|
+
}, this.id)
|
|
120
135
|
|
|
121
136
|
}
|
|
122
137
|
|
package/src/mixin/component.js
CHANGED
|
@@ -153,7 +153,7 @@ export default{
|
|
|
153
153
|
|
|
154
154
|
compStyle(){
|
|
155
155
|
return {
|
|
156
|
-
'min-height': this.
|
|
156
|
+
'min-height': this.formHeight
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -164,7 +164,7 @@ export default{
|
|
|
164
164
|
form: {},
|
|
165
165
|
completed: false,
|
|
166
166
|
state: 1,
|
|
167
|
-
|
|
167
|
+
formHeight: undefined,
|
|
168
168
|
}
|
|
169
169
|
},
|
|
170
170
|
|
|
@@ -174,7 +174,7 @@ export default{
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
window.setTimeout(() => {
|
|
177
|
-
this.
|
|
177
|
+
this.formHeight = this.$el.clientHeight + 'px'
|
|
178
178
|
}, 1000)
|
|
179
179
|
}
|
|
180
180
|
|