Skip to content

Possible to adjust speed? #350

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

You must be logged in to vote

For [email protected], you can use the plugin system to do this:

import Scrollbar, { ScrollbarPlugin } from 'smooth-scrollbar';

class ScaleSpeedPlugin extends ScrollbarPlugin {
  static pluginName = 'scaleSpeed';

  static defaultOptions = {
    speed: 1,
  };

  transformDelta(delta) {
    const { speed } = this.options;

    return {
      x: delta.x * speed,
      y: delta.y * speed,
    };
  }
}

Scrollbar.use(ScaleSpeedPlugin);

Scrollbar.init(elem, {
  plugins: {
    scaleSpeed: {
      speed: 10,
    },
  },
});

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@freestyle099
Comment options

@freestyle099
Comment options

@freestyle099
Comment options

Answer selected by idiotWu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants
Converted from issue

This discussion was converted from issue #112 on June 10, 2021 17:00.