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

[Performance] remove drawGutter #304

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions lib/raf-debounce.js

This file was deleted.

29 changes: 0 additions & 29 deletions lib/tool-bar-view.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const {CompositeDisposable, Emitter} = require('atom');
const rafDebounce = require('./raf-debounce');

module.exports = class ToolBarView {
constructor () {
Expand Down Expand Up @@ -46,12 +45,6 @@ module.exports = class ToolBarView {
if (atom.config.get('tool-bar.visible')) {
this.show();
}

this.drawGutter = rafDebounce(this.drawGutter.bind(this));
this.subscriptions.add(this.drawGutter);

this.element.addEventListener('scroll', this.drawGutter);
window.addEventListener('resize', this.drawGutter);
}

addItem (newItem) {
Expand All @@ -76,15 +69,13 @@ module.exports = class ToolBarView {
nextItem ? nextItem.element : null
);

this.drawGutter();

return nextItem;
}

removeItem (item) {
item.destroy();
this.items.splice(this.items.indexOf(item), 1);
this.drawGutter();
}

destroy () {
Expand All @@ -95,11 +86,8 @@ module.exports = class ToolBarView {
this.subscriptions = null;

this.hide();
this.element.removeEventListener('scroll', this.drawGutter);
this.element = null;

window.removeEventListener('resize', this.drawGutter);

this.emitter.emit('did-destroy');
this.emitter.dispose();
this.emitter = null;
Expand Down Expand Up @@ -170,23 +158,6 @@ module.exports = class ToolBarView {
}
}

drawGutter () {
this.element.classList.remove('gutter-top', 'gutter-bottom');

const visibleHeight = this.element.offsetHeight;
const scrollHeight = this.element.scrollHeight;
const hiddenHeight = scrollHeight - visibleHeight;

if (visibleHeight < scrollHeight) {
if (this.element.scrollTop > 0) {
this.element.classList.add('gutter-top');
}
if (this.element.scrollTop < hiddenHeight) {
this.element.classList.add('gutter-bottom');
}
}
}

hide () {
if (this.panel != null) {
if (this.element.parentNode) {
Expand Down
18 changes: 0 additions & 18 deletions styles/tool-bar.less
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,6 @@
&::-webkit-scrollbar {
display: none;
}

&.gutter-top::before,
&.gutter-bottom::after {
content: "";
height: 100%;
left: 0;
pointer-events: none;
position: absolute;
top: 0;
width: 100%;
z-index: 1;
}
&.gutter-top::before {
box-shadow: inset 0px 20px 25px -20px rgb(0, 0, 0);
}
&.gutter-bottom::after {
box-shadow: inset 0px -20px 25px -20px rgb(0, 0, 0);
}
}

.tool-bar-btn {
Expand Down