mercs600 / vue2-perfect-scrollbar

Vue.js wrapper for perfect scrollbar
https://mercs600.github.io/vue2-perfect-scrollbar/
MIT License
275 stars 43 forks source link

How Can I prevent it from scrolling to top When update? #13

Closed vibesudi closed 4 years ago

vibesudi commented 5 years ago

Toggle 'suppressScrollY' when I click the page,then update(). It scroll to top . like this: https://codesandbox.io/embed/vue-perfect-scrollbar-global-registration-5mf2l?fontsize=14 I hope to stay current positon. have to edit "index.js" of perfect-scrollbar . method update:

update() {
    if (!this.isAlive) {
      return;
    }

    // Recalcuate negative scrollLeft adjustment
    this.negativeScrollAdjustment = this.isNegativeScroll
      ? this.element.scrollWidth - this.element.clientWidth
      : 0;

    // Recalculate rail margins
    CSS.set(this.scrollbarXRail, { display: 'block' });
    CSS.set(this.scrollbarYRail, { display: 'block' });
    this.railXMarginWidth =
      toInt(CSS.get(this.scrollbarXRail).marginLeft) +
      toInt(CSS.get(this.scrollbarXRail).marginRight);
    this.railYMarginHeight =
      toInt(CSS.get(this.scrollbarYRail).marginTop) +
      toInt(CSS.get(this.scrollbarYRail).marginBottom);

    // Hide scrollbars not to affect scrollWidth and scrollHeight
    CSS.set(this.scrollbarXRail, { display: 'none' });
    CSS.set(this.scrollbarYRail, { display: 'none' });

    updateGeometry(this);

    processScrollDiff(this, 'top', 0, false, true);
    processScrollDiff(this, 'left', 0, false, true);

    CSS.set(this.scrollbarXRail, { display: '' });
    CSS.set(this.scrollbarYRail, { display: '' });
  }
vibesudi commented 5 years ago

I select another Plugin "smooth-scrollbar"

mercs600 commented 4 years ago

@vibesudi You have to fork https://github.com/mdbootstrap/perfect-scrollbar - there you have to make your changes and after that replace perfect-scrollbar dependency in your package.json:

    "vue2-perfect-scrollbar": "^1.2.3",
    "perfect-scrollbar": "git+https://github.com/tibineagu/perfect-scrollbar.git#custom-classes"

Instead of git+https://github.com/tibineagu/perfect-scrollbar.git#custom-classes you have to provide your repo url

BugKiller-tech commented 4 years ago

Is there any good news for this problem without using own repo?