Skip to content

Commit

Permalink
Update popper.js to v1.12.3
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Aug 23, 2017
1 parent 96b8e42 commit 90aae63
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Works with Rails out of the box.
Add this line to your application's Gemfile:

```ruby
gem 'popper_js', '~> 1.11.1'
gem 'popper_js', '~> 1.12.3'
```

And then execute:
Expand Down
30 changes: 20 additions & 10 deletions assets/javascripts/popper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**!
* @fileOverview Kickass library to create and place poppers near their reference elements.
* @version 1.11.1
* @version 1.12.3
* @license
* Copyright (c) 2016 Federico Zivolo and contributors
*
Expand Down Expand Up @@ -347,7 +347,7 @@ var isIE10$1 = function () {
};

function getSize(axis, body, html, computedStyle) {
return Math.max(body['offset' + axis], html['client' + axis], html['offset' + axis], isIE10$1() ? html['offset' + axis] + computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')] + computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')] : 0);
return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE10$1() ? html['offset' + axis] + computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')] + computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')] : 0);
}

function getWindowSizes() {
Expand Down Expand Up @@ -873,6 +873,7 @@ function update() {
var data = {
instance: this,
styles: {},
arrowStyles: {},
attributes: {},
flipped: false,
offsets: {}
Expand Down Expand Up @@ -1117,9 +1118,9 @@ function applyStyle(data) {
// they will be set as HTML attributes of the element
setAttributes(data.instance.popper, data.attributes);

// if the arrow style has been computed, apply the arrow style
if (data.offsets.arrow) {
setStyles(data.arrowElement, data.offsets.arrow);
// if arrowElement is defined and arrowStyles has some properties
if (data.arrowElement && Object.keys(data.arrowStyles).length) {
setStyles(data.arrowElement, data.arrowStyles);
}

return data;
Expand Down Expand Up @@ -1239,9 +1240,10 @@ function computeStyle(data, options) {
'x-placement': data.placement
};

// Update attributes and styles of `data`
// Update `data` attributes, styles and arrowStyles
data.attributes = _extends({}, attributes, data.attributes);
data.styles = _extends({}, styles, data.styles);
data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);

return data;
}
Expand Down Expand Up @@ -1314,13 +1316,15 @@ function arrow(data, options) {
var isVertical = ['left', 'right'].indexOf(placement) !== -1;

var len = isVertical ? 'height' : 'width';
var side = isVertical ? 'top' : 'left';
var sideCapitalized = isVertical ? 'Top' : 'Left';
var side = sideCapitalized.toLowerCase();
var altSide = isVertical ? 'left' : 'top';
var opSide = isVertical ? 'bottom' : 'right';
var arrowElementSize = getOuterSizes(arrowElement)[len];

//
// extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
// extends keepTogether behavior making sure the popper and its
// reference have enough pixels in conjuction
//

// top/left side
Expand All @@ -1336,7 +1340,9 @@ function arrow(data, options) {
var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;

// Compute the sideValue using the updated popper offsets
var sideValue = center - getClientRect(data.offsets.popper)[side];
// take popper margin in account because we don't have this info available
var popperMarginSide = getStyleComputedProperty(data.instance.popper, 'margin' + sideCapitalized).replace('px', '');
var sideValue = center - getClientRect(data.offsets.popper)[side] - popperMarginSide;

// prevent arrowElement from being placed not contiguously to its popper
sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
Expand Down Expand Up @@ -1858,7 +1864,7 @@ function inner(data) {

var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;

popper[isHoriz ? 'left' : 'top'] = reference[placement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);

data.placement = getOppositePlacement(placement);
data.offsets.popper = getClientRect(popper);
Expand Down Expand Up @@ -1936,6 +1942,9 @@ var modifiers = {
* '10 - 5vh + 3%'
* '-10px + 5vh, 5px - 6%'
* ```
* > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
* > with their reference element, unfortunately, you will have to disable the `flip` modifier.
* > More on this [reading this issue](https://github.com/FezVrasta/popper.js/issues/373)
*
* @memberof modifiers
* @inner
Expand Down Expand Up @@ -2198,6 +2207,7 @@ var modifiers = {
* @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper.
* @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
* @property {Object} data.styles Any CSS property defined here will be applied to the popper, it expects the JavaScript nomenclature (eg. `marginBottom`)
* @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow, it expects the JavaScript nomenclature (eg. `marginBottom`)
* @property {Object} data.boundaries Offsets of the popper boundaries
* @property {Object} data.offsets The measurements of popper, reference and arrow elements.
* @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
Expand Down
2 changes: 1 addition & 1 deletion lib/popper_js/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module PopperJs
VERSION = '1.11.1'
VERSION = '1.12.3'
end

0 comments on commit 90aae63

Please sign in to comment.