fix: context menu position (#1207)

* fix: context menu position

* fix: context menu position with player disabled
This commit is contained in:
memorydream 2022-01-09 18:12:30 +08:00 committed by GitHub
parent 66f9b4f526
commit b501214c02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,8 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex';
export default { export default {
name: 'ContextMenu', name: 'ContextMenu',
data() { data() {
@ -24,10 +26,14 @@ export default {
left: '0px', left: '0px',
}; };
}, },
computed: {
...mapState(['player']),
},
methods: { methods: {
setMenu(top, left) { setMenu(top, left) {
let heightOffset = this.player.enabled ? 64 : 0;
let largestHeight = let largestHeight =
window.innerHeight - this.$refs.menu.offsetHeight - 25; window.innerHeight - this.$refs.menu.offsetHeight - heightOffset;
let largestWidth = window.innerWidth - this.$refs.menu.offsetWidth - 25; let largestWidth = window.innerWidth - this.$refs.menu.offsetWidth - 25;
if (top > largestHeight) top = largestHeight; if (top > largestHeight) top = largestHeight;
if (left > largestWidth) left = largestWidth; if (left > largestWidth) left = largestWidth;