mirror of
https://github.com/tenrok/vue-context.git
synced 2026-06-22 09:00:33 +03:00
Adding props for better content positioning (#55)
This commit is contained in:
+29
-2
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user