scrollbar.js 983 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import $ from 'jquery';
  2. import GeminiScrollbar from 'gemini-scrollbar';
  3. const defaults = {
  4. autoshow: false,
  5. createElements: true,
  6. forceGemini: false
  7. };
  8. export default class Scrollbar {
  9. constructor(element, options) {
  10. this.element = $(element);
  11. this.created = false;
  12. if (!this.element.length) { return; }
  13. this.options = Object.assign({}, defaults, options, { element: this.element[0] });
  14. this.element.css('overflow', 'auto');
  15. this.instance = new GeminiScrollbar(this.options);
  16. this.create();
  17. this.element.data('scrollbar', this.instance);
  18. }
  19. create() {
  20. this.instance.create();
  21. this.created = true;
  22. }
  23. update() {
  24. if (!this.created) { return false; }
  25. this.instance.update();
  26. }
  27. destroy() {
  28. if (!this.created) { return false; }
  29. this.instance.destroy();
  30. }
  31. }
  32. export let Instance = new Scrollbar('#admin-main .content-wrapper');