From 142eb234e8ed3bc6a5d158166232a5b5a4d0d7ef Mon Sep 17 00:00:00 2001 From: Andrej Badin Date: Wed, 18 Nov 2015 00:42:34 +0100 Subject: [PATCH] Add option to force Gemini scrollbars even if native overlay-scrollbars are available. --- README.md | 1 + index.js | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 27b41ca..d9c2538 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/index.js b/index.js index 55ac07d..7412199 100644 --- a/index.js +++ b/index.js @@ -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', @@ -61,6 +61,8 @@ SCROLLBAR_WIDTH = getScrollbarWidth(); + DONT_CREATE_GEMINI = SCROLLBAR_WIDTH === 0 && !this.forceGemini; + this._cache = {events: {}}; this._created = false; this._cursorDown = false; @@ -77,7 +79,7 @@ } GeminiScrollbar.prototype.create = function create() { - if (SCROLLBAR_WIDTH === 0) { + if (DONT_CREATE_GEMINI) { addClass(this.element, [CLASSNAMES.prevented]); return this; } @@ -133,7 +135,7 @@ }; GeminiScrollbar.prototype.update = function update() { - if (SCROLLBAR_WIDTH === 0) { + if (DONT_CREATE_GEMINI) { return this; } @@ -159,7 +161,7 @@ }; GeminiScrollbar.prototype.destroy = function destroy() { - if (SCROLLBAR_WIDTH === 0) { + if (DONT_CREATE_GEMINI) { return this; }