popper_js 1.12.9 → 1.14.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a59bbeb89ea6c4566e4b1f24369a10082c23c97a
4
- data.tar.gz: b864874a2d2b4119cd99344c177f59411c57035a
3
+ metadata.gz: 87f69769d1ff9cbae471139ca595ab8f5fb1008b
4
+ data.tar.gz: 0b9f8f1bef8396bc4a3a7761d702ffd4a357bf20
5
5
  SHA512:
6
- metadata.gz: dda8c512d5397612025f6b4f755a599bd3ecb5ca9a452a6b26d2fa0b66823a5d4dee890fc6527f221cec2182babbbd8925bea946dc038799b916684c24169b82
7
- data.tar.gz: 60c205e38c0920530c1bd32a56caa40d98bf3a4b51ecec43423f0b1268f1c57b98ed1e5fdcac25318251719ef385542ae59f2fe7745b5f1e404a11f8fd062433
6
+ metadata.gz: 19736ac613f2278673181bd8eed55b1b2498252a5fd826ea5de1fb8219f798352a6b842cefd4c384c14850ae976c38923c1abf9b898acd800995affbb9f52148
7
+ data.tar.gz: c27f2ef23b4595a21a8f784bec99be151a4c5fa75c35c56cd04c497c6493b8bb5b099d910dfbe3d5dcc31ef841979610b258481e1e2be22796e0a36d5e80924f
@@ -1,6 +1,6 @@
1
1
  /**!
2
2
  * @fileOverview Kickass library to create and place poppers near their reference elements.
3
- * @version 1.12.9
3
+ * @version 1.14.3
4
4
  * @license
5
5
  * Copyright (c) 2016 Federico Zivolo and contributors
6
6
  *
@@ -29,6 +29,7 @@
29
29
  }(this, (function () { 'use strict';
30
30
 
31
31
  var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
32
+
32
33
  var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
33
34
  var timeoutDuration = 0;
34
35
  for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
@@ -148,13 +149,33 @@ function getScrollParent(element) {
148
149
  overflowX = _getStyleComputedProp.overflowX,
149
150
  overflowY = _getStyleComputedProp.overflowY;
150
151
 
151
- if (/(auto|scroll)/.test(overflow + overflowY + overflowX)) {
152
+ if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
152
153
  return element;
153
154
  }
154
155
 
155
156
  return getScrollParent(getParentNode(element));
156
157
  }
157
158
 
159
+ var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
160
+ var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
161
+
162
+ /**
163
+ * Determines if the browser is Internet Explorer
164
+ * @method
165
+ * @memberof Popper.Utils
166
+ * @param {Number} version to check
167
+ * @returns {Boolean} isIE
168
+ */
169
+ function isIE(version) {
170
+ if (version === 11) {
171
+ return isIE11;
172
+ }
173
+ if (version === 10) {
174
+ return isIE10;
175
+ }
176
+ return isIE11 || isIE10;
177
+ }
178
+
158
179
  /**
159
180
  * Returns the offset parent of the given element
160
181
  * @method
@@ -163,16 +184,23 @@ function getScrollParent(element) {
163
184
  * @returns {Element} offset parent
164
185
  */
165
186
  function getOffsetParent(element) {
187
+ if (!element) {
188
+ return document.documentElement;
189
+ }
190
+
191
+ var noOffsetParent = isIE(10) ? document.body : null;
192
+
166
193
  // NOTE: 1 DOM access here
167
- var offsetParent = element && element.offsetParent;
194
+ var offsetParent = element.offsetParent;
195
+ // Skip hidden elements which don't have an offsetParent
196
+ while (offsetParent === noOffsetParent && element.nextElementSibling) {
197
+ offsetParent = (element = element.nextElementSibling).offsetParent;
198
+ }
199
+
168
200
  var nodeName = offsetParent && offsetParent.nodeName;
169
201
 
170
202
  if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
171
- if (element) {
172
- return element.ownerDocument.documentElement;
173
- }
174
-
175
- return document.documentElement;
203
+ return element ? element.ownerDocument.documentElement : document.documentElement;
176
204
  }
177
205
 
178
206
  // .offsetParent will return the closest TD or TABLE in case
@@ -314,29 +342,14 @@ function getBordersSize(styles, axis) {
314
342
  return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10);
315
343
  }
316
344
 
317
- /**
318
- * Tells if you are running Internet Explorer 10
319
- * @method
320
- * @memberof Popper.Utils
321
- * @returns {Boolean} isIE10
322
- */
323
- var isIE10 = undefined;
324
-
325
- var isIE10$1 = function () {
326
- if (isIE10 === undefined) {
327
- isIE10 = navigator.appVersion.indexOf('MSIE 10') !== -1;
328
- }
329
- return isIE10;
330
- };
331
-
332
345
  function getSize(axis, body, html, computedStyle) {
333
- 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);
346
+ return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? html['offset' + axis] + computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')] + computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')] : 0);
334
347
  }
335
348
 
336
349
  function getWindowSizes() {
337
350
  var body = document.body;
338
351
  var html = document.documentElement;
339
- var computedStyle = isIE10$1() && getComputedStyle(html);
352
+ var computedStyle = isIE(10) && getComputedStyle(html);
340
353
 
341
354
  return {
342
355
  height: getSize('Height', body, html, computedStyle),
@@ -428,8 +441,8 @@ function getBoundingClientRect(element) {
428
441
  // IE10 10 FIX: Please, don't ask, the element isn't
429
442
  // considered in DOM in some circumstances...
430
443
  // This isn't reproducible in IE10 compatibility mode of IE11
431
- if (isIE10$1()) {
432
- try {
444
+ try {
445
+ if (isIE(10)) {
433
446
  rect = element.getBoundingClientRect();
434
447
  var scrollTop = getScroll(element, 'top');
435
448
  var scrollLeft = getScroll(element, 'left');
@@ -437,10 +450,10 @@ function getBoundingClientRect(element) {
437
450
  rect.left += scrollLeft;
438
451
  rect.bottom += scrollTop;
439
452
  rect.right += scrollLeft;
440
- } catch (err) {}
441
- } else {
442
- rect = element.getBoundingClientRect();
443
- }
453
+ } else {
454
+ rect = element.getBoundingClientRect();
455
+ }
456
+ } catch (e) {}
444
457
 
445
458
  var result = {
446
459
  left: rect.left,
@@ -472,7 +485,9 @@ function getBoundingClientRect(element) {
472
485
  }
473
486
 
474
487
  function getOffsetRectRelativeToArbitraryNode(children, parent) {
475
- var isIE10 = isIE10$1();
488
+ var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
489
+
490
+ var isIE10 = isIE(10);
476
491
  var isHTML = parent.nodeName === 'HTML';
477
492
  var childrenRect = getBoundingClientRect(children);
478
493
  var parentRect = getBoundingClientRect(parent);
@@ -482,6 +497,11 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) {
482
497
  var borderTopWidth = parseFloat(styles.borderTopWidth, 10);
483
498
  var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);
484
499
 
500
+ // In cases where the parent is fixed, we must ignore negative scroll in offset calc
501
+ if (fixedPosition && parent.nodeName === 'HTML') {
502
+ parentRect.top = Math.max(parentRect.top, 0);
503
+ parentRect.left = Math.max(parentRect.left, 0);
504
+ }
485
505
  var offsets = getClientRect({
486
506
  top: childrenRect.top - parentRect.top - borderTopWidth,
487
507
  left: childrenRect.left - parentRect.left - borderLeftWidth,
@@ -509,7 +529,7 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) {
509
529
  offsets.marginLeft = marginLeft;
510
530
  }
511
531
 
512
- if (isIE10 ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
532
+ if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
513
533
  offsets = includeScroll(offsets, parent);
514
534
  }
515
535
 
@@ -517,13 +537,15 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) {
517
537
  }
518
538
 
519
539
  function getViewportOffsetRectRelativeToArtbitraryNode(element) {
540
+ var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
541
+
520
542
  var html = element.ownerDocument.documentElement;
521
543
  var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
522
544
  var width = Math.max(html.clientWidth, window.innerWidth || 0);
523
545
  var height = Math.max(html.clientHeight, window.innerHeight || 0);
524
546
 
525
- var scrollTop = getScroll(html);
526
- var scrollLeft = getScroll(html, 'left');
547
+ var scrollTop = !excludeScroll ? getScroll(html) : 0;
548
+ var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
527
549
 
528
550
  var offset = {
529
551
  top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
@@ -554,6 +576,26 @@ function isFixed(element) {
554
576
  return isFixed(getParentNode(element));
555
577
  }
556
578
 
579
+ /**
580
+ * Finds the first parent of an element that has a transformed property defined
581
+ * @method
582
+ * @memberof Popper.Utils
583
+ * @argument {Element} element
584
+ * @returns {Element} first transformed parent or documentElement
585
+ */
586
+
587
+ function getFixedPositionOffsetParent(element) {
588
+ // This check is needed to avoid errors in case one of the elements isn't defined for any reason
589
+ if (!element || !element.parentElement || isIE()) {
590
+ return document.documentElement;
591
+ }
592
+ var el = element.parentElement;
593
+ while (el && getStyleComputedProperty(el, 'transform') === 'none') {
594
+ el = el.parentElement;
595
+ }
596
+ return el || document.documentElement;
597
+ }
598
+
557
599
  /**
558
600
  * Computed the boundaries limits and return them
559
601
  * @method
@@ -562,16 +604,20 @@ function isFixed(element) {
562
604
  * @param {HTMLElement} reference
563
605
  * @param {number} padding
564
606
  * @param {HTMLElement} boundariesElement - Element used to define the boundaries
607
+ * @param {Boolean} fixedPosition - Is in fixed position mode
565
608
  * @returns {Object} Coordinates of the boundaries
566
609
  */
567
610
  function getBoundaries(popper, reference, padding, boundariesElement) {
611
+ var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
612
+
568
613
  // NOTE: 1 DOM access here
614
+
569
615
  var boundaries = { top: 0, left: 0 };
570
- var offsetParent = findCommonOffsetParent(popper, reference);
616
+ var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
571
617
 
572
618
  // Handle viewport case
573
619
  if (boundariesElement === 'viewport') {
574
- boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent);
620
+ boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
575
621
  } else {
576
622
  // Handle other cases based on DOM element used as boundaries
577
623
  var boundariesNode = void 0;
@@ -586,7 +632,7 @@ function getBoundaries(popper, reference, padding, boundariesElement) {
586
632
  boundariesNode = boundariesElement;
587
633
  }
588
634
 
589
- var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent);
635
+ var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
590
636
 
591
637
  // In case of HTML, we need a different computation
592
638
  if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
@@ -687,11 +733,14 @@ function computeAutoPlacement(placement, refRect, popper, reference, boundariesE
687
733
  * @param {Object} state
688
734
  * @param {Element} popper - the popper element
689
735
  * @param {Element} reference - the reference element (the popper will be relative to this)
736
+ * @param {Element} fixedPosition - is in fixed position mode
690
737
  * @returns {Object} An object containing the offsets which will be applied to the popper
691
738
  */
692
739
  function getReferenceOffsets(state, popper, reference) {
693
- var commonOffsetParent = findCommonOffsetParent(popper, reference);
694
- return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent);
740
+ var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
741
+
742
+ var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
743
+ return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
695
744
  }
696
745
 
697
746
  /**
@@ -864,7 +913,7 @@ function update() {
864
913
  };
865
914
 
866
915
  // compute reference element offsets
867
- data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference);
916
+ data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
868
917
 
869
918
  // compute auto placement, store placement inside the data object,
870
919
  // modifiers will be able to edit `placement` if needed
@@ -874,9 +923,12 @@ function update() {
874
923
  // store the computed placement inside `originalPlacement`
875
924
  data.originalPlacement = data.placement;
876
925
 
926
+ data.positionFixed = this.options.positionFixed;
927
+
877
928
  // compute the popper offsets
878
929
  data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
879
- data.offsets.popper.position = 'absolute';
930
+
931
+ data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
880
932
 
881
933
  // run the modifiers
882
934
  data = runModifiers(this.modifiers, data);
@@ -916,7 +968,7 @@ function getSupportedPropertyName(property) {
916
968
  var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
917
969
  var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
918
970
 
919
- for (var i = 0; i < prefixes.length - 1; i++) {
971
+ for (var i = 0; i < prefixes.length; i++) {
920
972
  var prefix = prefixes[i];
921
973
  var toCheck = prefix ? '' + prefix + upperProp : property;
922
974
  if (typeof document.body.style[toCheck] !== 'undefined') {
@@ -937,9 +989,12 @@ function destroy() {
937
989
  // touch DOM only if `applyStyle` modifier is enabled
938
990
  if (isModifierEnabled(this.modifiers, 'applyStyle')) {
939
991
  this.popper.removeAttribute('x-placement');
940
- this.popper.style.left = '';
941
992
  this.popper.style.position = '';
942
993
  this.popper.style.top = '';
994
+ this.popper.style.left = '';
995
+ this.popper.style.right = '';
996
+ this.popper.style.bottom = '';
997
+ this.popper.style.willChange = '';
943
998
  this.popper.style[getSupportedPropertyName('transform')] = '';
944
999
  }
945
1000
 
@@ -1127,12 +1182,12 @@ function applyStyle(data) {
1127
1182
  * @method
1128
1183
  * @memberof Popper.modifiers
1129
1184
  * @param {HTMLElement} reference - The reference element used to position the popper
1130
- * @param {HTMLElement} popper - The HTML element used as popper.
1185
+ * @param {HTMLElement} popper - The HTML element used as popper
1131
1186
  * @param {Object} options - Popper.js options
1132
1187
  */
1133
1188
  function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
1134
1189
  // compute reference element offsets
1135
- var referenceOffsets = getReferenceOffsets(state, popper, reference);
1190
+ var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
1136
1191
 
1137
1192
  // compute auto placement, store placement inside the data object,
1138
1193
  // modifiers will be able to edit `placement` if needed
@@ -1143,7 +1198,7 @@ function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
1143
1198
 
1144
1199
  // Apply `position` to popper before anything else because
1145
1200
  // without the position applied we can't guarantee correct computations
1146
- setStyles(popper, { position: 'absolute' });
1201
+ setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
1147
1202
 
1148
1203
  return options;
1149
1204
  }
@@ -1178,11 +1233,13 @@ function computeStyle(data, options) {
1178
1233
  position: popper.position
1179
1234
  };
1180
1235
 
1181
- // floor sides to avoid blurry text
1236
+ // Avoid blurry text by using full pixel integers.
1237
+ // For pixel-perfect positioning, top/bottom prefers rounded
1238
+ // values, while left/right prefers floored values.
1182
1239
  var offsets = {
1183
1240
  left: Math.floor(popper.left),
1184
- top: Math.floor(popper.top),
1185
- bottom: Math.floor(popper.bottom),
1241
+ top: Math.round(popper.top),
1242
+ bottom: Math.round(popper.bottom),
1186
1243
  right: Math.floor(popper.right)
1187
1244
  };
1188
1245
 
@@ -1446,7 +1503,7 @@ function flip(data, options) {
1446
1503
  return data;
1447
1504
  }
1448
1505
 
1449
- var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement);
1506
+ var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
1450
1507
 
1451
1508
  var placement = data.placement.split('-')[0];
1452
1509
  var placementOpposite = getOppositePlacement(placement);
@@ -1738,7 +1795,27 @@ function preventOverflow(data, options) {
1738
1795
  boundariesElement = getOffsetParent(boundariesElement);
1739
1796
  }
1740
1797
 
1741
- var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement);
1798
+ // NOTE: DOM access here
1799
+ // resets the popper's position so that the document size can be calculated excluding
1800
+ // the size of the popper element itself
1801
+ var transformProp = getSupportedPropertyName('transform');
1802
+ var popperStyles = data.instance.popper.style; // assignment to help minification
1803
+ var top = popperStyles.top,
1804
+ left = popperStyles.left,
1805
+ transform = popperStyles[transformProp];
1806
+
1807
+ popperStyles.top = '';
1808
+ popperStyles.left = '';
1809
+ popperStyles[transformProp] = '';
1810
+
1811
+ var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
1812
+
1813
+ // NOTE: DOM access here
1814
+ // restores the original style properties after the offsets have been computed
1815
+ popperStyles.top = top;
1816
+ popperStyles.left = left;
1817
+ popperStyles[transformProp] = transform;
1818
+
1742
1819
  options.boundaries = boundaries;
1743
1820
 
1744
1821
  var order = options.priority;
@@ -2235,6 +2312,12 @@ var Defaults = {
2235
2312
  */
2236
2313
  placement: 'bottom',
2237
2314
 
2315
+ /**
2316
+ * Set this to true if you want popper to position it self in 'fixed' mode
2317
+ * @prop {Boolean} positionFixed=false
2318
+ */
2319
+ positionFixed: false,
2320
+
2238
2321
  /**
2239
2322
  * Whether events (resize, scroll) are initially enabled
2240
2323
  * @prop {Boolean} eventsEnabled=true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PopperJs
4
- VERSION = '1.12.9'
4
+ VERSION = '1.14.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popper_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.9
4
+ version: 1.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Mazovetskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-17 00:00:00.000000000 Z
11
+ date: 2018-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler