@glitchr/stickyjs 1.0.42 → 1.0.45

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/js/sticky.js +13 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glitchr/stickyjs",
3
- "version": "1.0.42",
3
+ "version": "1.0.45",
4
4
  "description": "Sticky scroll library",
5
5
  "main": "src/index.js",
6
6
  "repository": {
package/src/js/sticky.js CHANGED
@@ -694,19 +694,21 @@ $.fn.serializeObject = function () {
694
694
  var maxScrollY = $(el).prop("scrollHeight") - Math.round($(el).prop("clientHeight"));
695
695
  if (maxScrollY == 0) maxScrollY = Math.round($(el).prop("clientHeight"));
696
696
 
697
- scrollTop = Math.max(0, Math.min(dict["top"] ?? $(el).prop("scrollTop"), maxScrollY));
698
- scrollLeft = Math.max(0, Math.min(dict["left"] ?? $(el).prop("scrollLeft"), maxScrollX));
697
+ var scrollTop = Math.max(0, Math.min(dict["top"] ?? $(el).prop("scrollTop"), maxScrollY));
698
+ var scrollLeft = Math.max(0, Math.min(dict["left"] ?? $(el).prop("scrollLeft"), maxScrollX));
699
699
 
700
- speed = parseFloat(dict["speed"] ?? 0);
701
- easing = dict["easing"] ?? "swing";
702
- debounce = dict["debounce"] ?? 0;
700
+ var speed = parseFloat(dict["speed"] ?? 0);
701
+ var easing = dict["easing"] ?? "swing";
702
+ var debounce = dict["debounce"] ?? 0;
703
703
 
704
- duration = 1000*Sticky.parseDuration(dict["duration"] ?? 0);
705
- durationX = 1000*Sticky.parseDuration(dict["duration-x"] ?? dict["duration"] ?? 0);
706
- durationY = 1000*Sticky.parseDuration(dict["duration-y"] ?? dict["duration"] ?? 0);
704
+ var duration = 1000*Sticky.parseDuration(dict["duration"] ?? 0);
705
+ var durationX = 1000*Sticky.parseDuration(dict["duration-x"] ?? dict["duration"] ?? 0);
706
+ var durationY = 1000*Sticky.parseDuration(dict["duration-y"] ?? dict["duration"] ?? 0);
707
707
 
708
708
  if(speed) {
709
709
 
710
+ var distanceX = 0, distanceY = 0;
711
+
710
712
  var currentScrollX = $(el)[0].scrollLeft;
711
713
  if(currentScrollX < scrollLeft || scrollLeft == 0) // Going to the right
712
714
  distanceX = Math.abs(scrollLeft - currentScrollX);
@@ -1144,16 +1146,15 @@ $.fn.serializeObject = function () {
1144
1146
  var hash = null;
1145
1147
  if(Settings.debug > 1) console.log("Sticky headlines:", $(ids));
1146
1148
 
1147
- var elAll = $(ids).filter(function() {
1148
1149
 
1150
+ var elAll = $(ids).filter(function() {
1149
1151
  if(this === $(Settings.identifier)) return false;
1150
1152
  return this.getBoundingClientRect().top < Sticky.getScrollPadding(scroller).top + 1;
1151
-
1152
- }).sort(function (el1, el2) {
1153
-
1153
+ }).toArray().sort(function (el1, el2) {
1154
1154
  return el1.offsetTop > el2.offsetTop ? -1
1155
1155
  : (el1.offsetTop < el2.offsetTop ? 1 : 0);
1156
1156
  });
1157
+ elAll = $(elAll); // re-wrap as jQuery so .filter (with `this` as element) and .has() work below
1157
1158
 
1158
1159
  var el = elAll.filter(function() {
1159
1160