UNPKG

vuetify

Version:

Vue.js 2 Semantic Component Framework

56 lines (53 loc) 2.28 kB
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } import { getZIndex } from '../util/helpers'; /* @vue/component */ export default { name: 'stackable', data: function data() { return { stackBase: null, stackClass: 'unpecified', stackElement: null, stackExclude: null, stackMinZIndex: 0 }; }, computed: { /** * Currently active z-index * * @return {number} */ activeZIndex: function activeZIndex() { if (typeof window === 'undefined') return 0; var content = this.stackElement || this.$refs.content; // Return current zindex if not active var index = !this.isActive ? getZIndex(content) : this.getMaxZIndex(this.stackExclude || [content]) + 2; if (index == null) return index; // Return max current z-index (excluding self) + 2 // (2 to leave room for an overlay below, if needed) return parseInt(index); } }, methods: { getMaxZIndex: function getMaxZIndex() { var exclude = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var base = this.stackBase || this.$el; // Start with lowest allowed z-index or z-index of // base component's element, whichever is greater var zis = [this.stackMinZIndex, getZIndex(base)]; // Convert the NodeList to an array to // prevent an Edge bug with Symbol.iterator // https://github.com/vuetifyjs/vuetify/issues/2146 var activeElements = [].concat(_toConsumableArray(document.getElementsByClassName(this.stackClass))); // Get z-index for all active dialogs for (var index = 0; index < activeElements.length; index++) { if (!exclude.includes(activeElements[index])) { zis.push(getZIndex(activeElements[index])); } } return Math.max.apply(Math, zis); } } }; //# sourceMappingURL=stackable.js.map