Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

Commit e20e5ac

Browse files
authored
Adding props for better content positioning (#55)
1 parent 9c905bd commit e20e5ac

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/js/vue-context.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@ export default {
4242
type: Number,
4343
default: 10
4444
},
45+
useScrollHeight: {
46+
type: Boolean,
47+
default: false
48+
},
49+
useScrollWidth: {
50+
type: Boolean,
51+
default: false
52+
},
53+
heightOffset: {
54+
type: Number,
55+
default: 25
56+
},
57+
widthOffset: {
58+
type: Number,
59+
default: 25
60+
},
4561
tag: {
4662
type: String,
4763
default: 'ul'
@@ -272,8 +288,19 @@ export default {
272288
},
273289

274290
positionMenu(top, left, element) {
275-
const largestHeight = window.innerHeight - element.offsetHeight - 25;
276-
const largestWidth = window.innerWidth - element.offsetWidth - 25;
291+
const largestHeight =
292+
window.innerHeight -
293+
(this.$props.useScrollHeight
294+
? element.scrollHeight
295+
: element.offsetHeight) -
296+
this.$props.heightOffset;
297+
298+
const largestWidth =
299+
window.innerWidth -
300+
(this.$props.useScrollWidth
301+
? element.scrollWidth
302+
: element.offsetWidth) -
303+
this.$props.widthOffset;
277304

278305
if (top > largestHeight) {
279306
top = largestHeight;

0 commit comments

Comments
 (0)