Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Prop for auto-placement of items list #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/components/VueBootstrapTypeahead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ export default {
},
placeholder: String,
prepend: String,
append: String
append: String,
autoEstimatePlace: {
type: Boolean,
default: false
},
},

computed: {
Expand All @@ -120,6 +124,15 @@ export default {
resizeList(el) {
const rect = el.getBoundingClientRect()
const listStyle = this.$refs.list.$el.style

if(this.autoEstimatePlace) {
const firstHalfOfScreen = rect.y < (screen.availHeight / 2);
if (!firstHalfOfScreen) {
listStyle.top = this.$refs.list.$el.offsetHeight * (-1) + 'px';
} else {
listStyle.top = "";
}
}

// Set the width of the list on resize
listStyle.width = rect.width + 'px'
Expand Down