Skip to content

Commit

Permalink
Merge pull request #17 from Andreyco/master
Browse files Browse the repository at this point in the history
Add option to force Gemini scrollbars
  • Loading branch information
noeldelgado committed Nov 19, 2015
2 parents 8cbf8b5 + 142eb23 commit a1be1d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ name | type | default | description
* **element** | HTMLElement | `null` | The element to apply scrollbars
autoshow | Boolean | `false` | Show scrollbars upon hovering
createElements | Boolean | `true` | Create and append the require HTMLElements at runtime.
forceGemini | Boolean | `false` | Force Gemini scrollbars even if native overlay-scrollbars are available. Useful for development.

\* `required`

Expand Down
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @license MIT
*/
(function() {
var SCROLLBAR_WIDTH, CLASSNAMES, addClass, removeClass, getScrollbarWidth;
var SCROLLBAR_WIDTH, DONT_CREATE_GEMINI, CLASSNAMES, addClass, removeClass, getScrollbarWidth;

CLASSNAMES = {
element: 'gm-scrollbar-container',
Expand Down Expand Up @@ -61,6 +61,8 @@

SCROLLBAR_WIDTH = getScrollbarWidth();

DONT_CREATE_GEMINI = SCROLLBAR_WIDTH === 0 && !this.forceGemini;

this._cache = {events: {}};
this._created = false;
this._cursorDown = false;
Expand All @@ -77,7 +79,7 @@
}

GeminiScrollbar.prototype.create = function create() {
if (SCROLLBAR_WIDTH === 0) {
if (DONT_CREATE_GEMINI) {
addClass(this.element, [CLASSNAMES.prevented]);
return this;
}
Expand Down Expand Up @@ -133,7 +135,7 @@
};

GeminiScrollbar.prototype.update = function update() {
if (SCROLLBAR_WIDTH === 0) {
if (DONT_CREATE_GEMINI) {
return this;
}

Expand All @@ -159,7 +161,7 @@
};

GeminiScrollbar.prototype.destroy = function destroy() {
if (SCROLLBAR_WIDTH === 0) {
if (DONT_CREATE_GEMINI) {
return this;
}

Expand Down

0 comments on commit a1be1d0

Please sign in to comment.