Skip to content

Commit

Permalink
ColumnHider: scale icon size down in browsers with small scrollbars. C…
Browse files Browse the repository at this point in the history
…loses SitePen#1328
  • Loading branch information
msssk authored and edhager committed Feb 11, 2017
1 parent 27a3753 commit 27f0000
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion extensions/ColumnHider.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ define([
var grid = this,
hiderMenuNode = this.hiderMenuNode,
hiderToggleNode = this.hiderToggleNode,
id;
id,
scrollbarWidth,
hiderNodeScale,
hiderNodeTranslate;

function stopPropagation(event) {
event.stopPropagation();
Expand All @@ -150,6 +153,17 @@ define([
type: 'button'
}, this.domNode);

// The ColumnHider icon is 16 x 16 pixels. Presumably, when it was created that size worked in all
// browsers. Hopefully any browsers (or updates) introduced since then that reduce the scrollbar width
// also include support for scaling with CSS transforms.
scrollbarWidth = this.bodyNode.offsetWidth - this.bodyNode.clientWidth;
if (scrollbarWidth < 16) {
hiderNodeScale = scrollbarWidth / 16;
hiderNodeTranslate = (16 - scrollbarWidth) / 2;
hiderToggleNode.style.transform = 'scale(' + (hiderNodeScale) + ') translate(' +
hiderNodeTranslate + 'px)';
}

this._listeners.push(listen(hiderToggleNode, 'click', function (e) {
grid._toggleColumnHiderMenu(e);
}));
Expand Down

0 comments on commit 27f0000

Please sign in to comment.