normalize-scroll-left
Advanced tools
Comparing version 0.1.0 to 0.1.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Based on https://stackoverflow.com/a/31090240 | ||
var isBrowser = new Function('try {return this===window;}catch(e){ return false;}'); | ||
// Based on https://github.com/react-bootstrap/dom-helpers/blob/master/src/util/inDOM.js | ||
var inDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); | ||
var cachedType; | ||
@@ -15,6 +15,6 @@ function _setScrollType(type) { | ||
} | ||
if (!isBrowser() || !document || !document.body) { | ||
if (!inDOM || !window.document.body) { | ||
return 'indeterminate'; | ||
} | ||
var dummy = document.createElement('div'); | ||
var dummy = window.document.createElement('div'); | ||
dummy.appendChild(document.createTextNode('ABCD')); | ||
@@ -21,0 +21,0 @@ dummy.dir = 'rtl'; |
{ | ||
"name": "normalize-scroll-left", | ||
"description": "Utility library to determine and normalize Element.scrollLeft behavior", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"author": { | ||
@@ -37,5 +37,5 @@ "name": "Ali Taheri Moghaddar", | ||
"@types/mocha": "^2.2.43", | ||
"@types/node": "^8.0.31", | ||
"@types/node": "^8.0.33", | ||
"chai": "^4.1.2", | ||
"mocha": "^4.0.0", | ||
"mocha": "^4.0.1", | ||
"rimraf": "^2.6.2", | ||
@@ -42,0 +42,0 @@ "ts-loader": "^2.3.7", |
@@ -18,3 +18,3 @@ # Normalize Scroll Left for Right-to-Left | ||
Firefox/Opera | negative | -100 | 0 | 0 | ||
IE | reverse | 100 | 0 | 0 | ||
IE/Edge | reverse | 100 | 0 | 0 | ||
@@ -41,3 +41,3 @@ ## Installation | ||
This function returns the scroll type detected, Keep in mind, this function | ||
cahces the result as it should render a dummy on the dom (which is expensive). | ||
caches the result as it should render a dummy on the DOM (which is expensive). | ||
Make sure the first invocation of this function happens **after** the body is loaded. | ||
@@ -60,3 +60,3 @@ | ||
Firefox/Opera | `negative` | ||
IE | `reverse` | ||
IE/Edge | `reverse` | ||
Other/Server | `indeterminate` | ||
@@ -120,3 +120,3 @@ | ||
// -60 in Firefox/Opera | ||
// 60 in IE | ||
// 60 in IE/Edge | ||
// Does nothing on the server | ||
@@ -123,0 +123,0 @@ ``` |
Sorry, the diff of this file is not supported yet
12412