frs-hide-scrollbar
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -1,1 +0,1 @@ | ||
parcelRequire=function(i,c,e,r){var s="function"==typeof parcelRequire&&parcelRequire,d="function"==typeof require&&require;function a(r,e){if(!c[r]){if(!i[r]){var t="function"==typeof parcelRequire&&parcelRequire;if(!e&&t)return t(r,!0);if(s)return s(r,!0);if(d&&"string"==typeof r)return d(r);var o=new Error("Cannot find module '"+r+"'");throw o.code="MODULE_NOT_FOUND",o}n.resolve=function(e){return i[r][1][e]||e};var l=c[r]=new a.Module(r);i[r][0].call(l.exports,n,l,l.exports,this)}return c[r].exports;function n(e){return a(n.resolve(e))}}a.isParcelRequire=!0,a.Module=function(e){this.id=e,this.bundle=a,this.exports={}},a.modules=i,a.cache=c,a.parent=s,a.register=function(e,t){i[e]=[function(e,r){r.exports=t},{}]};for(var t=0;t<e.length;t++)a(e[t]);if(e.length){var o=a(e[e.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=o:"function"==typeof define&&define.amd&&define(function(){return o})}return a}({H0tP:[function(e,r,t){function o(e){return(e=e.length?Array.prototype.slice.apply(e):[e]).map(function(e){var r=Array.prototype.slice.apply(e.children),t=n("div",e);e.classList.add(o.config.wrapperClassName),t.classList.add(o.config.className),r.forEach(function(e){t.appendChild(e)})})}function l(){_el=n("div",document.body),_el.style.position="absolute",_el.style["z-index"]="-1",_el.style.width="100px",_el.style.overflow="scroll";var e=_el.offsetWidth-_el.clientWidth;return document.body.removeChild(_el),e!==o.config.scrollWidth&&(o.config.scrollWidth=e,o.config.styleElement.innerText+="."+o.config.className+"{overflow:scroll;margin-right:-"+o.config.scrollWidth+"px;height:calc(100% + "+o.config.scrollWidth+"px);}"),_el.scrollWidth}function n(e,r){return r.appendChild(document.createElement(e))}(window.FRSHideScrollBar=o).refreshScrollWidth=l,o.config={className:"frs-hide-scroll",wrapperClassName:"frs-hide-scroll-wrapper",scrollWidth:void 0,styleElement:document.getElementsByTagName("style")[0]||n("style",document.head)},window.addEventListener("load",l)},{}],U8NR:[function(e,r,t){},{}],YXW9:[function(e,r,t){e("./scripts/FRSHideScrollbar.js"),e("./styles/FRSHideScrollbar.scss")},{"./scripts/FRSHideScrollbar.js":"H0tP","./styles/FRSHideScrollbar.scss":"U8NR"}],Focm:[function(e,r,t){e("./src/FRS-hide-scrollbar.js")},{"./src/FRS-hide-scrollbar.js":"YXW9"}]},{},["Focm"]); | ||
parcelRequire=function(t,c,e,r){var s="function"==typeof parcelRequire&&parcelRequire,d="function"==typeof require&&require;function a(r,e){if(!c[r]){if(!t[r]){var l="function"==typeof parcelRequire&&parcelRequire;if(!e&&l)return l(r,!0);if(s)return s(r,!0);if(d&&"string"==typeof r)return d(r);var i=new Error("Cannot find module '"+r+"'");throw i.code="MODULE_NOT_FOUND",i}n.resolve=function(e){return t[r][1][e]||e};var o=c[r]=new a.Module(r);t[r][0].call(o.exports,n,o,o.exports,this)}return c[r].exports;function n(e){return a(n.resolve(e))}}a.isParcelRequire=!0,a.Module=function(e){this.id=e,this.bundle=a,this.exports={}},a.modules=t,a.cache=c,a.parent=s,a.register=function(e,l){t[e]=[function(e,r){r.exports=l},{}]};for(var l=0;l<e.length;l++)a(e[l]);if(e.length){var i=a(e[e.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=i:"function"==typeof define&&define.amd&&define(function(){return i})}return a}({H0tP:[function(e,r,l){var o;function i(){_el=n("div",document.body),_el.style.position="absolute",_el.style["z-index"]="-1",_el.style.width="100px",_el.style.overflow="scroll";var e=_el.offsetWidth-_el.clientWidth;return document.body.removeChild(_el),e!==FRSHideScrollBar.config.scrollWidth&&(FRSHideScrollBar.config.scrollWidth=e,t()),_el.scrollWidth}function n(e,r){return r.appendChild(document.createElement(e))}function t(e,r){if(e=e||FRSHideScrollBar.config.styleElement,r=r||o){var l=r.styleElement,i=l.innerText.lastIndexOf("."+r.className+"{margin-right:-");l.innerText=l.innerText.substring(0,i)}0!==FRSHideScrollBar.config.scrollWidth&&(o=FRSHideScrollBar.config,e.innerText+="."+FRSHideScrollBar.config.className+"{margin-right:-"+(FRSHideScrollBar.config.scrollWidth+.5)+"px;height:calc(100% + "+FRSHideScrollBar.config.scrollWidth+"px)}")}window.FRSHideScrollBar=window.FRSHideScrollBar||{},FRSHideScrollBar.refreshScrollWidth=i,FRSHideScrollBar.createNewChild=n,FRSHideScrollBar.updateStyles=t,FRSHideScrollBar.config=FRSHideScrollBar.config||{},FRSHideScrollBar.config.className=FRSHideScrollBar.config.className||"frs-hide-scroll",FRSHideScrollBar.config.wrapperClassName=FRSHideScrollBar.config.wrapperClassName||"frs-hide-scroll-wrapper",FRSHideScrollBar.config.styleElement=FRSHideScrollBar.config.styleElement||document.getElementsByTagName("style")[0]||n("style",document.head),window.addEventListener("load",i,{passive:!0}),window.addEventListener("resize",i,{passive:!0})},{}],U8NR:[function(e,r,l){},{}],YXW9:[function(e,r,l){e("./scripts/FRSHideScrollbar.js"),e("./styles/FRSHideScrollbar.scss")},{"./scripts/FRSHideScrollbar.js":"H0tP","./styles/FRSHideScrollbar.scss":"U8NR"}],Focm:[function(e,r,l){e("./src/FRS-hide-scrollbar.js")},{"./src/FRS-hide-scrollbar.js":"YXW9"}]},{},["Focm"]); |
@@ -1,1 +0,1 @@ | ||
!function(){function o(e){return(e=e.length?Array.prototype.slice.apply(e):[e]).map(function(e){var l=Array.prototype.slice.apply(e.children),t=i("div",e);e.classList.add(o.config.wrapperClassName),t.classList.add(o.config.className),l.forEach(function(e){t.appendChild(e)})})}function e(){_el=i("div",document.body),_el.style.position="absolute",_el.style["z-index"]="-1",_el.style.width="100px",_el.style.overflow="scroll";var e=_el.offsetWidth-_el.clientWidth;return document.body.removeChild(_el),e!==o.config.scrollWidth&&(o.config.scrollWidth=e,o.config.styleElement.innerText+="."+o.config.className+"{overflow:scroll;margin-right:-"+o.config.scrollWidth+"px;height:calc(100% + "+o.config.scrollWidth+"px);}"),_el.scrollWidth}function i(e,l){return l.appendChild(document.createElement(e))}(window.FRSHideScrollBar=o).refreshScrollWidth=e,o.config={className:"frs-hide-scroll",wrapperClassName:"frs-hide-scroll-wrapper",scrollWidth:void 0,styleElement:document.getElementsByTagName("style")[0]||i("style",document.head)},window.addEventListener("load",e)}(); | ||
!function(){var o;function e(){_el=l("div",document.body),_el.style.position="absolute",_el.style["z-index"]="-1",_el.style.width="100px",_el.style.overflow="scroll";var e=_el.offsetWidth-_el.clientWidth;return document.body.removeChild(_el),e!==FRSHideScrollBar.config.scrollWidth&&(FRSHideScrollBar.config.scrollWidth=e,r()),_el.scrollWidth}function l(e,l){return l.appendChild(document.createElement(e))}function r(e,l){if(e=e||FRSHideScrollBar.config.styleElement,l=l||o){var r=l.styleElement,i=r.innerText.lastIndexOf("."+l.className+"{margin-right:-");r.innerText=r.innerText.substring(0,i)}0!==FRSHideScrollBar.config.scrollWidth&&(o=FRSHideScrollBar.config,e.innerText+="."+FRSHideScrollBar.config.className+"{margin-right:-"+(FRSHideScrollBar.config.scrollWidth+.5)+"px;height:calc(100% + "+FRSHideScrollBar.config.scrollWidth+"px)}")}window.FRSHideScrollBar=window.FRSHideScrollBar||{},FRSHideScrollBar.refreshScrollWidth=e,FRSHideScrollBar.createNewChild=l,FRSHideScrollBar.updateStyles=r,FRSHideScrollBar.config=FRSHideScrollBar.config||{},FRSHideScrollBar.config.className=FRSHideScrollBar.config.className||"frs-hide-scroll",FRSHideScrollBar.config.wrapperClassName=FRSHideScrollBar.config.wrapperClassName||"frs-hide-scroll-wrapper",FRSHideScrollBar.config.styleElement=FRSHideScrollBar.config.styleElement||document.getElementsByTagName("style")[0]||l("style",document.head),window.addEventListener("load",e,{passive:!0}),window.addEventListener("resize",e,{passive:!0})}(); |
{ | ||
"name": "frs-hide-scrollbar", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "Easy & lightweight solution for cross-browser scrollbar hiding", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# FRS-hide-scrollbar | ||
FRS-hide-scrollbar is cross-compatible, simple & lightweight library for hiding both horizontal & vertical scrollbars! | ||
FRS-hide-scrollbar is cross-browser (supports both desktop & mobile devices), simple & lightweight library for hiding both horizontal & vertical scrollbars! | ||
For more information, please see [docs](https://frsource.github.io/FRS-hide-scrollbar/). |
@@ -1,31 +0,22 @@ | ||
window.FRSHideScrollBar = FRSHideScrollBar; | ||
var CONFIG_OLD; | ||
window.FRSHideScrollBar = window.FRSHideScrollBar || {}; | ||
FRSHideScrollBar.refreshScrollWidth = refreshScrollWidth; | ||
FRSHideScrollBar.config = { | ||
className : 'frs-hide-scroll', | ||
wrapperClassName: 'frs-hide-scroll-wrapper', | ||
scrollWidth : void 0, | ||
styleElement : document.getElementsByTagName('style')[0] || createNewElement('style', document.head) | ||
}; | ||
FRSHideScrollBar.createNewChild = createNewChild; | ||
FRSHideScrollBar.updateStyles = updateStyles; | ||
FRSHideScrollBar.config = FRSHideScrollBar.config || {}; | ||
window.addEventListener('load', refreshScrollWidth); | ||
FRSHideScrollBar.config.className = FRSHideScrollBar.config.className || 'frs-hide-scroll'; | ||
FRSHideScrollBar.config.wrapperClassName = FRSHideScrollBar.config.wrapperClassName || 'frs-hide-scroll-wrapper'; | ||
FRSHideScrollBar.config.styleElement = FRSHideScrollBar.config.styleElement || | ||
document.getElementsByTagName('style')[0] || | ||
createNewChild('style', document.head); | ||
window.addEventListener('load', refreshScrollWidth, {passive: true}); | ||
window.addEventListener('resize', refreshScrollWidth, {passive: true}); | ||
// | ||
function FRSHideScrollBar (_elements) { | ||
_elements = _elements.length ? Array.prototype.slice.apply(_elements) : [_elements]; | ||
return _elements.map(function (_el) { | ||
var children = Array.prototype.slice.apply(_el.children); | ||
var inner = createNewElement('div', _el); | ||
_el.classList.add(FRSHideScrollBar.config.wrapperClassName); | ||
inner.classList.add(FRSHideScrollBar.config.className); | ||
children.forEach(function (_el) { | ||
inner.appendChild(_el) | ||
}); | ||
}); | ||
} | ||
function refreshScrollWidth () { | ||
_el = createNewElement('div', document.body); | ||
_el = createNewChild('div', document.body); | ||
_el.style.position = 'absolute'; | ||
@@ -42,3 +33,3 @@ _el.style['z-index'] = '-1'; | ||
FRSHideScrollBar.config.scrollWidth = scrollWidth; | ||
updateStyles(FRSHideScrollBar.config.styleElement); | ||
updateStyles(); | ||
} | ||
@@ -49,10 +40,28 @@ | ||
function createNewElement (_tagName, _parent) { | ||
function createNewChild (_tagName, _parent) { | ||
return _parent.appendChild(document.createElement(_tagName)); | ||
} | ||
function updateStyles (_styleElement) { | ||
_styleElement.innerText += '.' + FRSHideScrollBar.config.className + '{overflow:scroll;margin-right:-' + | ||
FRSHideScrollBar.config.scrollWidth + 'px;height:calc(100% + ' + | ||
FRSHideScrollBar.config.scrollWidth + 'px);}'; | ||
function updateStyles (_styleElement, _cfgOld) { | ||
_styleElement = _styleElement || FRSHideScrollBar.config.styleElement; | ||
_cfgOld = _cfgOld || CONFIG_OLD; | ||
if (_cfgOld) { | ||
var styleElementOld = _cfgOld.styleElement; | ||
var lio = styleElementOld.innerText.lastIndexOf('.' + _cfgOld.className + | ||
'{margin-right:-'); | ||
styleElementOld.innerText = styleElementOld.innerText.substring(0, lio); | ||
} | ||
if (FRSHideScrollBar.config.scrollWidth === 0) { | ||
return; | ||
} | ||
CONFIG_OLD = FRSHideScrollBar.config; | ||
_styleElement.innerText += '.' + FRSHideScrollBar.config.className + | ||
'{margin-right:-' + | ||
(FRSHideScrollBar.config.scrollWidth + .5) + // additional 0.5px because of chrome | ||
// rounding bug | ||
'px;height:calc(100% + ' + | ||
FRSHideScrollBar.config.scrollWidth + 'px)}'; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
243354
52