Skip to content

make plugin use in browser, instead of typescript? #455

Answered by idiotWu
boroco asked this question in Q&A
Discussion options

You must be logged in to vote

To be more specific:

var Scrollbar = window.Scrollbar;

// see also: https://github.com/idiotWu/smooth-scrollbar/issues/198#issuecomment-496264237
function EdgeEasingPlugin() {
  Scrollbar.ScrollbarPlugin.apply(this, arguments);

  this._remainMomentum = {
    x: 0,
    y: 0,
  };
}

EdgeEasingPlugin.prototype = Object.create(Scrollbar.ScrollbarPlugin.prototype);

EdgeEasingPlugin.prototype.transformDelta = function(delta) {
  const {
    limit,
    offset,
  } = this.scrollbar;

  const x = this._remainMomentum.x + delta.x;
  const y = this._remainMomentum.y + delta.y;

  // clamps momentum within [-offset, limit - offset]
  this.scrollbar.setMomentum(
    Math.max(-offset.x, Math.min(x, l…

Replies: 5 comments 8 replies

Comment options

You must be logged in to vote
1 reply
@boroco
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by boroco
Comment options

You must be logged in to vote
7 replies
@boroco
Comment options

@idiotWu
Comment options

@boroco
Comment options

@idiotWu
Comment options

@boroco
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants