uikit 3.11.2-dev.4c11be04b → 3.11.2-dev.54d67da03

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/css/uikit-core-rtl.css +1 -1
  3. package/dist/css/uikit-core-rtl.min.css +1 -1
  4. package/dist/css/uikit-core.css +1 -1
  5. package/dist/css/uikit-core.min.css +1 -1
  6. package/dist/css/uikit-rtl.css +1 -1
  7. package/dist/css/uikit-rtl.min.css +1 -1
  8. package/dist/css/uikit.css +1 -1
  9. package/dist/css/uikit.min.css +1 -1
  10. package/dist/js/components/countdown.js +1 -1
  11. package/dist/js/components/countdown.min.js +1 -1
  12. package/dist/js/components/filter.js +1 -1
  13. package/dist/js/components/filter.min.js +1 -1
  14. package/dist/js/components/lightbox-panel.js +1 -1
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +1 -1
  17. package/dist/js/components/lightbox.min.js +1 -1
  18. package/dist/js/components/notification.js +1 -1
  19. package/dist/js/components/notification.min.js +1 -1
  20. package/dist/js/components/parallax.js +6 -17
  21. package/dist/js/components/parallax.min.js +1 -1
  22. package/dist/js/components/slider-parallax.js +1 -1
  23. package/dist/js/components/slider-parallax.min.js +1 -1
  24. package/dist/js/components/slider.js +1 -1
  25. package/dist/js/components/slider.min.js +1 -1
  26. package/dist/js/components/slideshow-parallax.js +1 -1
  27. package/dist/js/components/slideshow-parallax.min.js +1 -1
  28. package/dist/js/components/slideshow.js +1 -1
  29. package/dist/js/components/slideshow.min.js +1 -1
  30. package/dist/js/components/sortable.js +2 -3
  31. package/dist/js/components/sortable.min.js +1 -1
  32. package/dist/js/components/tooltip.js +1 -1
  33. package/dist/js/components/tooltip.min.js +1 -1
  34. package/dist/js/components/upload.js +1 -1
  35. package/dist/js/components/upload.min.js +1 -1
  36. package/dist/js/uikit-core.js +255 -202
  37. package/dist/js/uikit-core.min.js +1 -1
  38. package/dist/js/uikit-icons.js +1 -1
  39. package/dist/js/uikit-icons.min.js +1 -1
  40. package/dist/js/uikit.js +261 -220
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/api/state.js +4 -4
  44. package/src/js/components/parallax.js +5 -16
  45. package/src/js/components/sortable.js +1 -2
  46. package/src/js/core/core.js +2 -2
  47. package/src/js/core/drop.js +1 -1
  48. package/src/js/core/height-viewport.js +2 -2
  49. package/src/js/core/img.js +101 -97
  50. package/src/js/core/navbar.js +6 -2
  51. package/src/js/core/sticky.js +82 -50
  52. package/src/js/util/dimensions.js +28 -12
  53. package/src/js/util/fastdom.js +2 -2
  54. package/src/js/util/options.js +4 -4
  55. package/src/js/util/viewport.js +7 -3
  56. package/tests/image.html +28 -38
  57. package/tests/images/test.avif +0 -0
  58. package/tests/images/test.webp +0 -0
  59. package/tests/sticky-parallax.html +44 -41
  60. package/tests/sticky.html +56 -24
package/dist/js/uikit.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! UIkit 3.11.2-dev.4c11be04b | https://www.getuikit.com | (c) 2014 - 2022 YOOtheme | MIT License */
1
+ /*! UIkit 3.11.2-dev.54d67da03 | https://www.getuikit.com | (c) 2014 - 2022 YOOtheme | MIT License */
2
2
 
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -1750,19 +1750,35 @@
1750
1750
  if ( element === void 0 ) element = window;
1751
1751
  if ( offsetDim === void 0 ) offsetDim = false;
1752
1752
 
1753
- return isNumeric(value)
1754
- ? +value
1755
- : endsWith(value, 'vh')
1756
- ? percent(height(toWindow(element)), value)
1757
- : endsWith(value, 'vw')
1758
- ? percent(width(toWindow(element)), value)
1759
- : endsWith(value, '%')
1760
- ? percent(offsetDim
1761
- ? element[("offset" + (ucfirst(property)))]
1762
- : dimensions$1(element)[property], value)
1763
- : toFloat(value);
1753
+
1754
+ if (!isString(value)) {
1755
+ return toFloat(value);
1756
+ }
1757
+
1758
+ return parseCalc(value).reduce(function (result, value) {
1759
+ var unit = parseUnit(value);
1760
+ if (unit) {
1761
+ value = percent(
1762
+ unit === 'vh'
1763
+ ? height(toWindow(element))
1764
+ : unit === 'vw'
1765
+ ? width(toWindow(element))
1766
+ : offsetDim
1767
+ ? element[("offset" + (ucfirst(property)))]
1768
+ : dimensions$1(element)[property],
1769
+ value
1770
+ );
1771
+ }
1772
+
1773
+ return result + toFloat(value);
1774
+ }, 0);
1764
1775
  }
1765
1776
 
1777
+ var calcRe = /-?\d+(?:\.\d+)?(?:v[wh]|%|px)?/g;
1778
+ var parseCalc = memoize(function (calc) { return calc.toString().replace(/\s/g, '').match(calcRe) || []; });
1779
+ var unitRe = /(?:v[hw]|%)$/;
1780
+ var parseUnit = memoize(function (str) { return (str.match(unitRe) || [])[0]; });
1781
+
1766
1782
  function percent(base, value) {
1767
1783
  return base * toFloat(value) / 100;
1768
1784
  }
@@ -1800,8 +1816,6 @@
1800
1816
  };
1801
1817
 
1802
1818
  function flush(recursion) {
1803
- if ( recursion === void 0 ) recursion = 1;
1804
-
1805
1819
  runTasks(fastdom.reads);
1806
1820
  runTasks(fastdom.writes.splice(0));
1807
1821
 
@@ -1823,7 +1837,7 @@
1823
1837
  if (recursion && recursion < RECURSION_LIMIT) {
1824
1838
  Promise$1.resolve().then(function () { return flush(recursion); });
1825
1839
  } else {
1826
- requestAnimationFrame(function () { return flush(); });
1840
+ requestAnimationFrame(function () { return flush(1); });
1827
1841
  }
1828
1842
 
1829
1843
  }
@@ -2079,9 +2093,8 @@
2079
2093
 
2080
2094
  try {
2081
2095
 
2082
- return !options
2083
- ? {}
2084
- : startsWith(options, '{')
2096
+ return options
2097
+ ? startsWith(options, '{')
2085
2098
  ? JSON.parse(options)
2086
2099
  : args.length && !includes(options, ':')
2087
2100
  ? (( obj = {}, obj[args[0]] = options, obj ))
@@ -2093,7 +2106,8 @@
2093
2106
  options[key.trim()] = value.trim();
2094
2107
  }
2095
2108
  return options;
2096
- }, {});
2109
+ }, {})
2110
+ : {};
2097
2111
 
2098
2112
  } catch (e) {
2099
2113
  return {};
@@ -2241,7 +2255,11 @@
2241
2255
  element = toNode(element);
2242
2256
  }
2243
2257
 
2244
- element.scrollTop = top;
2258
+ if (isUndefined(top)) {
2259
+ return element.scrollTop;
2260
+ } else {
2261
+ element.scrollTop = top;
2262
+ }
2245
2263
  }
2246
2264
 
2247
2265
  function scrollIntoView(element, ref) {
@@ -2673,7 +2691,8 @@
2673
2691
  scrolledOver: scrolledOver,
2674
2692
  scrollParents: scrollParents,
2675
2693
  getViewport: getViewport$1,
2676
- getViewportClientHeight: getViewportClientHeight
2694
+ getViewportClientHeight: getViewportClientHeight,
2695
+ getScrollingElement: getScrollingElement
2677
2696
  });
2678
2697
 
2679
2698
  function globalAPI (UIkit) {
@@ -3137,11 +3156,11 @@
3137
3156
  on(
3138
3157
  el,
3139
3158
  name,
3140
- !delegate
3141
- ? null
3142
- : isString(delegate)
3159
+ delegate
3160
+ ? isString(delegate)
3143
3161
  ? delegate
3144
- : delegate.call(component),
3162
+ : delegate.call(component)
3163
+ : null,
3145
3164
  isString(handler) ? component[handler] : handler.bind(component),
3146
3165
  {passive: passive, capture: capture, self: self}
3147
3166
  )
@@ -3462,7 +3481,7 @@
3462
3481
  UIkit.data = '__uikit__';
3463
3482
  UIkit.prefix = 'uk-';
3464
3483
  UIkit.options = {};
3465
- UIkit.version = '3.11.2-dev.4c11be04b';
3484
+ UIkit.version = '3.11.2-dev.54d67da03';
3466
3485
 
3467
3486
  globalAPI(UIkit);
3468
3487
  hooksAPI(UIkit);
@@ -3483,7 +3502,7 @@
3483
3502
  return;
3484
3503
  }
3485
3504
  pendingResize = true;
3486
- fastdom.write(function () { return pendingResize = false; });
3505
+ fastdom.read(function () { return pendingResize = false; });
3487
3506
  UIkit.update(null, 'resize');
3488
3507
  };
3489
3508
 
@@ -3502,7 +3521,7 @@
3502
3521
  return;
3503
3522
  }
3504
3523
  pending = true;
3505
- fastdom.write(function () { return pending = false; });
3524
+ fastdom.read(function () { return pending = false; });
3506
3525
 
3507
3526
  UIkit.update(null, e.type);
3508
3527
 
@@ -4588,7 +4607,7 @@
4588
4607
  if (active$1) {
4589
4608
 
4590
4609
  if (delay && active$1.isDelaying) {
4591
- this.showTimer = setTimeout(this.show, 10);
4610
+ this.showTimer = setTimeout(function () { return matches(target, ':hover') && this$1$1.show(); }, 10);
4592
4611
  return;
4593
4612
  }
4594
4613
 
@@ -5312,7 +5331,7 @@
5312
5331
  css(this.$el, {minHeight: minHeight});
5313
5332
 
5314
5333
  if (minHeight !== prev) {
5315
- this.$update(this.$el, 'resize');
5334
+ trigger(this.$el, 'resize');
5316
5335
  }
5317
5336
 
5318
5337
  if (this.minHeight && toFloat(css(this.$el, 'minHeight')) < this.minHeight) {
@@ -5789,10 +5808,7 @@
5789
5808
 
5790
5809
  props: {
5791
5810
  dataSrc: String,
5792
- dataSrcset: Boolean,
5793
- sizes: String,
5794
- width: Number,
5795
- height: Number,
5811
+ dataSources: String,
5796
5812
  offsetTop: String,
5797
5813
  offsetLeft: String,
5798
5814
  target: String
@@ -5800,10 +5816,7 @@
5800
5816
 
5801
5817
  data: {
5802
5818
  dataSrc: '',
5803
- dataSrcset: false,
5804
- sizes: false,
5805
- width: false,
5806
- height: false,
5819
+ dataSources: [],
5807
5820
  offsetTop: '50vh',
5808
5821
  offsetLeft: '50vw',
5809
5822
  target: false
@@ -5811,37 +5824,6 @@
5811
5824
 
5812
5825
  computed: {
5813
5826
 
5814
- cacheKey: function(ref) {
5815
- var dataSrc = ref.dataSrc;
5816
-
5817
- return ((this.$name) + "." + dataSrc);
5818
- },
5819
-
5820
- width: function(ref) {
5821
- var width = ref.width;
5822
- var dataWidth = ref.dataWidth;
5823
-
5824
- return width || dataWidth;
5825
- },
5826
-
5827
- height: function(ref) {
5828
- var height = ref.height;
5829
- var dataHeight = ref.dataHeight;
5830
-
5831
- return height || dataHeight;
5832
- },
5833
-
5834
- sizes: function(ref) {
5835
- var sizes = ref.sizes;
5836
- var dataSizes = ref.dataSizes;
5837
-
5838
- return sizes || dataSizes;
5839
- },
5840
-
5841
- isImg: function(_, $el) {
5842
- return isImg($el);
5843
- },
5844
-
5845
5827
  target: {
5846
5828
 
5847
5829
  get: function(ref) {
@@ -5854,18 +5836,6 @@
5854
5836
  this.observe();
5855
5837
  }
5856
5838
 
5857
- },
5858
-
5859
- offsetTop: function(ref) {
5860
- var offsetTop = ref.offsetTop;
5861
-
5862
- return toPx(offsetTop, 'height');
5863
- },
5864
-
5865
- offsetLeft: function(ref) {
5866
- var offsetLeft = ref.offsetLeft;
5867
-
5868
- return toPx(offsetLeft, 'width');
5869
5839
  }
5870
5840
 
5871
5841
  },
@@ -5873,21 +5843,15 @@
5873
5843
  connected: function() {
5874
5844
 
5875
5845
  if (!window.IntersectionObserver) {
5876
- setSrcAttrs(this.$el, this.dataSrc, this.dataSrcset, this.sizes);
5846
+ setSrcAttrs(this.$el, this.dataSrc);
5877
5847
  return;
5878
5848
  }
5879
5849
 
5880
- if (storage[this.cacheKey]) {
5881
- setSrcAttrs(this.$el, storage[this.cacheKey], this.dataSrcset, this.sizes);
5882
- } else if (this.isImg && this.width && this.height) {
5883
- setSrcAttrs(this.$el, getPlaceholderImage(this.width, this.height, this.sizes));
5884
- }
5885
-
5886
- this.observer = new IntersectionObserver(this.load, {
5887
- rootMargin: ((this.offsetTop) + "px " + (this.offsetLeft) + "px")
5888
- });
5850
+ ensurePlaceholderImage(this.$el);
5889
5851
 
5890
- requestAnimationFrame(this.observe);
5852
+ var rootMargin = (toPx(this.offsetTop, 'height')) + "px " + (toPx(this.offsetLeft, 'width')) + "px";
5853
+ this.observer = new IntersectionObserver(this.load, {rootMargin: rootMargin});
5854
+ this.observe();
5891
5855
 
5892
5856
  },
5893
5857
 
@@ -5897,35 +5861,17 @@
5897
5861
 
5898
5862
  update: {
5899
5863
 
5900
- read: function(ref) {
5901
- var this$1$1 = this;
5902
- var image = ref.image;
5903
-
5904
-
5905
- if (!this.observer) {
5864
+ write: function(store) {
5865
+ if (!this.observer || isImg(this.$el)) {
5906
5866
  return false;
5907
5867
  }
5908
-
5909
- if (!image && document.readyState === 'complete') {
5910
- this.load(this.observer.takeRecords());
5911
- }
5912
-
5913
- if (this.isImg) {
5914
- return false;
5915
- }
5916
-
5917
- image && image.then(function (img) { return img && img.currentSrc !== '' && setSrcAttrs(this$1$1.$el, currentSrc(img)); });
5918
-
5919
- },
5920
-
5921
- write: function(data) {
5922
-
5923
- if (this.dataSrcset && window.devicePixelRatio !== 1) {
5868
+ var srcset = data(this.$el, 'data-srcset');
5869
+ if (srcset && window.devicePixelRatio !== 1) {
5924
5870
 
5925
5871
  var bgSize = css(this.$el, 'backgroundSize');
5926
- if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) === data.bgSize) {
5927
- data.bgSize = getSourceSize(this.dataSrcset, this.sizes);
5928
- css(this.$el, 'backgroundSize', ((data.bgSize) + "px"));
5872
+ if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) === store.bgSize) {
5873
+ store.bgSize = getSourceSize(srcset, data(this.$el, 'sizes'));
5874
+ css(this.$el, 'backgroundSize', ((store.bgSize) + "px"));
5929
5875
  }
5930
5876
 
5931
5877
  }
@@ -5939,21 +5885,26 @@
5939
5885
  methods: {
5940
5886
 
5941
5887
  load: function(entries) {
5942
- var this$1$1 = this;
5943
-
5944
5888
 
5945
5889
  // Old chromium based browsers (UC Browser) did not implement `isIntersecting`
5946
5890
  if (!entries.some(function (entry) { return isUndefined(entry.isIntersecting) || entry.isIntersecting; })) {
5947
5891
  return;
5948
5892
  }
5949
5893
 
5950
- this._data.image = getImage(this.dataSrc, this.dataSrcset, this.sizes).then(function (img) {
5894
+ if (this._data.image) {
5895
+ return this._data.image;
5896
+ }
5951
5897
 
5952
- setSrcAttrs(this$1$1.$el, currentSrc(img), img.srcset, img.sizes);
5953
- storage[this$1$1.cacheKey] = currentSrc(img);
5954
- return img;
5898
+ var image = isImg(this.$el)
5899
+ ? this.$el
5900
+ : getImageFromElement(
5901
+ this.$el,
5902
+ this.dataSrc,
5903
+ this.dataSources
5904
+ );
5955
5905
 
5956
- }, function (e) { return trigger(this$1$1.$el, new e.constructor(e.type, e)); });
5906
+ this._data.image = image;
5907
+ setSrcAttrs(this.$el, image.currentSrc);
5957
5908
 
5958
5909
  this.observer.disconnect();
5959
5910
  },
@@ -5970,13 +5921,14 @@
5970
5921
 
5971
5922
  };
5972
5923
 
5973
- function setSrcAttrs(el, src, srcset, sizes) {
5924
+ function setSrcAttrs(el, src) {
5974
5925
 
5975
5926
  if (isImg(el)) {
5976
- var set = function (prop, val) { return val && val !== el[prop] && (el[prop] = val); };
5977
- set('sizes', sizes);
5978
- set('srcset', srcset);
5979
- set('src', src);
5927
+
5928
+ var parentNode = parent(el);
5929
+ var elements = isPicture(parentNode) ? children(parentNode) : [el];
5930
+ elements.forEach(function (el) { return setSourceProps(el, el); });
5931
+
5980
5932
  } else if (src) {
5981
5933
 
5982
5934
  var change = !includes(el.style.backgroundImage, src);
@@ -5989,15 +5941,66 @@
5989
5941
 
5990
5942
  }
5991
5943
 
5992
- function getPlaceholderImage(width, height, sizes) {
5993
- var assign;
5944
+ var srcProps = ['data-src', 'data-srcset', 'sizes'];
5945
+ function setSourceProps(sourceEl, targetEl) {
5946
+ srcProps.forEach(function (prop) {
5947
+ var value = data(sourceEl, prop);
5948
+ if (value) {
5949
+ attr(targetEl, prop.replace(/^(data-)+/, ''), value);
5950
+ }
5951
+ });
5952
+ }
5994
5953
 
5954
+ function getImageFromElement(el, src, sources) {
5995
5955
 
5996
- if (sizes) {
5997
- ((assign = Dimensions.ratio({width: width, height: height}, 'width', toPx(sizesToPixel(sizes))), width = assign.width, height = assign.height));
5956
+ if (!src) {
5957
+ return false;
5998
5958
  }
5999
5959
 
6000
- return ("data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"" + width + "\" height=\"" + height + "\"></svg>");
5960
+ var img = new Image();
5961
+
5962
+ wrapInPicture(img, sources);
5963
+ setSourceProps(el, img);
5964
+ img.onload = function () { return setSrcAttrs(el, img.currentSrc); };
5965
+ attr(img, 'src', src);
5966
+ return img;
5967
+ }
5968
+
5969
+ function wrapInPicture(img, sources) {
5970
+
5971
+ sources = parseSources(sources);
5972
+
5973
+ if (sources.length) {
5974
+ var picture = fragment('<picture>');
5975
+ sources.forEach(function (attrs) {
5976
+ var source = fragment('<source>');
5977
+ attr(source, attrs);
5978
+ append(picture, source);
5979
+ });
5980
+ append(picture, img);
5981
+ }
5982
+ }
5983
+
5984
+ function parseSources(sources) {
5985
+ if (!sources) {
5986
+ return [];
5987
+ }
5988
+
5989
+ if (startsWith(sources, '[')) {
5990
+ try {
5991
+ sources = JSON.parse(sources);
5992
+ } catch (e) {
5993
+ sources = [];
5994
+ }
5995
+ } else {
5996
+ sources = parseOptions(sources);
5997
+ }
5998
+
5999
+ if (!isArray(sources)) {
6000
+ sources = [sources];
6001
+ }
6002
+
6003
+ return sources.filter(function (source) { return !isEmpty(source); });
6001
6004
  }
6002
6005
 
6003
6006
  var sizesRe = /\s*(.*?)\s*(\w+|calc\(.*?\))\s*(?:,|$)/g;
@@ -6037,24 +6040,22 @@
6037
6040
  return descriptors.filter(function (size) { return size >= srcSize; })[0] || descriptors.pop() || '';
6038
6041
  }
6039
6042
 
6040
- function isImg(el) {
6041
- return el.tagName === 'IMG';
6043
+ function ensurePlaceholderImage(el) {
6044
+ if (isImg(el) && !hasAttr(el, 'src')) {
6045
+ attr(el, 'src', 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"></svg>');
6046
+ }
6042
6047
  }
6043
6048
 
6044
- function currentSrc(el) {
6045
- return el.currentSrc || el.src;
6049
+ function isPicture(el) {
6050
+ return isA(el, 'PICTURE');
6046
6051
  }
6047
6052
 
6048
- var key = '__test__';
6049
- var storage;
6053
+ function isImg(el) {
6054
+ return isA(el, 'IMG');
6055
+ }
6050
6056
 
6051
- // workaround for Safari's private browsing mode and accessing sessionStorage in Blink
6052
- try {
6053
- storage = window.sessionStorage || {};
6054
- storage[key] = 1;
6055
- delete storage[key];
6056
- } catch (e) {
6057
- storage = {};
6057
+ function isA(el, tagName) {
6058
+ return el && el.tagName === tagName;
6058
6059
  }
6059
6060
 
6060
6061
  var Media = {
@@ -6720,7 +6721,7 @@
6720
6721
  var current = ref.current;
6721
6722
 
6722
6723
  var active = this.getActive();
6723
- if (active && includes(active.mode, 'hover') && active.target && !within(active.target, current) && !active.tracker.movesTo(active.$el)) {
6724
+ if (active && includes(active.mode, 'hover') && active.target && !within(active.target, current) && !active.isDelaying) {
6724
6725
  active.hide(false);
6725
6726
  }
6726
6727
  }
@@ -6895,7 +6896,11 @@
6895
6896
 
6896
6897
  var active = this.getActive();
6897
6898
 
6898
- if (matches(this.dropbar, ':hover') && active && active.$el === $el) {
6899
+ if (matches(this.dropbar, ':hover')
6900
+ && active
6901
+ && active.$el === $el
6902
+ && !this.toggles.some(function (el) { return active.target !== el && matches(el, ':focus'); })
6903
+ ) {
6899
6904
  e.preventDefault();
6900
6905
  }
6901
6906
  }
@@ -7687,6 +7692,7 @@
7687
7692
  mixins: [Class, Media],
7688
7693
 
7689
7694
  props: {
7695
+ position: String,
7690
7696
  top: null,
7691
7697
  bottom: Boolean,
7692
7698
  offset: String,
@@ -7702,6 +7708,7 @@
7702
7708
  },
7703
7709
 
7704
7710
  data: {
7711
+ position: 'top',
7705
7712
  top: 0,
7706
7713
  bottom: false,
7707
7714
  offset: 0,
@@ -7718,10 +7725,23 @@
7718
7725
 
7719
7726
  computed: {
7720
7727
 
7721
- offset: function(ref) {
7728
+ position: function(ref, $el) {
7729
+ var position = ref.position;
7730
+
7731
+ return position === 'auto'
7732
+ ? (this.isFixed ? this.placeholder : $el).offsetHeight > height(window)
7733
+ ? 'bottom'
7734
+ : 'top'
7735
+ : position;
7736
+ },
7737
+
7738
+ offset: function(ref, $el) {
7722
7739
  var offset = ref.offset;
7723
7740
 
7724
- return toPx(offset);
7741
+ if (this.position === 'bottom') {
7742
+ offset += '+100vh-100%';
7743
+ }
7744
+ return toPx(offset, 'height', $el);
7725
7745
  },
7726
7746
 
7727
7747
  selTarget: function(ref, $el) {
@@ -7788,7 +7808,7 @@
7788
7808
  var this$1$1 = this;
7789
7809
 
7790
7810
 
7791
- if (!(this.targetOffset !== false && location.hash && window.pageYOffset > 0)) {
7811
+ if (!(this.targetOffset !== false && location.hash && scrollTop(window) > 0)) {
7792
7812
  return;
7793
7813
  }
7794
7814
 
@@ -7821,6 +7841,7 @@
7821
7841
 
7822
7842
  read: function(ref, types) {
7823
7843
  var height$1 = ref.height;
7844
+ var margin = ref.margin;
7824
7845
 
7825
7846
 
7826
7847
  this.inactive = !this.matchMedia || !isVisible(this.$el);
@@ -7829,46 +7850,56 @@
7829
7850
  return false;
7830
7851
  }
7831
7852
 
7832
- if (this.isActive && types.has('resize')) {
7853
+ var hide = this.isActive && types.has('resize');
7854
+ if (hide) {
7833
7855
  this.hide();
7834
- height$1 = this.$el.offsetHeight;
7835
- this.show();
7836
7856
  }
7837
7857
 
7838
- height$1 = this.isActive ? height$1 : this.$el.offsetHeight;
7858
+ if (!this.isActive) {
7859
+ height$1 = this.$el.offsetHeight;
7860
+ margin = css(this.$el, 'margin');
7861
+ }
7839
7862
 
7840
- if (height$1 + this.offset > height(window)) {
7841
- this.inactive = true;
7842
- return false;
7863
+ if (hide) {
7864
+ this.show();
7843
7865
  }
7844
7866
 
7867
+ var overflow = Math.max(0, height$1 + this.offset - height(window));
7868
+
7845
7869
  var referenceElement = this.isFixed ? this.placeholder : this.$el;
7846
- this.topOffset = offset(referenceElement).top;
7847
- this.bottomOffset = this.topOffset + height$1;
7848
- this.offsetParentTop = offset(referenceElement.offsetParent).top;
7870
+ var topOffset = offset(referenceElement).top;
7871
+ var offsetParentTop = offset(referenceElement.offsetParent).top;
7849
7872
 
7850
- var bottom = parseProp('bottom', this);
7873
+ var top = parseProp(this.top, this.$el, topOffset);
7874
+ var bottom = parseProp(this.bottom, this.$el, topOffset + height$1);
7851
7875
 
7852
- this.top = Math.max(toFloat(parseProp('top', this)), this.topOffset) - this.offset;
7853
- this.bottom = bottom && bottom - this.$el.offsetHeight;
7854
- this.width = dimensions$1(isVisible(this.widthElement) ? this.widthElement : this.$el).width;
7876
+ var start = Math.max(top, topOffset) - this.offset;
7877
+ var end = bottom
7878
+ ? bottom - this.$el.offsetHeight + overflow - this.offset
7879
+ : getScrollingElement(this.$el).scrollHeight - height(window);
7855
7880
 
7856
7881
  return {
7882
+ start: start,
7883
+ end: end,
7884
+ overflow: overflow,
7885
+ topOffset: topOffset,
7886
+ offsetParentTop: offsetParentTop,
7857
7887
  height: height$1,
7858
- top: offsetPosition(this.placeholder)[0],
7859
- margins: css(this.$el, ['marginTop', 'marginBottom', 'marginLeft', 'marginRight'])
7888
+ margin: margin,
7889
+ width: dimensions$1(isVisible(this.widthElement) ? this.widthElement : this.$el).width,
7890
+ top: offsetPosition(this.placeholder)[0]
7860
7891
  };
7861
7892
  },
7862
7893
 
7863
7894
  write: function(ref) {
7864
7895
  var height = ref.height;
7865
- var margins = ref.margins;
7896
+ var margin = ref.margin;
7866
7897
 
7867
7898
 
7868
7899
  var ref$1 = this;
7869
7900
  var placeholder = ref$1.placeholder;
7870
7901
 
7871
- css(placeholder, assign({height: height}, margins));
7902
+ css(placeholder, {height: height, margin: margin});
7872
7903
 
7873
7904
  if (!within(placeholder, document)) {
7874
7905
  after(this.$el, placeholder);
@@ -7886,14 +7917,29 @@
7886
7917
  {
7887
7918
 
7888
7919
  read: function(ref) {
7889
- var scroll = ref.scroll; if ( scroll === void 0 ) scroll = 0;
7920
+ var prevScroll = ref.scroll; if ( prevScroll === void 0 ) prevScroll = 0;
7921
+ var prevDir = ref.dir; if ( prevDir === void 0 ) prevDir = 'down';
7922
+ var overflow = ref.overflow;
7923
+ var overflowScroll = ref.overflowScroll; if ( overflowScroll === void 0 ) overflowScroll = 0;
7924
+ var start = ref.start;
7925
+ var end = ref.end;
7890
7926
 
7891
7927
 
7892
- this.scroll = window.pageYOffset;
7928
+ var scroll = scrollTop(window);
7929
+ var dir = prevScroll <= scroll ? 'down' : 'up';
7893
7930
 
7894
7931
  return {
7895
- dir: scroll <= this.scroll ? 'down' : 'up',
7896
- scroll: this.scroll
7932
+ dir: dir,
7933
+ prevDir: prevDir,
7934
+ scroll: scroll,
7935
+ prevScroll: prevScroll,
7936
+ overflowScroll: clamp(
7937
+ overflowScroll
7938
+ + clamp(scroll, start, end)
7939
+ - clamp(prevScroll, start, end),
7940
+ 0,
7941
+ overflow
7942
+ )
7897
7943
  };
7898
7944
  },
7899
7945
 
@@ -7901,35 +7947,34 @@
7901
7947
  var this$1$1 = this;
7902
7948
 
7903
7949
 
7904
- var now = Date.now();
7905
7950
  var isScrollUpdate = types.has('scroll');
7906
7951
  var initTimestamp = data.initTimestamp; if ( initTimestamp === void 0 ) initTimestamp = 0;
7907
7952
  var dir = data.dir;
7908
- var lastDir = data.lastDir;
7909
- var lastScroll = data.lastScroll;
7953
+ var prevDir = data.prevDir;
7910
7954
  var scroll = data.scroll;
7955
+ var prevScroll = data.prevScroll; if ( prevScroll === void 0 ) prevScroll = 0;
7911
7956
  var top = data.top;
7957
+ var start = data.start;
7958
+ var topOffset = data.topOffset;
7959
+ var height = data.height;
7912
7960
 
7913
- data.lastScroll = scroll;
7914
-
7915
- if (scroll < 0 || scroll === lastScroll && isScrollUpdate || this.showOnUp && !isScrollUpdate && !this.isFixed) {
7961
+ if (scroll < 0 || scroll === prevScroll && isScrollUpdate || this.showOnUp && !isScrollUpdate && !this.isFixed) {
7916
7962
  return;
7917
7963
  }
7918
7964
 
7919
- if (now - initTimestamp > 300 || dir !== lastDir) {
7965
+ var now = Date.now();
7966
+ if (now - initTimestamp > 300 || dir !== prevDir) {
7920
7967
  data.initScroll = scroll;
7921
7968
  data.initTimestamp = now;
7922
7969
  }
7923
7970
 
7924
- data.lastDir = dir;
7925
-
7926
- if (this.showOnUp && !this.isFixed && Math.abs(data.initScroll - scroll) <= 30 && Math.abs(lastScroll - scroll) <= 10) {
7971
+ if (this.showOnUp && !this.isFixed && Math.abs(data.initScroll - scroll) <= 30 && Math.abs(prevScroll - scroll) <= 10) {
7927
7972
  return;
7928
7973
  }
7929
7974
 
7930
7975
  if (this.inactive
7931
- || scroll < this.top
7932
- || this.showOnUp && (scroll <= this.top || dir === 'down' && isScrollUpdate || dir === 'up' && !this.isFixed && scroll <= this.bottomOffset)
7976
+ || scroll < start
7977
+ || this.showOnUp && (scroll <= start || dir === 'down' && isScrollUpdate || dir === 'up' && !this.isFixed && scroll <= topOffset + height)
7933
7978
  ) {
7934
7979
 
7935
7980
  if (!this.isFixed) {
@@ -7944,7 +7989,7 @@
7944
7989
 
7945
7990
  this.isFixed = false;
7946
7991
 
7947
- if (this.animation && scroll > this.topOffset) {
7992
+ if (this.animation && scroll > topOffset) {
7948
7993
  Animation.cancel(this.$el);
7949
7994
  Animation.out(this.$el, this.animation).then(function () { return this$1$1.hide(); }, noop);
7950
7995
  } else {
@@ -7994,23 +8039,37 @@
7994
8039
 
7995
8040
  update: function() {
7996
8041
 
7997
- var active = this.top !== 0 || this.scroll > this.top;
7998
- var top = Math.max(0, this.offset);
8042
+ var ref = this._data;
8043
+ var width = ref.width;
8044
+ var scroll = ref.scroll; if ( scroll === void 0 ) scroll = 0;
8045
+ var overflow = ref.overflow;
8046
+ var overflowScroll = ref.overflowScroll; if ( overflowScroll === void 0 ) overflowScroll = 0;
8047
+ var start = ref.start;
8048
+ var end = ref.end;
8049
+ var topOffset = ref.topOffset;
8050
+ var height = ref.height;
8051
+ var offsetParentTop = ref.offsetParentTop;
8052
+ var active = start !== 0 || scroll > start;
8053
+ var top = this.offset;
7999
8054
  var position = 'fixed';
8000
8055
 
8001
- if (isNumeric(this.bottom) && this.scroll > this.bottom - this.offset) {
8002
- top = this.bottom - this.offsetParentTop;
8056
+ if (scroll > end) {
8057
+ top = end + this.offset - offsetParentTop;
8003
8058
  position = 'absolute';
8004
8059
  }
8005
8060
 
8061
+ if (overflow) {
8062
+ top -= overflowScroll;
8063
+ }
8064
+
8006
8065
  css(this.$el, {
8007
8066
  position: position,
8008
8067
  top: (top + "px"),
8009
- width: this.width
8068
+ width: width
8010
8069
  });
8011
8070
 
8012
8071
  this.isActive = active;
8013
- toggleClass(this.$el, this.clsBelow, this.scroll > this.bottomOffset);
8072
+ toggleClass(this.$el, this.clsBelow, scroll > topOffset + height);
8014
8073
  addClass(this.$el, this.clsFixed);
8015
8074
 
8016
8075
  }
@@ -8019,16 +8078,10 @@
8019
8078
 
8020
8079
  };
8021
8080
 
8022
- function parseProp(prop, ref) {
8023
- var $props = ref.$props;
8024
- var $el = ref.$el;
8025
- var propOffset = ref[(prop + "Offset")];
8026
-
8027
-
8028
- var value = $props[prop];
8081
+ function parseProp(value, el, propOffset) {
8029
8082
 
8030
8083
  if (!value) {
8031
- return;
8084
+ return 0;
8032
8085
  }
8033
8086
 
8034
8087
  if (isString(value) && value.match(/^-?\d/)) {
@@ -8037,7 +8090,7 @@
8037
8090
 
8038
8091
  } else {
8039
8092
 
8040
- return offset(value === true ? parent($el) : query(value, $el)).bottom;
8093
+ return offset(value === true ? parent(el) : query(value, el)).bottom;
8041
8094
 
8042
8095
  }
8043
8096
  }
@@ -11049,16 +11102,18 @@
11049
11102
  start: function(ref) {
11050
11103
  var start = ref.start;
11051
11104
 
11052
- return parseCalc(start, this.target);
11105
+ return toPx(start, 'height', this.target, true);
11053
11106
  },
11054
11107
 
11055
11108
  end: function(ref) {
11056
11109
  var end = ref.end;
11057
11110
  var viewport = ref.viewport;
11058
11111
 
11059
- return parseCalc(
11112
+ return toPx(
11060
11113
  end || (viewport = (1 - viewport) * 100) && (viewport + "vh+" + viewport + "%"),
11061
- this.target
11114
+ 'height',
11115
+ this.target,
11116
+ true
11062
11117
  );
11063
11118
  }
11064
11119
 
@@ -11105,19 +11160,6 @@
11105
11160
 
11106
11161
  };
11107
11162
 
11108
- var calcRe = /-?\d+(?:\.\d+)?(?:v[wh]|%|px)?/g;
11109
- function parseCalc(calc, el) {
11110
- var match;
11111
- var result = 0;
11112
- calc = calc.toString().replace(/\s/g, '');
11113
- calcRe.lastIndex = 0;
11114
- while ((match = calcRe.exec(calc)) !== null) {
11115
- result += toPx(match[0], 'height', el, true);
11116
- }
11117
-
11118
- return result;
11119
- }
11120
-
11121
11163
  function ease(percent, easing) {
11122
11164
  return easing >= 0
11123
11165
  ? Math.pow(percent, easing + 1)
@@ -12097,7 +12139,6 @@
12097
12139
 
12098
12140
  off(document, pointerMove, this.move);
12099
12141
  off(document, pointerUp, this.end);
12100
- off(window, 'scroll', this.scroll);
12101
12142
 
12102
12143
  if (!this.drag) {
12103
12144
  return;
@@ -12180,7 +12221,7 @@
12180
12221
 
12181
12222
  var x = pos.x;
12182
12223
  var y = pos.y;
12183
- y += window.pageYOffset;
12224
+ y += scrollTop(window);
12184
12225
 
12185
12226
  var dist = (Date.now() - last) * .3;
12186
12227
  last = Date.now();