Comments (4)
In case it helps anyone, here's my subclass to add toggling of the scrollbar when it's not needed:
class SmoothCustom extends Smooth {
// Keep the original behavior that gets turned off when you extend
constructor(opt) {
super(opt);
this.extends = false;
}
// Toggle display of scrollbar depending on whether content is > viewport
resize() {
super.resize();
if (this.vars.bounding <= 0) {
return this.dom.scrollbar.el.classList.add('hide');
} else {
return this.dom.scrollbar.el.classList.remove('hide');
}
}
};
from smooth-scrolling.
Ah — that's indeed a use case I didn't think of. I guess on your resize function you could check smooth.vars.bounding
, and if this value is < than smooth.vars.height
(equals window.innerHeight) then you could hide the scrollbar using visibility: hidden
or display: none
Hope it helps!
from smooth-scrolling.
Thanks! Would be great with the .on() and .off() as well (perhaps just adding a class when it meets those different criteria).
Definitely a feature request.
I should probably open another ticket, but I feel like I'm already spamming. ;)
Adding a Math.round enable option for the scroll values would be rad, like { fullpixels: true } or something.
from smooth-scrolling.
Hey @23d1,
Yup, that's definitely something we could add to the on/off methods.
As for rounding the pixels upon transformation, that's something I currently do most of the times now. I still use sub-pixels during transform to make sure the scroll is as smooth as possible, but usually rounds up the value when the user stops scrolling to avoid sub-pixel images and stuff.
If you're extending smooth and applying your own transform, you could use something like this:
this.getTransform(-this.vars.current.toFixed())
. It currently use a value of 2 if you're using the default script without extending it.
I'll think about adding this feature when I get some time to do it. There's actually a lot of stuff I'd like to add to a new version, I just didn't had time to re-factor it and push a new version with up-to-date documentation.
from smooth-scrolling.
Related Issues (20)
- Horizontal scroll demos not working HOT 2
- (Parallax demo) vs-scrollbar-smooth and vs-scrollbar-parallax got different scroll position after smooth.scrollTo
- Build version including parallax HOT 4
- Empty space at page bottom when transitioning page HOT 2
- Has the latest version been published to NPM? HOT 2
- scrollTo() after resize HOT 2
- Cannot find module 'babelify'
- Next.js Compatibility HOT 2
- Immediately set the scroll position HOT 2
- How to implement with GSAP ScrollTrigger HOT 17
- Scroll event on container not working
- Scrolling section responsive
- Uncaught TypeError: Class constructor Smooth cannot be invoked without 'new' HOT 1
- Error when building HOT 1
- StickySidebar with Smooth-Scroll
- Use native touch scrolling? HOT 6
- Smooth.resize() when using native gives error. HOT 1
- Custom easing function? HOT 1
- Horizontal scroll demo with both Y and X scrolling HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smooth-scrolling.