atom-material / atom-material-ui

A dynamic UI theme for Atom that follows Google's Material Design Guidelines
MIT License
817 stars 204 forks source link

Auto hide scroll bar when not triggered or hovered, and a much thinner scrollbar #274

Closed anobilisgorse closed 8 years ago

anobilisgorse commented 8 years ago

Hello, I really liked what you did with the new update of Atom Material UI, but I very much prefer having a thinner scrollbar and auto hiding it.

Is there some other way where I can do it through my own styles.less?

Many thanks.

silvestreh commented 8 years ago

You could try something like this in your user styles…

.scrollbars-visible-always {
    /deep/::-webkit-scrollbar {
        width: 0.25rem;
        height: 0.25rem;
    }
}
anobilisgorse commented 8 years ago

But it won't auto-hide? I came upon that too and that solved my problem about the width, but regarding the auto-hide feature?

I thought it was .scrollbars-show-when-scrolled but it was not working.

silvestreh commented 8 years ago

Scrollbar visibility is controlled by the OS. In OS X scrollbars are disabled by default, the class scrollbars-visible-always is added when you set the OS to always show them. Windows always shows them… I'm not sure about Linux as there are quite a few window managers/desktop environments.

With that said, you could try something like this:

.scrollbars-visible-always {
    .tree-view-scroller {
        &::-webkit-scrollbar {
            display: none;
            width: 0.25rem;
            height: 0.25rem;
        }
        &:hover::-webkit-scrollbar {
            display: block;
        }
    }
}

As you can see, you would have to do this on a component by component basis, targeting specifically elements with overflow: scroll;.

HoverBaum commented 8 years ago

Awesome, just what I was looking for as well.

How would you actually go about doing the same for the editor? I just spend an hour trying to find documentation or code snippets on how to get to the scrollbar. Best I could find was

atom-text-editor::shadow  {
  ::-webkit-scrollbar {
    display: none;
  }
}

But that permanently hides the scrollbar.

silvestreh commented 8 years ago

@HoverBaum the editor doesn't use OS scrollbars. Having said that, the snippet you're after would look like this:

atom-text-editor::shadow {
    .horizontal-scrollbar, .vertical-scrollbar {
        opacity: 0;
        transition: opacity 250ms;
    }
    .scroll-view:hover .horizontal-scrollbar {
        opacity: 1;
    }
    .scroll-view:hover + .vertical-scrollbar {
        opacity: 1;
    }
}
Log1x commented 7 years ago

Thanks for that @silvestreh -- that works nicely. Only quirk is it's not setting opacity: 1; when the scrollbar its self is being hovered. I tried adding .horizontal-scrollbar:hover { opacity: 1; } but didn't have luck with that either.

Any ideas what I'd need to add to fix that inconsistency?