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>
<script>
import { mapState } from 'vuex';
export default {
name: 'ContextMenu',
data() {
@ -24,10 +26,14 @@ export default {
left: '0px',
};
},
computed: {
...mapState(['player']),
},
methods: {
setMenu(top, left) {
let heightOffset = this.player.enabled ? 64 : 0;
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;
if (top > largestHeight) top = largestHeight;
if (left > largestWidth) left = largestWidth;