From b9dd1068f223d9d7def9f3998fb66a69bc3eedd3 Mon Sep 17 00:00:00 2001 From: nobody Date: Fri, 25 Jun 2021 06:35:38 +0200 Subject: [PATCH] Added: sticky-js v1.3.0 (#540) --- THIRD_PARTY.txt | 1 + core/mappings.js | 1 + core/resources.js | 4 ++++ modules/internal/targets.js | 3 +++ pages/updates/updates.html | 1 + resources/sticky-js/1.3.0/sticky.min.jsm | 1 + 6 files changed, 11 insertions(+) create mode 100644 resources/sticky-js/1.3.0/sticky.min.jsm diff --git a/THIRD_PARTY.txt b/THIRD_PARTY.txt index b3732d54..885ce9c2 100644 --- a/THIRD_PARTY.txt +++ b/THIRD_PARTY.txt @@ -1509,6 +1509,7 @@ https://cdnjs.cloudflare.com/ajax/libs/spin.js/3.1.0/spin.min.js https://cdnjs.cloudflare.com/ajax/libs/spin.js/4.1.0/spin.min.js https://cdnjs.cloudflare.com/ajax/libs/stickyfill/1.1.4/stickyfill.min.js https://cdnjs.cloudflare.com/ajax/libs/stickyfill/2.1.0/stickyfill.min.js +https://cdnjs.cloudflare.com/ajax/libs/sticky-js/1.3.0/sticky.min.js https://cdnjs.cloudflare.com/ajax/libs/store.js/2.0.12/store.legacy.min.js https://cdnjs.cloudflare.com/ajax/libs/swfobject/2.2/swfobject.js https://cdnjs.cloudflare.com/ajax/libs/Swiper/3.4.2/css/swiper.min.css diff --git a/core/mappings.js b/core/mappings.js index 43c4f087..f7fddb22 100644 --- a/core/mappings.js +++ b/core/mappings.js @@ -409,6 +409,7 @@ mappings.cdn = { 'slick-lightbox/{version}/slick-lightbox.css': resources.slickLightboxCSS, 'slider-pro/{version}/js/jquery.sliderPro.': resources.sliderProJS, 'spin.js/{version}/spin.min.js': resources.spinJS, + 'sticky-js/{version}/sticky.min.js': resources.stickyJS, 'stickyfill/{version}/stickyfill.': resources.stickyfill, 'socket.io/{version}/socket.io.': resources.socketIO, 'swfobject/{version}/swfobject.': resources.swfobject, diff --git a/core/resources.js b/core/resources.js index df8e88a5..89adc0b4 100644 --- a/core/resources.js +++ b/core/resources.js @@ -859,6 +859,10 @@ var resources = { 'spinJS': { 'path': 'resources/spin.js/{version}/spin.min.jsm' }, + // sticky-js + 'stickyJS': { + 'path': 'resources/sticky-js/{version}/sticky.min.jsm' + }, // stickyfill [Deprecated] 'stickyfill': { 'path': 'resources/stickyfill/{version}/stickyfill.min.jsm' diff --git a/modules/internal/targets.js b/modules/internal/targets.js index 3cd4db97..14760400 100644 --- a/modules/internal/targets.js +++ b/modules/internal/targets.js @@ -559,6 +559,8 @@ targets.setLastVersion = function (type, version) { return '1.1.4'; } else if (type.startsWith('/stickyfill/2.')) { return '2.1.0'; + } else if (type.startsWith('/sticky-js/')) { + return '1.3.0'; } else if (type.startsWith('/store.js/2.')) { return '2.0.12'; } else if (type.startsWith('/swfobject/2.')) { @@ -643,6 +645,7 @@ targets.determineResourceName = function (filename) { }; const ListOfFiles = { + 'sticky.min.jsm': 'sticky-js', 'jquery-ajax-unobtrusive.min.jsm': 'jQuery Unobtrusive Ajax', 'vuex.min.jsm': 'vuex', 'alpine.jsm': 'alpinejs', diff --git a/pages/updates/updates.html b/pages/updates/updates.html index 9e31437c..ddf8a656 100644 --- a/pages/updates/updates.html +++ b/pages/updates/updates.html @@ -38,6 +38,7 @@
  • Updated: findify-bundle v7.0.22 -> v7.0.23 (#539)
  • Added: vuex v3.6.2 and v4.0.2 (#540)
  • Added: jquery-ajax-unobtrusive v3.6.2 (#540)
  • +
  • Added: sticky-js v1.3.0 (#540)
  • diff --git a/resources/sticky-js/1.3.0/sticky.min.jsm b/resources/sticky-js/1.3.0/sticky.min.jsm new file mode 100644 index 00000000..ee6515fb --- /dev/null +++ b/resources/sticky-js/1.3.0/sticky.min.jsm @@ -0,0 +1 @@ +function _classCallCheck(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,i){for(var e=0;e",marginTop:i.marginTop||0,marginBottom:i.marginBottom||0,stickyFor:i.stickyFor||0,stickyClass:i.stickyClass||null,stickyContainer:i.stickyContainer||"body"},this.updateScrollTopPosition=this.updateScrollTopPosition.bind(this),this.updateScrollTopPosition(),window.addEventListener("load",this.updateScrollTopPosition),window.addEventListener("scroll",this.updateScrollTopPosition),this.run()}return _createClass(e,[{key:"run",value:function(){var i=this,e=setInterval(function(){if("complete"===document.readyState){clearInterval(e);var t=document.querySelectorAll(i.selector);i.forEach(t,function(t){return i.renderElement(t)})}},10)}},{key:"renderElement",value:function(t){var i=this;t.sticky={},t.sticky.active=!1,t.sticky.marginTop=parseInt(t.getAttribute("data-margin-top"))||this.options.marginTop,t.sticky.marginBottom=parseInt(t.getAttribute("data-margin-bottom"))||this.options.marginBottom,t.sticky.stickyFor=parseInt(t.getAttribute("data-sticky-for"))||this.options.stickyFor,t.sticky.stickyClass=t.getAttribute("data-sticky-class")||this.options.stickyClass,t.sticky.wrap=!!t.hasAttribute("data-sticky-wrap")||this.options.wrap,t.sticky.stickyContainer=this.options.stickyContainer,t.sticky.container=this.getStickyContainer(t),t.sticky.container.rect=this.getRectangle(t.sticky.container),t.sticky.rect=this.getRectangle(t),"img"===t.tagName.toLowerCase()&&(t.onload=function(){return t.sticky.rect=i.getRectangle(t)}),t.sticky.wrap&&this.wrapElement(t),this.activate(t)}},{key:"wrapElement",value:function(t){t.insertAdjacentHTML("beforebegin",t.getAttribute("data-sticky-wrapWith")||this.options.wrapWith),t.previousSibling.appendChild(t)}},{key:"activate",value:function(t){t.sticky.rect.top+t.sticky.rect.height=t.sticky.container.rect.top+t.sticky.container.rect.height||t.sticky.stickyFor>=this.vp.width&&t.sticky.active)&&(t.sticky.active=!1),this.setPosition(t)}},{key:"initScrollEvents",value:function(t){var i=this;t.sticky.scrollListener=function(){return i.onScrollEvents(t)},window.addEventListener("scroll",t.sticky.scrollListener)}},{key:"destroyScrollEvents",value:function(t){window.removeEventListener("scroll",t.sticky.scrollListener)}},{key:"onScrollEvents",value:function(t){t.sticky&&t.sticky.active&&this.setPosition(t)}},{key:"setPosition",value:function(t){this.css(t,{position:"",width:"",top:"",left:""}),this.vp.heightt.sticky.rect.top-t.sticky.marginTop?(this.css(t,{position:"fixed",width:t.sticky.rect.width+"px",left:t.sticky.rect.left+"px"}),this.scrollTop+t.sticky.rect.height+t.sticky.marginTop>t.sticky.container.rect.top+t.sticky.container.offsetHeight-t.sticky.marginBottom?(t.sticky.stickyClass&&t.classList.remove(t.sticky.stickyClass),this.css(t,{top:t.sticky.container.rect.top+t.sticky.container.offsetHeight-(this.scrollTop+t.sticky.rect.height+t.sticky.marginBottom)+"px"})):(t.sticky.stickyClass&&t.classList.add(t.sticky.stickyClass),this.css(t,{top:t.sticky.marginTop+"px"}))):(t.sticky.stickyClass&&t.classList.remove(t.sticky.stickyClass),this.css(t,{position:"",width:"",top:"",left:""}),t.sticky.wrap&&this.css(t.parentNode,{display:"",width:"",height:""})))}},{key:"update",value:function(){var i=this;this.forEach(this.elements,function(t){t.sticky.rect=i.getRectangle(t),t.sticky.container.rect=i.getRectangle(t.sticky.container),i.activate(t),i.setPosition(t)})}},{key:"destroy",value:function(){var i=this;window.removeEventListener("load",this.updateScrollTopPosition),window.removeEventListener("scroll",this.updateScrollTopPosition),this.forEach(this.elements,function(t){i.destroyResizeEvents(t),i.destroyScrollEvents(t),delete t.sticky})}},{key:"getStickyContainer",value:function(t){for(var i=t.parentNode;!i.hasAttribute("data-sticky-container")&&!i.parentNode.querySelector(t.sticky.stickyContainer)&&i!==this.body;)i=i.parentNode;return i}},{key:"getRectangle",value:function(t){this.css(t,{position:"",width:"",top:"",left:""});for(var i=Math.max(t.offsetWidth,t.clientWidth,t.scrollWidth),e=Math.max(t.offsetHeight,t.clientHeight,t.scrollHeight),s=0,n=0;s+=t.offsetTop||0,n+=t.offsetLeft||0,t=t.offsetParent;);return{top:s,left:n,width:i,height:e}}},{key:"getViewportSize",value:function(){return{width:Math.max(document.documentElement.clientWidth,window.innerWidth||0),height:Math.max(document.documentElement.clientHeight,window.innerHeight||0)}}},{key:"updateScrollTopPosition",value:function(){this.scrollTop=(window.pageYOffset||document.scrollTop)-(document.clientTop||0)||0}},{key:"forEach",value:function(t,i){for(var e=0,s=t.length;e