Skip to content

Regarding Background Scroll Lock #326

Discussion options

You must be logged in to vote

Hey @toxifiedmatrix, I hope you find it useful to reach a solution! basically, I did a custom plugin to "fix" the scroll position, and then I used this plugin to initialize it (Scrollbar.use(StopScrollPlugin)), and finally, I just use a single if to update the plugin option (scrollBar.updatePluginOptions("modal", { scroll: false }))

stopPlugin.js

import { ScrollbarPlugin } from "smooth-scrollbar"

export default class StopScrollPlugin extends ScrollbarPlugin {
  static pluginName = "stopScroll"

  static defaultOptions = {
    scroll: true
  }

  transformDelta(delta) {
    return !this.options.scroll ? { x: 0, y: 0 } : delta
  }
}

index.js

Scrollbar.use(StopScrollPlugin);

const scrollb…

Replies: 7 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

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

Answer selected by idiotWu
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
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
4 participants
Converted from issue

This discussion was converted from issue #273 on June 10, 2021 16:39.