@nrk/core-scroll
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -67,2 +67,3 @@ import {name, version} from './package.json' | ||
function onMousemove (event) { | ||
DRAG.preventLink = true // Prevent links when we know there has been movement | ||
DRAG.diffX = DRAG.pageX - (DRAG.pageX = event.pageX) | ||
@@ -83,2 +84,3 @@ DRAG.diffY = DRAG.pageY - (DRAG.pageY = event.pageY) | ||
}) | ||
DRAG.target = null // Prevent memory leak | ||
} | ||
@@ -110,2 +112,3 @@ | ||
function onClick (event) { | ||
if (DRAG.preventLink) DRAG.preventLink = event.preventDefault() | ||
for (let el = event.target; el; el = el.parentElement) { | ||
@@ -112,0 +115,0 @@ const id = el.getAttribute(ATTR) |
@@ -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?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.0".replace(/\W+/g,"-"),u={up:{y:-1,prop:"top"},down:{y:1,prop:"bottom"},left:{x:-1},right:{x:1}},s=.8,d=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,r=e.offsetHeight-e.clientHeight;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",s=e.getBoundingClientRect(),d=s[c]-e[l.move.x?"scrollLeft":"scrollTop"],f=s[c]+s[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)-d,t[l.move.prop||r]<f})}return l}(e,o)),e})}function v(e){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){document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",g),document.body.style.cursor="",h(l.target),y(l.target,{x:l.scrollX+l.diffX*d,y:l.scrollY+l.diffY*d})}function h(e){var t=e.target||e;if("resize"===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))||s,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)),d=f?1:a-e.scrollLeft,p=f?1:u-e.scrollTop,v=function(){l.animate===i&&(Math.round(d)||Math.round(p))&&(e.scrollLeft=a-Math.round(d*=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,"click",function(e){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?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.1".replace(/\W+/g,"-"),u={up:{y:-1,prop:"top"},down:{y:1,prop:"bottom"},left:{x:-1},right:{x:1}},s=.8,d=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,r=e.offsetHeight-e.clientHeight;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",s=e.getBoundingClientRect(),d=s[c]-e[l.move.x?"scrollLeft":"scrollTop"],f=s[c]+s[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)-d,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){document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",g),document.body.style.cursor="",h(l.target),y(l.target,{x:l.scrollX+l.diffX*d,y:l.scrollY+l.diffY*d}),l.target=null}function h(e){var t=e.target||e;if("resize"===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))||s,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)),d=f?1:a-e.scrollLeft,p=f?1:u-e.scrollTop,v=function(){l.animate===i&&(Math.round(d)||Math.round(p))&&(e.scrollLeft=a-Math.round(d*=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,"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?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={},s="data-core-scroll",u="data-@nrk/core-scroll-1.1.0".replace(/\W+/g,"-"),a={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(u)){t.setAttribute(u,o.friction||""),t.style.overflow="scroll",t.style.willChange="scroll-position",t.style.webkitOverflowScrolling="touch";var e=t.offsetWidth-t.clientWidth,r=t.offsetHeight-t.clientHeight;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:a[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",s=i.move.x?"left":"top",u=t.getBoundingClientRect(),f=u[s]-t[i.move.x?"scrollLeft":"scrollTop"],d=u[s]+u[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-"+s];return i[c]=e[s]-parseInt(o,10)-f,e[i.move.prop||r]<d})}return i}(t,o)),t})}function v(t){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){document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",g),document.body.style.cursor="",y(c.target),w(c.target,{x:c.scrollX+c.diffX*d,y:c.scrollY+c.diffY*d})}function y(t){var e=t.target||t;if("resize"===t.type)return l("["+u+"]").forEach(y);if(e.hasAttribute&&e.hasAttribute(u)){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("["+s+"]").forEach(function(t){t.getAttribute(s)===e.id&&(t.disabled=!o[t.value])})}}function w(t,e){var o=e.x,n=e.y,r=Math.min(.99,t.getAttribute(u))||f,i=c.animate=Math.floor(Date.now()*Math.random()).toString(16),l=Math.max(0,Math.min(o,t.scrollWidth-t.clientWidth)),s=Math.max(0,Math.min(n,t.scrollHeight-t.clientHeight)),a=p?1:l-t.scrollLeft,d=p?1:s-t.scrollTop,m=function(){c.animate===i&&(Math.round(a)||Math.round(d))&&(t.scrollLeft=l-Math.round(a*=r),t.scrollTop=s-Math.round(d*=r),h(m))};m()}n(u,"mousedown",function(t){for(var e=t.target;e;e=e.parentElement)!t.defaultPrevented&&e.hasAttribute(u)&&(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(u,"resize",i(y,500)),n(u,"scroll",i(y,500),!0),n(u,"wheel",function(){return c.animate=!1},{passive:!0}),n(u,"click",function(t){for(var e=t.target;e;e=e.parentElement){var o=e.getAttribute(s);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?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={},s="data-core-scroll",u="data-@nrk/core-scroll-1.1.1".replace(/\W+/g,"-"),a={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(u)){t.setAttribute(u,o.friction||""),t.style.overflow="scroll",t.style.willChange="scroll-position",t.style.webkitOverflowScrolling="touch";var e=t.offsetWidth-t.clientWidth,r=t.offsetHeight-t.clientHeight;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:a[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",s=i.move.x?"left":"top",u=t.getBoundingClientRect(),f=u[s]-t[i.move.x?"scrollLeft":"scrollTop"],d=u[s]+u[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-"+s];return i[c]=e[s]-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){document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",g),document.body.style.cursor="",y(c.target),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)return l("["+u+"]").forEach(y);if(e.hasAttribute&&e.hasAttribute(u)){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("["+s+"]").forEach(function(t){t.getAttribute(s)===e.id&&(t.disabled=!o[t.value])})}}function w(t,e){var o=e.x,n=e.y,r=Math.min(.99,t.getAttribute(u))||f,i=c.animate=Math.floor(Date.now()*Math.random()).toString(16),l=Math.max(0,Math.min(o,t.scrollWidth-t.clientWidth)),s=Math.max(0,Math.min(n,t.scrollHeight-t.clientHeight)),a=p?1:l-t.scrollLeft,d=p?1:s-t.scrollTop,m=function(){c.animate===i&&(Math.round(a)||Math.round(d))&&(t.scrollLeft=l-Math.round(a*=r),t.scrollTop=s-Math.round(d*=r),h(m))};m()}n(u,"mousedown",function(t){for(var e=t.target;e;e=e.parentElement)!t.defaultPrevented&&e.hasAttribute(u)&&(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(u,"resize",i(y,500)),n(u,"scroll",i(y,500),!0),n(u,"wheel",function(){return c.animate=!1},{passive:!0}),n(u,"click",function(t){c.preventLink&&(c.preventLink=t.preventDefault());for(var e=t.target;e;e=e.parentElement){var o=e.getAttribute(s);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.1", | ||
"version": "1.1.2", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60511
214