@nrk/core-scroll
Advanced tools
Comparing version 4.1.0 to 4.1.1
@@ -157,13 +157,4 @@ 'use strict'; | ||
var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Polyfill toggleAttribute for IE | ||
var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Mock HTMLElement for Node | ||
if (IS_BROWSER && !window.Element.prototype.toggleAttribute) { | ||
window.Element.prototype.toggleAttribute = function (name) { | ||
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !this.hasAttribute(name); | ||
if (!force === this.hasAttribute(name)) this[force ? 'setAttribute' : 'removeAttribute'](name, ''); | ||
return force; | ||
}; | ||
} // Mock HTMLElement for Node | ||
if (!IS_BROWSER && !global.HTMLElement) { | ||
@@ -276,2 +267,3 @@ global.HTMLElement = | ||
* @param {String|NodeList|Array|Element} elements A CSS selector string, nodeList, element array, or single element | ||
* @param {Element} context Node to look for elements within | ||
* @return {Element[]} Array of elements | ||
@@ -448,7 +440,7 @@ */ | ||
return queryAll(this.getAttribute('items') || this.children, this); | ||
}, | ||
} // Ensure falsy values becomes '' | ||
, | ||
set: function set(val) { | ||
this.setAttribute('items', val || ''); | ||
} // Ensure falsy values becomes '' | ||
} | ||
}, { | ||
@@ -463,3 +455,4 @@ key: "scrollRight", | ||
return this.scrollHeight - this.clientHeight - this.scrollTop; | ||
} | ||
} // Avoid friction 1 (infinite) | ||
}, { | ||
@@ -469,4 +462,3 @@ key: "friction", | ||
return Math.min(0.99, this.getAttribute('friction')) || 0.8; | ||
} // Avoid friction 1 (infinite) | ||
, | ||
}, | ||
set: function set(val) { | ||
@@ -473,0 +465,0 @@ this.setAttribute('friction', val); |
@@ -46,2 +46,3 @@ import { IS_BROWSER, addStyle, closest, dispatchEvent, throttle, getUUID, queryAll } from '../utils' | ||
} | ||
disconnectedCallback () { | ||
@@ -56,2 +57,3 @@ this._throttledEvent = null // Garbage collection | ||
} | ||
handleEvent (event = {}) { | ||
@@ -77,2 +79,3 @@ if (event.defaultPrevented) return | ||
} | ||
scroll (point) { | ||
@@ -96,6 +99,13 @@ const { x, y } = parsePoint(this, point) | ||
get items () { return queryAll(this.getAttribute('items') || this.children, this) } | ||
set items (val) { this.setAttribute('items', val || '') } // Ensure falsy values becomes '' | ||
// Ensure falsy values becomes '' | ||
set items (val) { this.setAttribute('items', val || '') } | ||
get scrollRight () { return this.scrollWidth - this.clientWidth - this.scrollLeft } | ||
get scrollBottom () { return this.scrollHeight - this.clientHeight - this.scrollTop } | ||
get friction () { return Math.min(0.99, this.getAttribute('friction')) || 0.8 } // Avoid friction 1 (infinite) | ||
// Avoid friction 1 (infinite) | ||
get friction () { return Math.min(0.99, this.getAttribute('friction')) || 0.8 } | ||
set friction (val) { this.setAttribute('friction', val) } | ||
@@ -102,0 +112,0 @@ } |
@@ -163,13 +163,4 @@ (function (global, factory) { | ||
var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Polyfill toggleAttribute for IE | ||
var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Mock HTMLElement for Node | ||
if (IS_BROWSER && !window.Element.prototype.toggleAttribute) { | ||
window.Element.prototype.toggleAttribute = function (name) { | ||
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !this.hasAttribute(name); | ||
if (!force === this.hasAttribute(name)) this[force ? 'setAttribute' : 'removeAttribute'](name, ''); | ||
return force; | ||
}; | ||
} // Mock HTMLElement for Node | ||
if (!IS_BROWSER && !global.HTMLElement) { | ||
@@ -282,2 +273,3 @@ global.HTMLElement = | ||
* @param {String|NodeList|Array|Element} elements A CSS selector string, nodeList, element array, or single element | ||
* @param {Element} context Node to look for elements within | ||
* @return {Element[]} Array of elements | ||
@@ -454,7 +446,7 @@ */ | ||
return queryAll(this.getAttribute('items') || this.children, this); | ||
}, | ||
} // Ensure falsy values becomes '' | ||
, | ||
set: function set(val) { | ||
this.setAttribute('items', val || ''); | ||
} // Ensure falsy values becomes '' | ||
} | ||
}, { | ||
@@ -469,3 +461,4 @@ key: "scrollRight", | ||
return this.scrollHeight - this.clientHeight - this.scrollTop; | ||
} | ||
} // Avoid friction 1 (infinite) | ||
}, { | ||
@@ -475,4 +468,3 @@ key: "friction", | ||
return Math.min(0.99, this.getAttribute('friction')) || 0.8; | ||
} // Avoid friction 1 (infinite) | ||
, | ||
}, | ||
set: function set(val) { | ||
@@ -567,3 +559,3 @@ this.setAttribute('friction', val); | ||
var version = "4.1.0"; | ||
var version = "4.1.1"; | ||
@@ -612,3 +604,3 @@ /** | ||
var customEvents = options.customEvents || []; | ||
var skipProps = customProps.slice(); // Keep a copy | ||
var skipProps = customProps.concat('forwardRef'); // Keep a copy with forwardRef added | ||
@@ -624,2 +616,9 @@ var tagName = (dashCase + "-" + (options.suffix || 'react')).replace(/\W+/g, '-').toLowerCase(); | ||
this.ref = function (el) { | ||
// Support callback ref https://reactjs.org/docs/refs-and-the-dom.html#callback-refs | ||
if (typeof this$1.props.forwardRef === 'function') { | ||
this$1.props.forwardRef(el); | ||
} else if (this$1.props.forwardRef) { | ||
this$1.props.forwardRef.current = el; | ||
} | ||
return this$1.el = el; | ||
@@ -653,3 +652,3 @@ }; | ||
customProps.forEach(function (key) { | ||
return this$1.props.hasOwnProperty(key) && (this$1.el[key] = this$1.props[key]); | ||
return key in this$1.props && (this$1.el[key] = this$1.props[key]); | ||
}); | ||
@@ -656,0 +655,0 @@ customEvents.forEach(function (key) { |
@@ -1,3 +0,3 @@ | ||
/*! @nrk/core-scroll v4.1.0 - Copyright (c) 2017-2019 NRK */ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).coreScroll=e()}(this,function(){"use strict";function u(t){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(t,e,n){return(i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,n){var o=[null];o.push.apply(o,e);var i=new(Function.bind.apply(t,o));return n&&c(i,n.prototype),i}).apply(null,arguments)}function a(t){var o="function"==typeof Map?new Map:void 0;return(a=function(t){if(null===t||(e=t,-1===Function.toString.call(e).indexOf("[native code]")))return t;var e;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==o){if(o.has(t))return o.get(t);o.set(t,n)}function n(){return i(t,arguments,s(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)})(t)}function f(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var t="undefined"!=typeof window;t&&/(android)/i.test(navigator.userAgent),t&&/iPad|iPhone|iPod/.test(String(navigator.platform));t&&!window.Element.prototype.toggleAttribute&&(window.Element.prototype.toggleAttribute=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:!this.hasAttribute(t);return!e===this.hasAttribute(t)&&this[e?"setAttribute":"removeAttribute"](t,""),e}),t||global.HTMLElement||(global.HTMLElement=function(){return function t(){r(this,t)}}());var e,n,h=(e="undefined"==typeof window?{}:window.Element.prototype,n=e.matches||e.msMatchesSelector||e.webkitMatchesSelector,e.closest?function(t,e){return t.closest(e)}:function(t,e){for(;t;t=t.parentElement)if(n.call(t,e))return t;return null});function d(t,e){var n,o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i="prevent_recursive_dispatch_maximum_callstack".concat(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 r=t.dispatchEvent(n);return t[i]=null,r}function p(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:document;if(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 m={},v={up:{y:-1,prop:"top"},down:{y:1,prop:"bottom"},left:{x:-1},right:{x:1}},o=10,y=function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];try{window.addEventListener("test",null,{get passive(){t={passive:!0}}})}catch(t){}return t}(),g=t&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion)").matches,b=t&&(window.requestAnimationFrame||window.setTimeout);function w(t){m.diffX=m.pageX-(m.pageX=t.pageX),m.diffY=m.pageY-(m.pageY=t.pageY),m.diffSumX+=m.diffX,m.diffSumY+=m.diffY,m.target.scrollLeft=m.scrollX+=m.diffX,m.target.scrollTop=m.scrollY+=m.diffY,Math.max(Math.abs(m.diffSumX),Math.abs(m.diffSumY))>o&&(m.target.style.pointerEvents="none")}function E(t){var e=Math.abs(m.diffX||m.diffY)>o?20:0;document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",E),document.body.style.cursor="",e&&m.target.scroll({x:m.scrollX+m.diffX*e,y:m.scrollY+m.diffY*e}),m.target.style.pointerEvents="",m.target.style.cursor="-webkit-grab",m.target.style.cursor="grab",m.target=null}return function(t){function e(){return r(this,e),f(this,s(e).apply(this,arguments))}var n,o,i;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}(e,a(HTMLElement)),n=e,(o=[{key:"connectedCallback",value:function(){var t,e,n,o,i=this;t=this.nodeName,e="\n ".concat(this.nodeName,"{display:block}\n ").concat(this.nodeName,"::-webkit-scrollbar{display:none}\n "),n="style-".concat(t.toLowerCase()),o=e.replace(/\/\*[^!][^*]*\*\//g,"").replace(/\s*(^|[:;,{}]|$)\s*/g,"$1"),document.getElementById(n)||document.head.insertAdjacentHTML("afterbegin",'<style id="'.concat(n,'">').concat(o,"</style>")),this.style.overflow="scroll",this.style.willChange="scroll-position",this.style.webkitOverflowScrolling="touch";var r,l,s,c=this.offsetWidth-this.clientWidth,u=this.offsetHeight-this.clientHeight;this.style.marginRight="-".concat(c,"px"),this.style.marginBottom="-".concat(u,"px"),this.style.maxHeight="calc(100% + ".concat(u,"px)"),this._throttledEvent=(r=this.handleEvent.bind(this),l=500,function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];s||(s=setTimeout(function(){r.apply(this,e),s=null},l))}),this.addEventListener("mousedown",this),this.addEventListener("wheel",this,y),this.addEventListener("scroll",this._throttledEvent,y),window.addEventListener("resize",this._throttledEvent,y),window.addEventListener("load",this),document.addEventListener("click",this),setTimeout(function(){return i.handleEvent()})}},{key:"disconnectedCallback",value:function(){this._throttledEvent=null,this.removeEventListener("mousedown",this),this.removeEventListener("wheel",this,y),this.removeEventListener("scroll",this._throttledEvent,y),window.removeEventListener("resize",this._throttledEvent,y),window.removeEventListener("load",this),document.removeEventListener("click",this)}},{key:"handleEvent",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};if(!t.defaultPrevented)if("wheel"===t.type)m.animate=!1;else if("mousedown"===t.type)(function(t){if(h(t.target,'[contenteditable="true"],input,select,textarea'))return;t.preventDefault(),m.pageX=t.pageX,m.pageY=t.pageY,m.diffSumX=0,m.diffSumY=0,m.animate=m.diffX=m.diffY=0,m.scrollX=this.scrollLeft,m.scrollY=this.scrollTop,m.target=this,document.body.style.cursor=this.style.cursor="-webkit-grabbing",document.body.style.cursor=this.style.cursor="grabbing",document.addEventListener("mousemove",w),document.addEventListener("mouseup",E)}).call(this,t);else if("click"===t.type){var e=this.id&&h(t.target,'[for="'.concat(this.id,'"]'));e&&d(this,"scroll.click",{move:e.value})&&this.scroll(e.value)}else{var n={left:this.scrollLeft,up:this.scrollTop,right:this.scrollRight,down:this.scrollBottom},o=n.left||n.right||n.up||n.down?"grab":"";p(this.id&&'[for="'.concat(this.id,'"]')).forEach(function(t){return t.disabled=!n[t.value]}),d(this,"scroll.change"),t.type||(this.style.cursor="-webkit-".concat(o),this.style.cursor=o)}}},{key:"scroll",value:function(t){var e=this,n=function(t,o){var i="object"===u(o)?o:{move:o};"number"!=typeof i.x&&(i.x=t.scrollLeft);"number"!=typeof i.y&&(i.y=t.scrollTop);if(i.move=v[i.move]){var r=i.move.x?"x":"y",l=i.move.x?"left":"top",e=t.getBoundingClientRect(),s=e[l]-t[i.move.x?"scrollLeft":"scrollTop"],c=e[l]+e[i.move.x?"width":"height"]*i.move[r];t.items.every(function(t){var e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView.getComputedStyle(t)["margin-".concat(l)];return i[r]=e[l]-parseInt(n,10)-s,e[i.move.prop||o]<c})}return{x:Math.max(0,Math.min(i.x,t.scrollWidth-t.clientWidth)),y:Math.max(0,Math.min(i.y,t.scrollHeight-t.clientHeight))}}(this,t),o=n.x,i=n.y,r=m.animate=Date.now().toString(36)+Math.random().toString(36).slice(2,5),l=this.friction,s=g?1:o-this.scrollLeft,c=g?1:i-this.scrollTop;!function t(){m.animate===r&&(Math.round(s)||Math.round(c))&&(e.scrollLeft=o-Math.round(s*=l),e.scrollTop=i-Math.round(c*=l),b(t))}()}},{key:"items",get:function(){return p(this.getAttribute("items")||this.children,this)},set:function(t){this.setAttribute("items",t||"")}},{key:"scrollRight",get:function(){return this.scrollWidth-this.clientWidth-this.scrollLeft}},{key:"scrollBottom",get:function(){return this.scrollHeight-this.clientHeight-this.scrollTop}},{key:"friction",get:function(){return Math.min(.99,this.getAttribute("friction"))||.8},set:function(t){this.setAttribute("friction",t)}}])&&l(n.prototype,o),i&&l(n,i),e}()}),window.customElements.define("core-scroll",coreScroll); | ||
/*! @nrk/core-scroll v4.1.1 - Copyright (c) 2017-2019 NRK */ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).coreScroll=e()}(this,function(){"use strict";function u(t){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(t,e,n){return(i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,n){var o=[null];o.push.apply(o,e);var i=new(Function.bind.apply(t,o));return n&&c(i,n.prototype),i}).apply(null,arguments)}function a(t){var o="function"==typeof Map?new Map:void 0;return(a=function(t){if(null===t||(e=t,-1===Function.toString.call(e).indexOf("[native code]")))return t;var e;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==o){if(o.has(t))return o.get(t);o.set(t,n)}function n(){return i(t,arguments,s(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)})(t)}function f(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var t="undefined"!=typeof window;t&&/(android)/i.test(navigator.userAgent),t&&/iPad|iPhone|iPod/.test(String(navigator.platform));t||global.HTMLElement||(global.HTMLElement=function(){return function t(){r(this,t)}}());var e,n,d=(e="undefined"==typeof window?{}:window.Element.prototype,n=e.matches||e.msMatchesSelector||e.webkitMatchesSelector,e.closest?function(t,e){return t.closest(e)}:function(t,e){for(;t;t=t.parentElement)if(n.call(t,e))return t;return null});function h(t,e){var n,o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i="prevent_recursive_dispatch_maximum_callstack".concat(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 r=t.dispatchEvent(n);return t[i]=null,r}function p(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:document;if(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 m={},v={up:{y:-1,prop:"top"},down:{y:1,prop:"bottom"},left:{x:-1},right:{x:1}},o=10,y=function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];try{window.addEventListener("test",null,{get passive(){t={passive:!0}}})}catch(t){}return t}(),g=t&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion)").matches,b=t&&(window.requestAnimationFrame||window.setTimeout);function w(t){m.diffX=m.pageX-(m.pageX=t.pageX),m.diffY=m.pageY-(m.pageY=t.pageY),m.diffSumX+=m.diffX,m.diffSumY+=m.diffY,m.target.scrollLeft=m.scrollX+=m.diffX,m.target.scrollTop=m.scrollY+=m.diffY,Math.max(Math.abs(m.diffSumX),Math.abs(m.diffSumY))>o&&(m.target.style.pointerEvents="none")}function E(t){var e=Math.abs(m.diffX||m.diffY)>o?20:0;document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",E),document.body.style.cursor="",e&&m.target.scroll({x:m.scrollX+m.diffX*e,y:m.scrollY+m.diffY*e}),m.target.style.pointerEvents="",m.target.style.cursor="-webkit-grab",m.target.style.cursor="grab",m.target=null}return function(t){function e(){return r(this,e),f(this,s(e).apply(this,arguments))}var n,o,i;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}(e,a(HTMLElement)),n=e,(o=[{key:"connectedCallback",value:function(){var t,e,n,o,i=this;t=this.nodeName,e="\n ".concat(this.nodeName,"{display:block}\n ").concat(this.nodeName,"::-webkit-scrollbar{display:none}\n "),n="style-".concat(t.toLowerCase()),o=e.replace(/\/\*[^!][^*]*\*\//g,"").replace(/\s*(^|[:;,{}]|$)\s*/g,"$1"),document.getElementById(n)||document.head.insertAdjacentHTML("afterbegin",'<style id="'.concat(n,'">').concat(o,"</style>")),this.style.overflow="scroll",this.style.willChange="scroll-position",this.style.webkitOverflowScrolling="touch";var r,l,s,c=this.offsetWidth-this.clientWidth,u=this.offsetHeight-this.clientHeight;this.style.marginRight="-".concat(c,"px"),this.style.marginBottom="-".concat(u,"px"),this.style.maxHeight="calc(100% + ".concat(u,"px)"),this._throttledEvent=(r=this.handleEvent.bind(this),l=500,function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];s||(s=setTimeout(function(){r.apply(this,e),s=null},l))}),this.addEventListener("mousedown",this),this.addEventListener("wheel",this,y),this.addEventListener("scroll",this._throttledEvent,y),window.addEventListener("resize",this._throttledEvent,y),window.addEventListener("load",this),document.addEventListener("click",this),setTimeout(function(){return i.handleEvent()})}},{key:"disconnectedCallback",value:function(){this._throttledEvent=null,this.removeEventListener("mousedown",this),this.removeEventListener("wheel",this,y),this.removeEventListener("scroll",this._throttledEvent,y),window.removeEventListener("resize",this._throttledEvent,y),window.removeEventListener("load",this),document.removeEventListener("click",this)}},{key:"handleEvent",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};if(!t.defaultPrevented)if("wheel"===t.type)m.animate=!1;else if("mousedown"===t.type)(function(t){if(d(t.target,'[contenteditable="true"],input,select,textarea'))return;t.preventDefault(),m.pageX=t.pageX,m.pageY=t.pageY,m.diffSumX=0,m.diffSumY=0,m.animate=m.diffX=m.diffY=0,m.scrollX=this.scrollLeft,m.scrollY=this.scrollTop,m.target=this,document.body.style.cursor=this.style.cursor="-webkit-grabbing",document.body.style.cursor=this.style.cursor="grabbing",document.addEventListener("mousemove",w),document.addEventListener("mouseup",E)}).call(this,t);else if("click"===t.type){var e=this.id&&d(t.target,'[for="'.concat(this.id,'"]'));e&&h(this,"scroll.click",{move:e.value})&&this.scroll(e.value)}else{var n={left:this.scrollLeft,up:this.scrollTop,right:this.scrollRight,down:this.scrollBottom},o=n.left||n.right||n.up||n.down?"grab":"";p(this.id&&'[for="'.concat(this.id,'"]')).forEach(function(t){return t.disabled=!n[t.value]}),h(this,"scroll.change"),t.type||(this.style.cursor="-webkit-".concat(o),this.style.cursor=o)}}},{key:"scroll",value:function(t){var e=this,n=function(t,o){var i="object"===u(o)?o:{move:o};"number"!=typeof i.x&&(i.x=t.scrollLeft);"number"!=typeof i.y&&(i.y=t.scrollTop);if(i.move=v[i.move]){var r=i.move.x?"x":"y",l=i.move.x?"left":"top",e=t.getBoundingClientRect(),s=e[l]-t[i.move.x?"scrollLeft":"scrollTop"],c=e[l]+e[i.move.x?"width":"height"]*i.move[r];t.items.every(function(t){var e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView.getComputedStyle(t)["margin-".concat(l)];return i[r]=e[l]-parseInt(n,10)-s,e[i.move.prop||o]<c})}return{x:Math.max(0,Math.min(i.x,t.scrollWidth-t.clientWidth)),y:Math.max(0,Math.min(i.y,t.scrollHeight-t.clientHeight))}}(this,t),o=n.x,i=n.y,r=m.animate=Date.now().toString(36)+Math.random().toString(36).slice(2,5),l=this.friction,s=g?1:o-this.scrollLeft,c=g?1:i-this.scrollTop;!function t(){m.animate===r&&(Math.round(s)||Math.round(c))&&(e.scrollLeft=o-Math.round(s*=l),e.scrollTop=i-Math.round(c*=l),b(t))}()}},{key:"items",get:function(){return p(this.getAttribute("items")||this.children,this)},set:function(t){this.setAttribute("items",t||"")}},{key:"scrollRight",get:function(){return this.scrollWidth-this.clientWidth-this.scrollLeft}},{key:"scrollBottom",get:function(){return this.scrollHeight-this.clientHeight-this.scrollTop}},{key:"friction",get:function(){return Math.min(.99,this.getAttribute("friction"))||.8},set:function(t){this.setAttribute("friction",t)}}])&&l(n.prototype,o),i&&l(n,i),e}()}),window.customElements.define("core-scroll",coreScroll); | ||
//# sourceMappingURL=core-scroll.min.js.map |
37
jsx.js
@@ -161,13 +161,4 @@ 'use strict'; | ||
var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Polyfill toggleAttribute for IE | ||
var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Mock HTMLElement for Node | ||
if (IS_BROWSER && !window.Element.prototype.toggleAttribute) { | ||
window.Element.prototype.toggleAttribute = function (name) { | ||
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !this.hasAttribute(name); | ||
if (!force === this.hasAttribute(name)) this[force ? 'setAttribute' : 'removeAttribute'](name, ''); | ||
return force; | ||
}; | ||
} // Mock HTMLElement for Node | ||
if (!IS_BROWSER && !global.HTMLElement) { | ||
@@ -280,2 +271,3 @@ global.HTMLElement = | ||
* @param {String|NodeList|Array|Element} elements A CSS selector string, nodeList, element array, or single element | ||
* @param {Element} context Node to look for elements within | ||
* @return {Element[]} Array of elements | ||
@@ -452,7 +444,7 @@ */ | ||
return queryAll(this.getAttribute('items') || this.children, this); | ||
}, | ||
} // Ensure falsy values becomes '' | ||
, | ||
set: function set(val) { | ||
this.setAttribute('items', val || ''); | ||
} // Ensure falsy values becomes '' | ||
} | ||
}, { | ||
@@ -467,3 +459,4 @@ key: "scrollRight", | ||
return this.scrollHeight - this.clientHeight - this.scrollTop; | ||
} | ||
} // Avoid friction 1 (infinite) | ||
}, { | ||
@@ -473,4 +466,3 @@ key: "friction", | ||
return Math.min(0.99, this.getAttribute('friction')) || 0.8; | ||
} // Avoid friction 1 (infinite) | ||
, | ||
}, | ||
set: function set(val) { | ||
@@ -565,3 +557,3 @@ this.setAttribute('friction', val); | ||
var version = "4.1.0"; | ||
var version = "4.1.1"; | ||
@@ -610,3 +602,3 @@ /** | ||
var customEvents = options.customEvents || []; | ||
var skipProps = customProps.slice(); // Keep a copy | ||
var skipProps = customProps.concat('forwardRef'); // Keep a copy with forwardRef added | ||
@@ -622,2 +614,9 @@ var tagName = (dashCase + "-" + (options.suffix || 'react')).replace(/\W+/g, '-').toLowerCase(); | ||
this.ref = function (el) { | ||
// Support callback ref https://reactjs.org/docs/refs-and-the-dom.html#callback-refs | ||
if (typeof this$1.props.forwardRef === 'function') { | ||
this$1.props.forwardRef(el); | ||
} else if (this$1.props.forwardRef) { | ||
this$1.props.forwardRef.current = el; | ||
} | ||
return this$1.el = el; | ||
@@ -651,3 +650,3 @@ }; | ||
customProps.forEach(function (key) { | ||
return this$1.props.hasOwnProperty(key) && (this$1.el[key] = this$1.props[key]); | ||
return key in this$1.props && (this$1.el[key] = this$1.props[key]); | ||
}); | ||
@@ -654,0 +653,0 @@ customEvents.forEach(function (key) { |
@@ -5,3 +5,3 @@ { | ||
"author": "NRK <opensource@nrk.no> (https://www.nrk.no/)", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "core-scroll.cjs.js", |
@@ -152,3 +152,3 @@ # Core Scroll | ||
```html | ||
<script src="https://static.nrk.no/core-components/major/6/core-scroll/core-scroll.min.js"></script> <!-- Using static --> | ||
<script src="https://static.nrk.no/core-components/major/7/core-scroll/core-scroll.min.js"></script> <!-- Using static --> | ||
``` | ||
@@ -155,0 +155,0 @@ |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
0
151160
11
1864