diff --git a/.gitignore b/.gitignore index c7f0539e..1831664f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules/ npm-debug.log coverage/ dist/ +.idea/ diff --git a/packages/v-tooltip/src/components/Popper.js b/packages/v-tooltip/src/components/Popper.js index 54be3cf8..2873399d 100644 --- a/packages/v-tooltip/src/components/Popper.js +++ b/packages/v-tooltip/src/components/Popper.js @@ -132,7 +132,7 @@ export default () => ({ }, container: { - type: [String, Object, Element, Boolean], + type: [String, Object, Element, Boolean, Function], default () { return getDefaultConfig(this.theme, 'container') }, @@ -571,6 +571,10 @@ export default () => ({ $_ensureContainer () { let container = this.container + // if container is a callback, resolve it + if (typeof container === 'function') { + container = container(this.$_targetNodes[0]) + } // if container is a query, get the relative element if (typeof container === 'string') { container = window.document.querySelector(container) diff --git a/packages/v-tooltip/src/config.js b/packages/v-tooltip/src/config.js index 1840512c..6b2c4dba 100644 --- a/packages/v-tooltip/src/config.js +++ b/packages/v-tooltip/src/config.js @@ -3,11 +3,11 @@ export const config = { disabled: false, // Default position offset [skidding, distance] (px) offset: [0, 5], - // Default container where the tooltip will be appended + // Default container where the tooltip will be appended, can accept a callback that should return an element or a query selector container: 'body', // Element used to compute position and size boundaries boundary: undefined, - // Skip delay & CSS transitions when another popper is shown, so that the popper appear to instanly move to the new position. + // Skip delay & CSS transitions when another popper is shown, so that the popper appear to instantly move to the new position. instantMove: false, // Auto destroy tooltip DOM nodes (ms) disposeTimeout: 5000,