Commit 5c1a5f79314de0708adfdc89db31ea120e9d72ef
1 parent
0b6b72ae
优化播放器尺寸调节逻辑:
1.播放器不会大于屏幕高度 2.增加灰色背景色区分播放区域 3.播放器居中
Showing
1 changed file
with
10 additions
and
3 deletions
web_src/src/components/common/jessibuca.vue
| 1 | <template> | 1 | <template> |
| 2 | - <div id="container" ref="containerId" @dblclick="fullscreenSwich" style="width: 100%"> | 2 | + <div id="container" ref="containerId" @dblclick="fullscreenSwich" style="background-color: #eee;margin:0 auto;"> |
| 3 | <div class="buttons-box" id="buttonsBox"> | 3 | <div class="buttons-box" id="buttonsBox"> |
| 4 | <div class="buttons-box-left"> | 4 | <div class="buttons-box-left"> |
| 5 | <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i> | 5 | <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i> |
| @@ -72,9 +72,16 @@ export default { | @@ -72,9 +72,16 @@ export default { | ||
| 72 | methods: { | 72 | methods: { |
| 73 | updatePlayerDomSize() { | 73 | updatePlayerDomSize() { |
| 74 | let dom = document.getElementById('container'); | 74 | let dom = document.getElementById('container'); |
| 75 | - const width = dom.parentNode.clientWidth | 75 | + let width = dom.parentNode.clientWidth |
| 76 | + let height = (9 / 16) * width | ||
| 77 | + const clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight) | ||
| 78 | + if (height > clientHeight) { | ||
| 79 | + height = clientHeight | ||
| 80 | + width = (16 / 9) * height | ||
| 81 | + } | ||
| 82 | + | ||
| 76 | dom.style.width = width + 'px'; | 83 | dom.style.width = width + 'px'; |
| 77 | - dom.style.height = (9 / 16) * width + "px"; | 84 | + dom.style.height = height + "px"; |
| 78 | }, | 85 | }, |
| 79 | create() { | 86 | create() { |
| 80 | let options = {}; | 87 | let options = {}; |