diff --git a/resources/sys/wde/simple-scrollbar.css b/resources/sys/wde/simple-scrollbar.css new file mode 100644 index 0000000..718e25e --- /dev/null +++ b/resources/sys/wde/simple-scrollbar.css @@ -0,0 +1,56 @@ +.ss-wrapper { + overflow: hidden; + width: 100%; + height: 100%; + position: relative; + z-index: 1; + float: left; +} + +.ss-content { + height: 100%; + width: calc(100% + 18px); + padding: 0 0 0 0; + position: relative; + overflow: auto; + box-sizing: border-box; +} + +.ss-content.rtl { + width: calc(100% + 18px); + right: auto; +} + +.ss-scroll { + position: relative; + background: rgba(0, 0, 0, 0.1); + width: 14px; + height: 31px; + /* border-radius: 4px; */ + top: 0; + z-index: 2; + cursor: pointer; + /* opacity: 0; */ + /* transition: opacity 0.25s linear; */ + background: #9999FF; + box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.5), + inset 1px 0px 0px rgba(255, 255, 255, 0.5), + inset -1px -1px 0px rgba(102, 102, 204, 0.91); +} + +.ss-hidden { + display: none; +} + +.ss-container:hover .ss-scroll, +.ss-container:active .ss-scroll { + opacity: 1; +} + +.ss-grabbed { + -o-user-select: none; + -ms-user-select: none; + -moz-user-select: none; + -webkit-user-select: none; + user-select: none; +} diff --git a/resources/sys/wde/simple-scrollbar.js b/resources/sys/wde/simple-scrollbar.js new file mode 100644 index 0000000..2ff768f --- /dev/null +++ b/resources/sys/wde/simple-scrollbar.js @@ -0,0 +1,165 @@ +;(function(root, factory) { + if (typeof exports === 'object') { + module.exports = factory(window, document) + } else { + root.SimpleScrollbar = factory(window, document) + } +})(this, function(w, d) { + var raf = w.requestAnimationFrame || w.setImmediate || function(c) { return setTimeout(c, 0); }; + + function initEl(el) { + Object.defineProperty(el, 'data-simple-scrollbar', { value: new SimpleScrollbar(el), configurable: true }); + } + + function unbindEl(el) { + if (!Object.prototype.hasOwnProperty.call(el, 'data-simple-scrollbar')) return; + el['data-simple-scrollbar'].unBind(); + //Remove the elements property + delete el['data-simple-scrollbar']; + } + + // Mouse drag handler + function dragDealer(el, context) { + var lastPageY; + + el.addEventListener('mousedown', function(e) { + lastPageY = e.pageY; + el.classList.add('ss-grabbed'); + d.body.classList.add('ss-grabbed'); + + d.addEventListener('mousemove', drag); + d.addEventListener('mouseup', stop); + + return false; + }); + + function drag(e) { + var delta = e.pageY - lastPageY; + lastPageY = e.pageY; + + raf(function() { + context.el.scrollTop += delta / context.scrollRatio; + }); + } + + function stop() { + el.classList.remove('ss-grabbed'); + d.body.classList.remove('ss-grabbed'); + d.removeEventListener('mousemove', drag); + d.removeEventListener('mouseup', stop); + } + } + + // Constructor + function ss(el) { + this.target = el; + this.content = el.firstElementChild; + + this.direction = w.getComputedStyle(this.target).direction; + + this.bar = '