2
0
mirror of https://github.com/tenrok/vue-context.git synced 2026-05-17 05:49:36 +03:00

Adding props for better content positioning (#55)

This commit is contained in:
Nikita Berezhnoy
2020-05-28 16:17:10 +03:00
committed by GitHub
parent 9c905bdf77
commit e20e5ac690
+29 -2
View File
@@ -42,6 +42,22 @@ export default {
type: Number,
default: 10
},
useScrollHeight: {
type: Boolean,
default: false
},
useScrollWidth: {
type: Boolean,
default: false
},
heightOffset: {
type: Number,
default: 25
},
widthOffset: {
type: Number,
default: 25
},
tag: {
type: String,
default: 'ul'
@@ -272,8 +288,19 @@ export default {
},
positionMenu(top, left, element) {
const largestHeight = window.innerHeight - element.offsetHeight - 25;
const largestWidth = window.innerWidth - element.offsetWidth - 25;
const largestHeight =
window.innerHeight -
(this.$props.useScrollHeight
? element.scrollHeight
: element.offsetHeight) -
this.$props.heightOffset;
const largestWidth =
window.innerWidth -
(this.$props.useScrollWidth
? element.scrollWidth
: element.offsetWidth) -
this.$props.widthOffset;
if (top > largestHeight) {
top = largestHeight;