You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

29 lines
1.8 KiB

  1. var TRACK_BG = 'rgba(222, 222, 222, .75)';
  2. var THUMB_BG = 'rgba(0, 0, 0, .5)';
  3. var SCROLLBAR_STYLE = "\n[data-scrollbar] {\n display: block;\n position: relative;\n}\n\n.scroll-content {\n -webkit-transform: translate3d(0, 0, 0);\n transform: translate3d(0, 0, 0);\n}\n\n.scrollbar-track {\n position: absolute;\n opacity: 0;\n z-index: 1;\n background: " + TRACK_BG + ";\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n -webkit-transition: opacity 0.5s 0.5s ease-out;\n transition: opacity 0.5s 0.5s ease-out;\n}\n.scrollbar-track.show,\n.scrollbar-track:hover {\n opacity: 1;\n -webkit-transition-delay: 0s;\n transition-delay: 0s;\n}\n\n.scrollbar-track-x {\n bottom: 0;\n left: 0;\n width: 100%;\n height: 8px;\n}\n.scrollbar-track-y {\n top: 0;\n right: 0;\n width: 8px;\n height: 100%;\n}\n.scrollbar-thumb {\n position: absolute;\n top: 0;\n left: 0;\n width: 8px;\n height: 8px;\n background: " + THUMB_BG + ";\n border-radius: 4px;\n}\n";
  4. var STYLE_ID = 'smooth-scrollbar-style';
  5. var isStyleAttached = false;
  6. export function attachStyle() {
  7. if (isStyleAttached || typeof window === 'undefined') {
  8. return;
  9. }
  10. var styleEl = document.createElement('style');
  11. styleEl.id = STYLE_ID;
  12. styleEl.textContent = SCROLLBAR_STYLE;
  13. if (document.head) {
  14. document.head.appendChild(styleEl);
  15. }
  16. isStyleAttached = true;
  17. }
  18. export function detachStyle() {
  19. if (!isStyleAttached || typeof window === 'undefined') {
  20. return;
  21. }
  22. var styleEl = document.getElementById(STYLE_ID);
  23. if (!styleEl || !styleEl.parentNode) {
  24. return;
  25. }
  26. styleEl.parentNode.removeChild(styleEl);
  27. isStyleAttached = false;
  28. }
  29. //# sourceMappingURL=style.js.map