handy-scroll 1.1.4 → 1.1.5

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.
package/README.md CHANGED
@@ -6,10 +6,9 @@ Handy dependency-free floating scrollbar widget
6
6
 
7
7
  handy-scroll is a dependency-free module which can be used to solve the problem of scrolling some lengthy containers horizontally when those containers don’t fit into the viewport. The widget is just a scrollbar which is attached at the bottom of the container’s visible area. It doesn’t get out of sight when the page is scrolled, thereby making horizontal scrolling of the container much handier.
8
8
 
9
- :bulb: **Tips:**
10
-
11
- * If you are rather looking for a jQuery plugin with the same functionality, please check out the sibling project [floating-scroll](https://github.com/Amphiluke/floating-scroll) instead.
12
- * Developing a Vue-based app? Consider using the [vue-handy-scroll](https://github.com/Amphiluke/vue-handy-scroll) component.
9
+ > [!TIP]
10
+ > * If you are rather looking for a jQuery plugin with the same functionality, please check out the sibling project [floating-scroll](https://github.com/Amphiluke/floating-scroll) instead.
11
+ > * Developing a Vue.js-based app? Consider using the [vue-handy-scroll](https://github.com/Amphiluke/vue-handy-scroll) component.
13
12
 
14
13
  ## Usage
15
14
 
@@ -1,7 +1,7 @@
1
1
  /*!
2
- handy-scroll v1.1.4
2
+ handy-scroll v1.1.5
3
3
  https://amphiluke.github.io/handy-scroll/
4
- (c) 2023 Amphiluke
4
+ (c) 2024 Amphiluke
5
5
  */
6
6
  (function (global, factory) {
7
7
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -189,7 +189,7 @@ https://amphiluke.github.io/handy-scroll/
189
189
  instance.eventHandlers.forEach(({el, handlers}) => {
190
190
  Object.keys(handlers).forEach(event => el.removeEventListener(event, handlers[event], false));
191
191
  });
192
- instance.widget.parentNode.removeChild(instance.widget);
192
+ instance.widget.remove();
193
193
  instance.eventHandlers = instance.widget = instance.container = instance.scrollBody = null;
194
194
  }
195
195
  };
@@ -1,6 +1,6 @@
1
1
  /*!
2
- handy-scroll v1.1.4
2
+ handy-scroll v1.1.5
3
3
  https://amphiluke.github.io/handy-scroll/
4
- (c) 2023 Amphiluke
4
+ (c) 2024 Amphiluke
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).handyScroll=t()}(this,(function(){"use strict";let e=Array.prototype.slice,t={isDOMAvailable:"object"==typeof document&&!!document.documentElement,ready(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>{e()}),{once:!0}):e()},$:e=>"string"==typeof e?document.body.querySelector(e):e,$$:t=>Array.isArray(t)?t:t.nodeType===Node.ELEMENT_NODE?[t]:"string"==typeof t?e.call(document.body.querySelectorAll(t)):e.call(t)},n={init(e){let n=this,i=t.$$(".handy-scroll-body").filter((t=>t.contains(e)));i.length&&(n.scrollBody=i[0]),n.container=e,n.visible=!0,n.initWidget(),n.update(),n.addEventHandlers(),n.skipSyncContainer=n.skipSyncWidget=!1},initWidget(){let e=this,t=e.widget=document.createElement("div");t.classList.add("handy-scroll");let n=document.createElement("div");n.style.width=`${e.container.scrollWidth}px`,t.appendChild(n),e.container.appendChild(t)},addEventHandlers(){let e=this;(e.eventHandlers=[{el:e.scrollBody||window,handlers:{scroll(){e.checkVisibility()},resize(){e.update()}}},{el:e.widget,handlers:{scroll(){e.visible&&!e.skipSyncContainer&&e.syncContainer(),e.skipSyncContainer=!1}}},{el:e.container,handlers:{scroll(){e.skipSyncWidget||e.syncWidget(),e.skipSyncWidget=!1},focusin(){setTimeout((()=>{e.widget&&e.syncWidget()}),0)}}}]).forEach((({el:e,handlers:t})=>{Object.keys(t).forEach((n=>e.addEventListener(n,t[n],!1)))}))},checkVisibility(){let e=this,{widget:t,container:n,scrollBody:i}=e,l=t.scrollWidth<=t.offsetWidth;if(!l){let e=n.getBoundingClientRect(),t=i?i.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight;l=e.bottom<=t||e.top>t}e.visible===l&&(e.visible=!l,t.classList.toggle("handy-scroll-hidden"))},syncContainer(){let e=this,{scrollLeft:t}=e.widget;e.container.scrollLeft!==t&&(e.skipSyncWidget=!0,e.container.scrollLeft=t)},syncWidget(){let e=this,{scrollLeft:t}=e.container;e.widget.scrollLeft!==t&&(e.skipSyncContainer=!0,e.widget.scrollLeft=t)},update(){let e=this,{widget:t,container:n,scrollBody:i}=e,{clientWidth:l,scrollWidth:o}=n;t.style.width=`${l}px`,i||(t.style.left=`${n.getBoundingClientRect().left}px`),t.firstElementChild.style.width=`${o}px`,o>l&&(t.style.height=t.offsetHeight-t.clientHeight+1+"px"),e.syncWidget(),e.checkVisibility()},destroy(){let e=this;e.eventHandlers.forEach((({el:e,handlers:t})=>{Object.keys(t).forEach((n=>e.removeEventListener(n,t[n],!1)))})),e.widget.parentNode.removeChild(e.widget),e.eventHandlers=e.widget=e.container=e.scrollBody=null}},i=[],l={mount(e){t.$$(e).forEach((e=>{if(l.mounted(e))return;let t=Object.create(n);i.push(t),t.init(e)}))},mounted(e){let n=t.$(e);return i.some((e=>e.container===n))},update(e){t.$$(e).forEach((e=>{i.some((t=>t.container===e&&(t.update(),!0)))}))},destroy(e){t.$$(e).forEach((e=>{i.some(((t,n)=>t.container===e&&(i.splice(n,1)[0].destroy(),!0)))}))},destroyDetached(){i=i.filter((e=>!!document.body.contains(e.container)||(e.destroy(),!1)))}};return t.isDOMAvailable&&t.ready((()=>{l.mount("[data-handy-scroll]")})),l}));
6
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).handyScroll=t()}(this,(function(){"use strict";let e=Array.prototype.slice,t={isDOMAvailable:"object"==typeof document&&!!document.documentElement,ready(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>{e()}),{once:!0}):e()},$:e=>"string"==typeof e?document.body.querySelector(e):e,$$:t=>Array.isArray(t)?t:t.nodeType===Node.ELEMENT_NODE?[t]:"string"==typeof t?e.call(document.body.querySelectorAll(t)):e.call(t)},n={init(e){let n=this,i=t.$$(".handy-scroll-body").filter((t=>t.contains(e)));i.length&&(n.scrollBody=i[0]),n.container=e,n.visible=!0,n.initWidget(),n.update(),n.addEventHandlers(),n.skipSyncContainer=n.skipSyncWidget=!1},initWidget(){let e=this,t=e.widget=document.createElement("div");t.classList.add("handy-scroll");let n=document.createElement("div");n.style.width=`${e.container.scrollWidth}px`,t.appendChild(n),e.container.appendChild(t)},addEventHandlers(){let e=this;(e.eventHandlers=[{el:e.scrollBody||window,handlers:{scroll(){e.checkVisibility()},resize(){e.update()}}},{el:e.widget,handlers:{scroll(){e.visible&&!e.skipSyncContainer&&e.syncContainer(),e.skipSyncContainer=!1}}},{el:e.container,handlers:{scroll(){e.skipSyncWidget||e.syncWidget(),e.skipSyncWidget=!1},focusin(){setTimeout((()=>{e.widget&&e.syncWidget()}),0)}}}]).forEach((({el:e,handlers:t})=>{Object.keys(t).forEach((n=>e.addEventListener(n,t[n],!1)))}))},checkVisibility(){let e=this,{widget:t,container:n,scrollBody:i}=e,l=t.scrollWidth<=t.offsetWidth;if(!l){let e=n.getBoundingClientRect(),t=i?i.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight;l=e.bottom<=t||e.top>t}e.visible===l&&(e.visible=!l,t.classList.toggle("handy-scroll-hidden"))},syncContainer(){let e=this,{scrollLeft:t}=e.widget;e.container.scrollLeft!==t&&(e.skipSyncWidget=!0,e.container.scrollLeft=t)},syncWidget(){let e=this,{scrollLeft:t}=e.container;e.widget.scrollLeft!==t&&(e.skipSyncContainer=!0,e.widget.scrollLeft=t)},update(){let e=this,{widget:t,container:n,scrollBody:i}=e,{clientWidth:l,scrollWidth:o}=n;t.style.width=`${l}px`,i||(t.style.left=`${n.getBoundingClientRect().left}px`),t.firstElementChild.style.width=`${o}px`,o>l&&(t.style.height=t.offsetHeight-t.clientHeight+1+"px"),e.syncWidget(),e.checkVisibility()},destroy(){let e=this;e.eventHandlers.forEach((({el:e,handlers:t})=>{Object.keys(t).forEach((n=>e.removeEventListener(n,t[n],!1)))})),e.widget.remove(),e.eventHandlers=e.widget=e.container=e.scrollBody=null}},i=[],l={mount(e){t.$$(e).forEach((e=>{if(l.mounted(e))return;let t=Object.create(n);i.push(t),t.init(e)}))},mounted(e){let n=t.$(e);return i.some((e=>e.container===n))},update(e){t.$$(e).forEach((e=>{i.some((t=>t.container===e&&(t.update(),!0)))}))},destroy(e){t.$$(e).forEach((e=>{i.some(((t,n)=>t.container===e&&(i.splice(n,1)[0].destroy(),!0)))}))},destroyDetached(){i=i.filter((e=>!!document.body.contains(e.container)||(e.destroy(),!1)))}};return t.isDOMAvailable&&t.ready((()=>{l.mount("[data-handy-scroll]")})),l}));
@@ -1,7 +1,7 @@
1
1
  /*!
2
- handy-scroll v1.1.4
2
+ handy-scroll v1.1.5
3
3
  https://amphiluke.github.io/handy-scroll/
4
- (c) 2023 Amphiluke
4
+ (c) 2024 Amphiluke
5
5
  */
6
6
  (function (global, factory) {
7
7
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -181,7 +181,6 @@ https://amphiluke.github.io/handy-scroll/
181
181
  if (scrollWidth > clientWidth) {
182
182
  widget.style.height = widget.offsetHeight - widget.clientHeight + 1 + "px"; // +1px JIC
183
183
  }
184
-
185
184
  instance.syncWidget();
186
185
  instance.checkVisibility(); // fixes issue Amphiluke/floating-scroll#2
187
186
  },
@@ -195,7 +194,7 @@ https://amphiluke.github.io/handy-scroll/
195
194
  return el.removeEventListener(event, handlers[event], false);
196
195
  });
197
196
  });
198
- instance.widget.parentNode.removeChild(instance.widget);
197
+ instance.widget.remove();
199
198
  instance.eventHandlers = instance.widget = instance.container = instance.scrollBody = null;
200
199
  }
201
200
  };
@@ -1,6 +1,6 @@
1
1
  /*!
2
- handy-scroll v1.1.4
2
+ handy-scroll v1.1.5
3
3
  https://amphiluke.github.io/handy-scroll/
4
- (c) 2023 Amphiluke
4
+ (c) 2024 Amphiluke
5
5
  */
6
- !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).handyScroll=n()}(this,(function(){"use strict";var t=Array.prototype.slice,n="object"==typeof document&&!!document.documentElement,e=function(t){return"string"==typeof t?document.body.querySelector(t):t},i=function(n){return Array.isArray(n)?n:n.nodeType===Node.ELEMENT_NODE?[n]:"string"==typeof n?t.call(document.body.querySelectorAll(n)):t.call(n)},o={init:function(t){var n=this,e=i(".handy-scroll-body").filter((function(n){return n.contains(t)}));e.length&&(n.scrollBody=e[0]),n.container=t,n.visible=!0,n.initWidget(),n.update(),n.addEventHandlers(),n.skipSyncContainer=n.skipSyncWidget=!1},initWidget:function(){var t=this,n=t.widget=document.createElement("div");n.classList.add("handy-scroll");var e=document.createElement("div");e.style.width=t.container.scrollWidth+"px",n.appendChild(e),t.container.appendChild(n)},addEventHandlers:function(){var t=this;(t.eventHandlers=[{el:t.scrollBody||window,handlers:{scroll:function(){t.checkVisibility()},resize:function(){t.update()}}},{el:t.widget,handlers:{scroll:function(){t.visible&&!t.skipSyncContainer&&t.syncContainer(),t.skipSyncContainer=!1}}},{el:t.container,handlers:{scroll:function(){t.skipSyncWidget||t.syncWidget(),t.skipSyncWidget=!1},focusin:function(){setTimeout((function(){t.widget&&t.syncWidget()}),0)}}}]).forEach((function(t){var n=t.el,e=t.handlers;Object.keys(e).forEach((function(t){return n.addEventListener(t,e[t],!1)}))}))},checkVisibility:function(){var t=this,n=t.widget,e=t.container,i=t.scrollBody,o=n.scrollWidth<=n.offsetWidth;if(!o){var c=e.getBoundingClientRect(),r=i?i.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight;o=c.bottom<=r||c.top>r}t.visible===o&&(t.visible=!o,n.classList.toggle("handy-scroll-hidden"))},syncContainer:function(){var t=this,n=t.widget.scrollLeft;t.container.scrollLeft!==n&&(t.skipSyncWidget=!0,t.container.scrollLeft=n)},syncWidget:function(){var t=this,n=t.container.scrollLeft;t.widget.scrollLeft!==n&&(t.skipSyncContainer=!0,t.widget.scrollLeft=n)},update:function(){var t=this,n=t.widget,e=t.container,i=t.scrollBody,o=e.clientWidth,c=e.scrollWidth;n.style.width=o+"px",i||(n.style.left=e.getBoundingClientRect().left+"px"),n.firstElementChild.style.width=c+"px",c>o&&(n.style.height=n.offsetHeight-n.clientHeight+1+"px"),t.syncWidget(),t.checkVisibility()},destroy:function(){var t=this;t.eventHandlers.forEach((function(t){var n=t.el,e=t.handlers;Object.keys(e).forEach((function(t){return n.removeEventListener(t,e[t],!1)}))})),t.widget.parentNode.removeChild(t.widget),t.eventHandlers=t.widget=t.container=t.scrollBody=null}},c=[],r={mount:function(t){i(t).forEach((function(t){if(!r.mounted(t)){var n=Object.create(o);c.push(n),n.init(t)}}))},mounted:function(t){var n=e(t);return c.some((function(t){return t.container===n}))},update:function(t){i(t).forEach((function(t){c.some((function(n){return n.container===t&&(n.update(),!0)}))}))},destroy:function(t){i(t).forEach((function(t){c.some((function(n,e){return n.container===t&&(c.splice(e,1)[0].destroy(),!0)}))}))},destroyDetached:function(){c=c.filter((function(t){return!!document.body.contains(t.container)||(t.destroy(),!1)}))}};return n&&function(t){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(function(){t()}),{once:!0}):t()}((function(){r.mount("[data-handy-scroll]")})),r}));
6
+ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).handyScroll=n()}(this,(function(){"use strict";var t=Array.prototype.slice,n="object"==typeof document&&!!document.documentElement,e=function(t){return"string"==typeof t?document.body.querySelector(t):t},i=function(n){return Array.isArray(n)?n:n.nodeType===Node.ELEMENT_NODE?[n]:"string"==typeof n?t.call(document.body.querySelectorAll(n)):t.call(n)},o={init:function(t){var n=this,e=i(".handy-scroll-body").filter((function(n){return n.contains(t)}));e.length&&(n.scrollBody=e[0]),n.container=t,n.visible=!0,n.initWidget(),n.update(),n.addEventHandlers(),n.skipSyncContainer=n.skipSyncWidget=!1},initWidget:function(){var t=this,n=t.widget=document.createElement("div");n.classList.add("handy-scroll");var e=document.createElement("div");e.style.width=t.container.scrollWidth+"px",n.appendChild(e),t.container.appendChild(n)},addEventHandlers:function(){var t=this;(t.eventHandlers=[{el:t.scrollBody||window,handlers:{scroll:function(){t.checkVisibility()},resize:function(){t.update()}}},{el:t.widget,handlers:{scroll:function(){t.visible&&!t.skipSyncContainer&&t.syncContainer(),t.skipSyncContainer=!1}}},{el:t.container,handlers:{scroll:function(){t.skipSyncWidget||t.syncWidget(),t.skipSyncWidget=!1},focusin:function(){setTimeout((function(){t.widget&&t.syncWidget()}),0)}}}]).forEach((function(t){var n=t.el,e=t.handlers;Object.keys(e).forEach((function(t){return n.addEventListener(t,e[t],!1)}))}))},checkVisibility:function(){var t=this,n=t.widget,e=t.container,i=t.scrollBody,o=n.scrollWidth<=n.offsetWidth;if(!o){var c=e.getBoundingClientRect(),r=i?i.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight;o=c.bottom<=r||c.top>r}t.visible===o&&(t.visible=!o,n.classList.toggle("handy-scroll-hidden"))},syncContainer:function(){var t=this,n=t.widget.scrollLeft;t.container.scrollLeft!==n&&(t.skipSyncWidget=!0,t.container.scrollLeft=n)},syncWidget:function(){var t=this,n=t.container.scrollLeft;t.widget.scrollLeft!==n&&(t.skipSyncContainer=!0,t.widget.scrollLeft=n)},update:function(){var t=this,n=t.widget,e=t.container,i=t.scrollBody,o=e.clientWidth,c=e.scrollWidth;n.style.width=o+"px",i||(n.style.left=e.getBoundingClientRect().left+"px"),n.firstElementChild.style.width=c+"px",c>o&&(n.style.height=n.offsetHeight-n.clientHeight+1+"px"),t.syncWidget(),t.checkVisibility()},destroy:function(){var t=this;t.eventHandlers.forEach((function(t){var n=t.el,e=t.handlers;Object.keys(e).forEach((function(t){return n.removeEventListener(t,e[t],!1)}))})),t.widget.remove(),t.eventHandlers=t.widget=t.container=t.scrollBody=null}},c=[],r={mount:function(t){i(t).forEach((function(t){if(!r.mounted(t)){var n=Object.create(o);c.push(n),n.init(t)}}))},mounted:function(t){var n=e(t);return c.some((function(t){return t.container===n}))},update:function(t){i(t).forEach((function(t){c.some((function(n){return n.container===t&&(n.update(),!0)}))}))},destroy:function(t){i(t).forEach((function(t){c.some((function(n,e){return n.container===t&&(c.splice(e,1)[0].destroy(),!0)}))}))},destroyDetached:function(){c=c.filter((function(t){return!!document.body.contains(t.container)||(t.destroy(),!1)}))}};return n&&function(t){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(function(){t()}),{once:!0}):t()}((function(){r.mount("[data-handy-scroll]")})),r}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "handy-scroll",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Handy dependency-free floating scrollbar widget",
5
5
  "main": "./dist/handy-scroll.min.js",
6
6
  "module": "./src/handy-scroll.js",
@@ -41,14 +41,14 @@
41
41
  },
42
42
  "homepage": "https://amphiluke.github.io/handy-scroll/",
43
43
  "devDependencies": {
44
- "@babel/core": "^7.23.0",
45
- "@babel/preset-env": "^7.22.20",
46
- "@rollup/plugin-babel": "^6.0.3",
47
- "@rollup/plugin-terser": "^0.4.3",
48
- "clean-css-cli": "^5.6.2",
49
- "eslint": "^8.50.0",
44
+ "@babel/core": "^7.23.7",
45
+ "@babel/preset-env": "^7.23.8",
46
+ "@rollup/plugin-babel": "^6.0.4",
47
+ "@rollup/plugin-terser": "^0.4.4",
48
+ "clean-css-cli": "^5.6.3",
49
+ "eslint": "^8.56.0",
50
50
  "husky": "8.0.3",
51
51
  "less": "^4.2.0",
52
- "rollup": "^3.29.4"
52
+ "rollup": "^4.9.5"
53
53
  }
54
54
  }
@@ -145,7 +145,7 @@ let handyScrollProto = {
145
145
  instance.eventHandlers.forEach(({el, handlers}) => {
146
146
  Object.keys(handlers).forEach(event => el.removeEventListener(event, handlers[event], false));
147
147
  });
148
- instance.widget.parentNode.removeChild(instance.widget);
148
+ instance.widget.remove();
149
149
  instance.eventHandlers = instance.widget = instance.container = instance.scrollBody = null;
150
150
  }
151
151
  };