Skip to content

Commit

Permalink
implement detectOverflow for boundaries-selector
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisbelt committed Mar 18, 2020
1 parent 0d45dc6 commit b8c47b1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
21 changes: 12 additions & 9 deletions dist/vue-popper.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core')) :
typeof define === 'function' && define.amd ? define(['@popperjs/core'], factory) :
(global = global || self, global.VuePopper = factory(global.core));
}(this, (function (core) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('@popperjs/core/lib/utils/detectOverflow.js')) :
typeof define === 'function' && define.amd ? define(['@popperjs/core', '@popperjs/core/lib/utils/detectOverflow.js'], factory) :
(global = global || self, global.VuePopper = factory(global.core, global.detectOverflow));
}(this, (function (core, detectOverflow) { 'use strict';

detectOverflow = detectOverflow && Object.prototype.hasOwnProperty.call(detectOverflow, 'default') ? detectOverflow['default'] : detectOverflow;

//

Expand Down Expand Up @@ -221,12 +223,13 @@
}

if (_this.boundariesSelector) {
var boundariesElement = document.querySelector(_this.boundariesSelector);
var customBoundary = document.querySelector(_this.boundariesSelector);

if (customBoundary) {
detectOverflow(state, {
boundary: customBoundary // 'clippingParents' by default

if (boundariesElement) {
_this.popperOptions.modifiers = Object.assign({}, _this.popperOptions.modifiers);
_this.popperOptions.modifiers.preventOverflow = Object.assign({}, _this.popperOptions.modifiers.preventOverflow);
_this.popperOptions.modifiers.preventOverflow.boundariesElement = boundariesElement;
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/vue-popper.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions src/component/popper.js.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

<script>
import { createPopper } from '@popperjs/core';
import detectOverflow from '@popperjs/core/lib/utils/detectOverflow.js';
function on(element, event, handler) {
if (element && event && handler) {
Expand Down Expand Up @@ -281,12 +282,12 @@
}
if (this.boundariesSelector) {
const boundariesElement = document.querySelector(this.boundariesSelector);
const customBoundary = document.querySelector(this.boundariesSelector);
if (boundariesElement) {
this.popperOptions.modifiers = Object.assign({}, this.popperOptions.modifiers);
this.popperOptions.modifiers.preventOverflow = Object.assign({}, this.popperOptions.modifiers.preventOverflow);
this.popperOptions.modifiers.preventOverflow.boundariesElement = boundariesElement;
if (customBoundary) {
detectOverflow(state, {
boundary: customBoundary, // 'clippingParents' by default
});
}
}
Expand Down

0 comments on commit b8c47b1

Please sign in to comment.