2
0
mirror of https://github.com/tenrok/vue-context.git synced 2026-06-22 10:20:32 +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, type: Number,
default: 10 default: 10
}, },
useScrollHeight: {
type: Boolean,
default: false
},
useScrollWidth: {
type: Boolean,
default: false
},
heightOffset: {
type: Number,
default: 25
},
widthOffset: {
type: Number,
default: 25
},
tag: { tag: {
type: String, type: String,
default: 'ul' default: 'ul'
@@ -272,8 +288,19 @@ export default {
}, },
positionMenu(top, left, element) { positionMenu(top, left, element) {
const largestHeight = window.innerHeight - element.offsetHeight - 25; const largestHeight =
const largestWidth = window.innerWidth - element.offsetWidth - 25; 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) { if (top > largestHeight) {
top = largestHeight; top = largestHeight;