Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nrk/core-scroll

Package Overview
Dependencies
Maintainers
88
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nrk/core-scroll - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

2

core-scroll.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.coreScroll=t()}(this,function(){"use strict";var e="undefined"!=typeof window,t=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform)),function(e){void 0===e&&(e=!1);try{window.addEventListener("test",null,{get passive(){e=!0}})}catch(e){}return e}());function o(e,o,n,r){(void 0===r&&(r=!1),"undefined"==typeof window||window[e=e+"-"+o])||(t||"object"!=typeof r||(r=Boolean(r.capture)),("resize"===o||"load"===o?window:document).addEventListener(window[e]=o,n,r))}var n="prevent_recursive_dispatch_maximum_callstack";function r(e,t){var o,n;return function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];var l=this,a=Date.now();o&&a<o+t?(clearTimeout(n),n=setTimeout(function(){o=a,e.apply(l,r)},t)):(o=a,e.apply(l,r))}}function i(e,t){if(void 0===t&&(t=document),e){if(e.nodeType)return[e];if("string"==typeof e)return[].slice.call(t.querySelectorAll(e));if(e.length)return[].slice.call(e)}return[]}var l={},a="data-core-scroll",c="data-@nrk/core-scroll-1.1.4".replace(/\W+/g,"-"),u={up:{y:-1,prop:"top"},down:{y:1,prop:"bottom"},left:{x:-1},right:{x:1}},d=.8,s=20,f=e&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion)").matches,m=!e||window.requestAnimationFrame||window.setTimeout;function p(e,t){void 0===t&&(t="");var o="object"==typeof t?t:{move:t},n="x"in o||"y"in o||o.move;return i(e).map(function(e){if(!e.hasAttribute(c)){e.setAttribute(c,o.friction||""),e.style.overflow="scroll",e.style.willChange="scroll-position",e.style.webkitOverflowScrolling="touch";var t=e.offsetWidth-e.clientWidth+1,r=e.offsetHeight-e.clientHeight+1;e.style.maxHeight="calc(100% + "+r+"px)",e.style.marginRight="-"+t+"px",e.style.marginBottom="-"+r+"px",h(e)}return n&&y(e,function(e,t){var o=t.x,n=t.y,r=t.move,l={x:o,y:n,move:u[r]};"number"!=typeof l.x&&(l.x=e.scrollLeft);"number"!=typeof l.y&&(l.y=e.scrollTop);if(l.move){var a=l.move.x?"x":"y",c=l.move.x?"left":"top",d=e.getBoundingClientRect(),s=d[c]-e[l.move.x?"scrollLeft":"scrollTop"],f=d[c]+d[l.move.x?"width":"height"]*l.move[a];i(e.children).every(function(e){var t=e.getBoundingClientRect(),o=e.ownerDocument.defaultView.getComputedStyle(e)["margin-"+c];return l[a]=t[c]-parseInt(o,10)-s,t[l.move.prop||r]<f})}return l}(e,o)),e})}function v(e){l.preventLink=!0,l.diffX=l.pageX-(l.pageX=e.pageX),l.diffY=l.pageY-(l.pageY=e.pageY),l.target.scrollLeft=l.scrollX+=l.diffX,l.target.scrollTop=l.scrollY+=l.diffY}function g(e){var t=l.diffX||l.diffY;document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",g),document.body.style.cursor="",h(l.target),t&&y(l.target,{x:l.scrollX+l.diffX*s,y:l.scrollY+l.diffY*s}),l.target=null}function h(e){var t=e.target||e;if("resize"===e.type||"load"===e.type)return i("["+c+"]").forEach(h);if(t.hasAttribute&&t.hasAttribute(c)){var o={left:t.scrollLeft,up:t.scrollTop};o.right=t.scrollWidth-t.clientWidth-o.left,o.down=t.scrollHeight-t.clientHeight-o.up;var r=o.left||o.right||o.up||o.down?"grab":"";!function(e,t,o){void 0===o&&(o={});var r,i=""+n+t;!!e[i]||(e[i]=!0,"function"==typeof window.CustomEvent?r=new window.CustomEvent(t,{bubbles:!0,cancelable:!0,detail:o}):(r=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,o),e.dispatchEvent(r),e[i]=null,r.defaultPrevented)}(t,"scroll.change",o),e.type||(t.style.cursor="-webkit-"+r,t.style.cursor=r),t.id&&i("["+a+"]").forEach(function(e){e.getAttribute(a)===t.id&&(e.disabled=!o[e.value])})}}function y(e,t){var o=t.x,n=t.y,r=Math.min(.99,e.getAttribute(c))||d,i=l.animate=Math.floor(Date.now()*Math.random()).toString(16),a=Math.max(0,Math.min(o,e.scrollWidth-e.clientWidth)),u=Math.max(0,Math.min(n,e.scrollHeight-e.clientHeight)),s=f?1:a-e.scrollLeft,p=f?1:u-e.scrollTop,v=function(){l.animate===i&&(Math.round(s)||Math.round(p))&&(e.scrollLeft=a-Math.round(s*=r),e.scrollTop=u-Math.round(p*=r),m(v))};v()}return o(c,"mousedown",function(e){for(var t=e.target;t;t=t.parentElement)!e.defaultPrevented&&t.hasAttribute(c)&&(e.preventDefault(),l.pageX=e.pageX,l.pageY=e.pageY,l.scrollX=t.scrollLeft,l.scrollY=t.scrollTop,l.animate=l.diffX=l.diffY=0,l.target=t,document.body.style.cursor=t.style.cursor="-webkit-grabbing",document.body.style.cursor=t.style.cursor="grabbing",document.addEventListener("mousemove",v),document.addEventListener("mouseup",g))}),o(c,"resize",r(h,500)),o(c,"scroll",r(h,500),!0),o(c,"wheel",function(){return l.animate=!1},{passive:!0}),o(c,"load",h),o(c,"click",function(e){l.preventLink&&(l.preventLink=e.preventDefault());for(var t=e.target;t;t=t.parentElement){var o=t.getAttribute(a);if(o)return p(document.getElementById(o),t.value)}}),p});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.coreScroll=t()}(this,function(){"use strict";var e="undefined"!=typeof window,t=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform)),function(e){void 0===e&&(e=!1);try{window.addEventListener("test",null,{get passive(){e=!0}})}catch(e){}return e}());function o(e,o,n,r){(void 0===r&&(r=!1),"undefined"==typeof window||window[e=e+"-"+o])||(t||"object"!=typeof r||(r=Boolean(r.capture)),("resize"===o||"load"===o?window:document).addEventListener(window[e]=o,n,r))}var n="prevent_recursive_dispatch_maximum_callstack";function r(e,t){var o,n;return function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];var l=this,a=Date.now();o&&a<o+t?(clearTimeout(n),n=setTimeout(function(){o=a,e.apply(l,r)},t)):(o=a,e.apply(l,r))}}function i(e,t){if(void 0===t&&(t=document),e){if(e.nodeType)return[e];if("string"==typeof e)return[].slice.call(t.querySelectorAll(e));if(e.length)return[].slice.call(e)}return[]}var l={},a="data-core-scroll",c="data-@nrk/core-scroll-1.1.5".replace(/\W+/g,"-"),u={up:{y:-1,prop:"top"},down:{y:1,prop:"bottom"},left:{x:-1},right:{x:1}},d=.8,s=20,f=e&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion)").matches,m=!e||window.requestAnimationFrame||window.setTimeout;function p(e,t){void 0===t&&(t="");var o="object"==typeof t?t:{move:t},n="x"in o||"y"in o||o.move;return i(e).map(function(e){if(!e.hasAttribute(c)){e.setAttribute(c,o.friction||""),e.style.overflow="scroll",e.style.willChange="scroll-position",e.style.webkitOverflowScrolling="touch";var t=e.offsetWidth-e.clientWidth+1,r=e.offsetHeight-e.clientHeight+1;e.style.maxHeight="calc(100% + "+r+"px)",e.style.marginRight="-"+t+"px",e.style.marginBottom="-"+r+"px",h(e)}return n&&y(e,function(e,t){var o=t.x,n=t.y,r=t.move,l={x:o,y:n,move:u[r]};"number"!=typeof l.x&&(l.x=e.scrollLeft);"number"!=typeof l.y&&(l.y=e.scrollTop);if(l.move){var a=l.move.x?"x":"y",c=l.move.x?"left":"top",d=e.getBoundingClientRect(),s=d[c]-e[l.move.x?"scrollLeft":"scrollTop"],f=d[c]+d[l.move.x?"width":"height"]*l.move[a];i(e.children).every(function(e){var t=e.getBoundingClientRect(),o=e.ownerDocument.defaultView.getComputedStyle(e)["margin-"+c];return l[a]=t[c]-parseInt(o,10)-s,t[l.move.prop||r]<f})}return l}(e,o)),e})}function v(e){l.preventLink=!0,l.diffX=l.pageX-(l.pageX=e.pageX),l.diffY=l.pageY-(l.pageY=e.pageY),l.target.scrollLeft=l.scrollX+=l.diffX,l.target.scrollTop=l.scrollY+=l.diffY}function g(e){var t=l.diffX||l.diffY;document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",g),document.body.style.cursor="",h(l.target),t&&y(l.target,{x:l.scrollX+l.diffX*s,y:l.scrollY+l.diffY*s}),l.target=null}function h(e){var t=e.target||e;if("resize"===e.type||"load"===e.type)return i("["+c+"]").forEach(h);if(t.hasAttribute&&t.hasAttribute(c)){var o={left:t.scrollLeft,up:t.scrollTop};o.right=t.scrollWidth-t.clientWidth-o.left,o.down=t.scrollHeight-t.clientHeight-o.up;var r=o.left||o.right||o.up||o.down?"grab":"";!function(e,t,o){void 0===o&&(o={});var r,i=""+n+t;if(e[i])return!0;e[i]=!0,"function"==typeof window.CustomEvent?r=new window.CustomEvent(t,{bubbles:!0,cancelable:!0,detail:o}):(r=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,o);var l=e.dispatchEvent(r);e[i]=null}(t,"scroll.change",o),e.type||(t.style.cursor="-webkit-"+r,t.style.cursor=r),t.id&&i("["+a+"]").forEach(function(e){e.getAttribute(a)===t.id&&(e.disabled=!o[e.value])})}}function y(e,t){var o=t.x,n=t.y,r=Math.min(.99,e.getAttribute(c))||d,i=l.animate=Math.floor(Date.now()*Math.random()).toString(16),a=Math.max(0,Math.min(o,e.scrollWidth-e.clientWidth)),u=Math.max(0,Math.min(n,e.scrollHeight-e.clientHeight)),s=f?1:a-e.scrollLeft,p=f?1:u-e.scrollTop,v=function(){l.animate===i&&(Math.round(s)||Math.round(p))&&(e.scrollLeft=a-Math.round(s*=r),e.scrollTop=u-Math.round(p*=r),m(v))};v()}return o(c,"mousedown",function(e){for(var t=e.target;t;t=t.parentElement)!e.defaultPrevented&&t.hasAttribute(c)&&(e.preventDefault(),l.pageX=e.pageX,l.pageY=e.pageY,l.scrollX=t.scrollLeft,l.scrollY=t.scrollTop,l.animate=l.diffX=l.diffY=0,l.target=t,document.body.style.cursor=t.style.cursor="-webkit-grabbing",document.body.style.cursor=t.style.cursor="grabbing",document.addEventListener("mousemove",v),document.addEventListener("mouseup",g))}),o(c,"resize",r(h,500)),o(c,"scroll",r(h,500),!0),o(c,"wheel",function(){return l.animate=!1},{passive:!0}),o(c,"load",h),o(c,"click",function(e){l.preventLink&&(l.preventLink=e.preventDefault());for(var t=e.target;t;t=t.parentElement){var o=t.getAttribute(a);if(o)return p(document.getElementById(o),t.value)}}),p});
//# sourceMappingURL=core-scroll.min.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):t.CoreScroll=e(t.React)}(this,function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e="undefined"!=typeof window,o=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform)),function(t){void 0===t&&(t=!1);try{window.addEventListener("test",null,{get passive(){t=!0}})}catch(t){}return t}());function n(t,e,n,r){(void 0===r&&(r=!1),"undefined"==typeof window||window[t=t+"-"+e])||(o||"object"!=typeof r||(r=Boolean(r.capture)),("resize"===e||"load"===e?window:document).addEventListener(window[t]=e,n,r))}var r="prevent_recursive_dispatch_maximum_callstack";function i(t,e){var o,n;return function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];var l=this,c=Date.now();o&&c<o+e?(clearTimeout(n),n=setTimeout(function(){o=c,t.apply(l,r)},e)):(o=c,t.apply(l,r))}}function l(t,e){if(void 0===e&&(e=document),t){if(t.nodeType)return[t];if("string"==typeof t)return[].slice.call(e.querySelectorAll(t));if(t.length)return[].slice.call(t)}return[]}var c={},a="data-core-scroll",s="data-@nrk/core-scroll-1.1.4".replace(/\W+/g,"-"),u={up:{y:-1,prop:"top"},down:{y:1,prop:"bottom"},left:{x:-1},right:{x:1}},f=.8,d=20,p=e&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion)").matches,h=!e||window.requestAnimationFrame||window.setTimeout;function m(t,e){void 0===e&&(e="");var o="object"==typeof e?e:{move:e},n="x"in o||"y"in o||o.move;return l(t).map(function(t){if(!t.hasAttribute(s)){t.setAttribute(s,o.friction||""),t.style.overflow="scroll",t.style.willChange="scroll-position",t.style.webkitOverflowScrolling="touch";var e=t.offsetWidth-t.clientWidth+1,r=t.offsetHeight-t.clientHeight+1;t.style.maxHeight="calc(100% + "+r+"px)",t.style.marginRight="-"+e+"px",t.style.marginBottom="-"+r+"px",y(t)}return n&&w(t,function(t,e){var o=e.x,n=e.y,r=e.move,i={x:o,y:n,move:u[r]};"number"!=typeof i.x&&(i.x=t.scrollLeft);"number"!=typeof i.y&&(i.y=t.scrollTop);if(i.move){var c=i.move.x?"x":"y",a=i.move.x?"left":"top",s=t.getBoundingClientRect(),f=s[a]-t[i.move.x?"scrollLeft":"scrollTop"],d=s[a]+s[i.move.x?"width":"height"]*i.move[c];l(t.children).every(function(t){var e=t.getBoundingClientRect(),o=t.ownerDocument.defaultView.getComputedStyle(t)["margin-"+a];return i[c]=e[a]-parseInt(o,10)-f,e[i.move.prop||r]<d})}return i}(t,o)),t})}function v(t){c.preventLink=!0,c.diffX=c.pageX-(c.pageX=t.pageX),c.diffY=c.pageY-(c.pageY=t.pageY),c.target.scrollLeft=c.scrollX+=c.diffX,c.target.scrollTop=c.scrollY+=c.diffY}function g(t){var e=c.diffX||c.diffY;document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",g),document.body.style.cursor="",y(c.target),e&&w(c.target,{x:c.scrollX+c.diffX*d,y:c.scrollY+c.diffY*d}),c.target=null}function y(t){var e=t.target||t;if("resize"===t.type||"load"===t.type)return l("["+s+"]").forEach(y);if(e.hasAttribute&&e.hasAttribute(s)){var o={left:e.scrollLeft,up:e.scrollTop};o.right=e.scrollWidth-e.clientWidth-o.left,o.down=e.scrollHeight-e.clientHeight-o.up;var n=o.left||o.right||o.up||o.down?"grab":"";!function(t,e,o){void 0===o&&(o={});var n,i=""+r+e;!!t[i]||(t[i]=!0,"function"==typeof window.CustomEvent?n=new window.CustomEvent(e,{bubbles:!0,cancelable:!0,detail:o}):(n=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,o),t.dispatchEvent(n),t[i]=null,n.defaultPrevented)}(e,"scroll.change",o),t.type||(e.style.cursor="-webkit-"+n,e.style.cursor=n),e.id&&l("["+a+"]").forEach(function(t){t.getAttribute(a)===e.id&&(t.disabled=!o[t.value])})}}function w(t,e){var o=e.x,n=e.y,r=Math.min(.99,t.getAttribute(s))||f,i=c.animate=Math.floor(Date.now()*Math.random()).toString(16),l=Math.max(0,Math.min(o,t.scrollWidth-t.clientWidth)),a=Math.max(0,Math.min(n,t.scrollHeight-t.clientHeight)),u=p?1:l-t.scrollLeft,d=p?1:a-t.scrollTop,m=function(){c.animate===i&&(Math.round(u)||Math.round(d))&&(t.scrollLeft=l-Math.round(u*=r),t.scrollTop=a-Math.round(d*=r),h(m))};m()}n(s,"mousedown",function(t){for(var e=t.target;e;e=e.parentElement)!t.defaultPrevented&&e.hasAttribute(s)&&(t.preventDefault(),c.pageX=t.pageX,c.pageY=t.pageY,c.scrollX=e.scrollLeft,c.scrollY=e.scrollTop,c.animate=c.diffX=c.diffY=0,c.target=e,document.body.style.cursor=e.style.cursor="-webkit-grabbing",document.body.style.cursor=e.style.cursor="grabbing",document.addEventListener("mousemove",v),document.addEventListener("mouseup",g))}),n(s,"resize",i(y,500)),n(s,"scroll",i(y,500),!0),n(s,"wheel",function(){return c.animate=!1},{passive:!0}),n(s,"load",y),n(s,"click",function(t){c.preventLink&&(c.preventLink=t.preventDefault());for(var e=t.target;e;e=e.parentElement){var o=e.getAttribute(a);if(o)return m(document.getElementById(o),e.value)}});var b={onChange:null,friction:null};return function(e){function o(t){var o=this;e.call(this,t),this.onScroll=this.onScroll.bind(this),this.scrollTo=function(t){return m(o.el,t)},this.scrollUp=function(){return m(o.el,"up")},this.scrollDown=function(){return m(o.el,"down")},this.scrollLeft=function(){return m(o.el,"left")},this.scrollRight=function(){return m(o.el,"right")}}return e&&(o.__proto__=e),o.prototype=Object.create(e&&e.prototype),o.prototype.constructor=o,o.prototype.componentDidMount=function(){this.el.addEventListener("scroll.change",this.onScroll),m(this.el,{friction:this.props.friction})},o.prototype.componentDidUpdate=function(){m(this.el)},o.prototype.componentWillUnmount=function(){this.el.removeEventListener("scroll.change",this.onScroll)},o.prototype.onScroll=function(t){var e=t.detail;this.props.onChange&&this.props.onChange({scrollUp:e.up?this.scrollUp:null,scrollDown:e.down?this.scrollDown:null,scrollLeft:e.left?this.scrollLeft:null,scrollRight:e.right?this.scrollRight:null})},o.prototype.render=function(){var e=this,o=function(t,e,o){return void 0===o&&(o={}),Object.keys(t).reduce(function(o,n){return e.hasOwnProperty(n)||(o[n]=t[n]),o},o)}(this.props,b,{ref:function(t){return e.el=t}});return t.createElement("div",o,this.props.children)},o}(t.Component)});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):t.CoreScroll=e(t.React)}(this,function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e="undefined"!=typeof window,o=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform)),function(t){void 0===t&&(t=!1);try{window.addEventListener("test",null,{get passive(){t=!0}})}catch(t){}return t}());function n(t,e,n,r){(void 0===r&&(r=!1),"undefined"==typeof window||window[t=t+"-"+e])||(o||"object"!=typeof r||(r=Boolean(r.capture)),("resize"===e||"load"===e?window:document).addEventListener(window[t]=e,n,r))}var r="prevent_recursive_dispatch_maximum_callstack";function i(t,e){var o,n;return function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];var l=this,c=Date.now();o&&c<o+e?(clearTimeout(n),n=setTimeout(function(){o=c,t.apply(l,r)},e)):(o=c,t.apply(l,r))}}function l(t,e){if(void 0===e&&(e=document),t){if(t.nodeType)return[t];if("string"==typeof t)return[].slice.call(e.querySelectorAll(t));if(t.length)return[].slice.call(t)}return[]}var c={},a="data-core-scroll",s="data-@nrk/core-scroll-1.1.5".replace(/\W+/g,"-"),u={up:{y:-1,prop:"top"},down:{y:1,prop:"bottom"},left:{x:-1},right:{x:1}},f=.8,d=20,p=e&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion)").matches,h=!e||window.requestAnimationFrame||window.setTimeout;function m(t,e){void 0===e&&(e="");var o="object"==typeof e?e:{move:e},n="x"in o||"y"in o||o.move;return l(t).map(function(t){if(!t.hasAttribute(s)){t.setAttribute(s,o.friction||""),t.style.overflow="scroll",t.style.willChange="scroll-position",t.style.webkitOverflowScrolling="touch";var e=t.offsetWidth-t.clientWidth+1,r=t.offsetHeight-t.clientHeight+1;t.style.maxHeight="calc(100% + "+r+"px)",t.style.marginRight="-"+e+"px",t.style.marginBottom="-"+r+"px",y(t)}return n&&w(t,function(t,e){var o=e.x,n=e.y,r=e.move,i={x:o,y:n,move:u[r]};"number"!=typeof i.x&&(i.x=t.scrollLeft);"number"!=typeof i.y&&(i.y=t.scrollTop);if(i.move){var c=i.move.x?"x":"y",a=i.move.x?"left":"top",s=t.getBoundingClientRect(),f=s[a]-t[i.move.x?"scrollLeft":"scrollTop"],d=s[a]+s[i.move.x?"width":"height"]*i.move[c];l(t.children).every(function(t){var e=t.getBoundingClientRect(),o=t.ownerDocument.defaultView.getComputedStyle(t)["margin-"+a];return i[c]=e[a]-parseInt(o,10)-f,e[i.move.prop||r]<d})}return i}(t,o)),t})}function v(t){c.preventLink=!0,c.diffX=c.pageX-(c.pageX=t.pageX),c.diffY=c.pageY-(c.pageY=t.pageY),c.target.scrollLeft=c.scrollX+=c.diffX,c.target.scrollTop=c.scrollY+=c.diffY}function g(t){var e=c.diffX||c.diffY;document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",g),document.body.style.cursor="",y(c.target),e&&w(c.target,{x:c.scrollX+c.diffX*d,y:c.scrollY+c.diffY*d}),c.target=null}function y(t){var e=t.target||t;if("resize"===t.type||"load"===t.type)return l("["+s+"]").forEach(y);if(e.hasAttribute&&e.hasAttribute(s)){var o={left:e.scrollLeft,up:e.scrollTop};o.right=e.scrollWidth-e.clientWidth-o.left,o.down=e.scrollHeight-e.clientHeight-o.up;var n=o.left||o.right||o.up||o.down?"grab":"";!function(t,e,o){void 0===o&&(o={});var n,i=""+r+e;if(t[i])return!0;t[i]=!0,"function"==typeof window.CustomEvent?n=new window.CustomEvent(e,{bubbles:!0,cancelable:!0,detail:o}):(n=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,o);var l=t.dispatchEvent(n);t[i]=null}(e,"scroll.change",o),t.type||(e.style.cursor="-webkit-"+n,e.style.cursor=n),e.id&&l("["+a+"]").forEach(function(t){t.getAttribute(a)===e.id&&(t.disabled=!o[t.value])})}}function w(t,e){var o=e.x,n=e.y,r=Math.min(.99,t.getAttribute(s))||f,i=c.animate=Math.floor(Date.now()*Math.random()).toString(16),l=Math.max(0,Math.min(o,t.scrollWidth-t.clientWidth)),a=Math.max(0,Math.min(n,t.scrollHeight-t.clientHeight)),u=p?1:l-t.scrollLeft,d=p?1:a-t.scrollTop,m=function(){c.animate===i&&(Math.round(u)||Math.round(d))&&(t.scrollLeft=l-Math.round(u*=r),t.scrollTop=a-Math.round(d*=r),h(m))};m()}n(s,"mousedown",function(t){for(var e=t.target;e;e=e.parentElement)!t.defaultPrevented&&e.hasAttribute(s)&&(t.preventDefault(),c.pageX=t.pageX,c.pageY=t.pageY,c.scrollX=e.scrollLeft,c.scrollY=e.scrollTop,c.animate=c.diffX=c.diffY=0,c.target=e,document.body.style.cursor=e.style.cursor="-webkit-grabbing",document.body.style.cursor=e.style.cursor="grabbing",document.addEventListener("mousemove",v),document.addEventListener("mouseup",g))}),n(s,"resize",i(y,500)),n(s,"scroll",i(y,500),!0),n(s,"wheel",function(){return c.animate=!1},{passive:!0}),n(s,"load",y),n(s,"click",function(t){c.preventLink&&(c.preventLink=t.preventDefault());for(var e=t.target;e;e=e.parentElement){var o=e.getAttribute(a);if(o)return m(document.getElementById(o),e.value)}});var b={onChange:null,friction:null};return function(e){function o(t){var o=this;e.call(this,t),this.onScroll=this.onScroll.bind(this),this.scrollTo=function(t){return m(o.el,t)},this.scrollUp=function(){return m(o.el,"up")},this.scrollDown=function(){return m(o.el,"down")},this.scrollLeft=function(){return m(o.el,"left")},this.scrollRight=function(){return m(o.el,"right")}}return e&&(o.__proto__=e),o.prototype=Object.create(e&&e.prototype),o.prototype.constructor=o,o.prototype.componentDidMount=function(){this.el.addEventListener("scroll.change",this.onScroll),m(this.el,{friction:this.props.friction})},o.prototype.componentDidUpdate=function(){m(this.el)},o.prototype.componentWillUnmount=function(){this.el.removeEventListener("scroll.change",this.onScroll)},o.prototype.onScroll=function(t){var e=t.detail;this.props.onChange&&this.props.onChange({scrollUp:e.up?this.scrollUp:null,scrollDown:e.down?this.scrollDown:null,scrollLeft:e.left?this.scrollLeft:null,scrollRight:e.right?this.scrollRight:null})},o.prototype.render=function(){var e=this,o=function(t,e,o){return void 0===o&&(o={}),Object.keys(t).reduce(function(o,n){return e.hasOwnProperty(n)||(o[n]=t[n]),o},o)}(this.props,b,{ref:function(t){return e.el=t}});return t.createElement("div",o,this.props.children)},o}(t.Component)});
//# sourceMappingURL=index.js.map

@@ -5,3 +5,3 @@ {

"author": "NRK <opensource@nrk.no> (https://www.nrk.no/)",
"version": "1.1.5",
"version": "1.1.6",
"license": "MIT",

@@ -8,0 +8,0 @@ "main": "core-scroll.min.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc