Giter Site home page Giter Site logo

Comments (4)

weotch avatar weotch commented on May 20, 2024 1

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.

baptistebriel avatar baptistebriel commented on May 20, 2024

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.

23d1 avatar 23d1 commented on May 20, 2024

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.

baptistebriel avatar baptistebriel commented on May 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.