Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selector config to accept CSS selector string. Entrance animation for scroll track. Relative scrolling method. #6

Open
alexfain opened this issue Feb 12, 2022 · 1 comment

Comments

@alexfain
Copy link

alexfain commented Feb 12, 2022

Hello, I have implemented your scrollbar and it is awesome!!

I have 3 suggestions.

A first suggestion in case someone needs to implement multiple scrollbars on the page and can't set individual IDs to be known beforehand will be to update the following lines:

[37] this.selector = options.selector || defaults.selector;
[271] let selectorElement = document.querySelector(this.selector);
  • as this enables developer to initialize the scroller by CSS selector string and not only by the ID, I have modified the file on my project and it works as a charm.

Second suggestion: maybe adding an entrance animation to the .lms_scroll_track will help prevent some unwanted flickering when initially the scrollbar is display: none, something simple like:

.lms_scroll_track{
    animation: appear .5s ease forwards;
}
@keyframes appear { from{ opacity: 0; } to{ opacity: 1; } }

Third suggestion is to add a new method or second parameter (boolean) on the .scrollTo method for the scrolling amount to be relative to the current scroll position.

var scrollEl = instance.mainElement.querySelector('.lms_content_wrapper');
instance.scrollTo(scrollEl.scrollTop + 150);

Besides that your code is splendid and also great job for reserving the native scrolling.

@BMSVieira
Copy link
Owner

Hey,

Thank you for all the sugestions, it makes sense.
Im glad you used it with no problems besides those "little" things.

Please, submit a pull request with the modifications you sugested so you will be in the Contributors!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants