mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-07 07:12:23 +03:00
06177a4d24
BREAKING CHANGE: drop vue 2 support
33 lines
820 B
JavaScript
33 lines
820 B
JavaScript
export default {
|
|
mounted(el, { instance }) {
|
|
if (instance.appendToBody) {
|
|
const {
|
|
height,
|
|
top,
|
|
left,
|
|
width,
|
|
} = instance.$refs.toggle.getBoundingClientRect()
|
|
let scrollX = window.scrollX || window.pageXOffset
|
|
let scrollY = window.scrollY || window.pageYOffset
|
|
el.unbindPosition = instance.calculatePosition(el, instance, {
|
|
width: width + 'px',
|
|
left: scrollX + left + 'px',
|
|
top: scrollY + top + height + 'px',
|
|
})
|
|
|
|
document.body.appendChild(el)
|
|
}
|
|
},
|
|
|
|
unmounted(el, { instance }) {
|
|
if (instance.appendToBody) {
|
|
if (el.unbindPosition && typeof el.unbindPosition === 'function') {
|
|
el.unbindPosition()
|
|
}
|
|
if (el.parentNode) {
|
|
el.parentNode.removeChild(el)
|
|
}
|
|
}
|
|
},
|
|
}
|