get-scroll-info
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -25,4 +25,4 @@ "use strict"; | ||
top: 0, | ||
right: 0, | ||
bottom: 0, | ||
right: 1024, | ||
bottom: 768, | ||
left: 0 | ||
@@ -29,0 +29,0 @@ }); |
@@ -65,7 +65,21 @@ "use strict"; | ||
var nodeName = (el.nodeName || "").toLowerCase(); | ||
var isRoot = "body" === nodeName || "html" === nodeName; | ||
var isRoot = "body" === nodeName || "html" === nodeName; // defined scrollWidth and scrollHeight first. | ||
// to know if have vertical or horizontal bar. | ||
var scrollWidth = el.scrollWidth; | ||
var scrollHeight = el.scrollHeight; | ||
if (isRoot) { | ||
w = Math.max(docEl.clientWidth || 0, oWin.innerWidth || 0); | ||
h = Math.max(docEl.clientHeight || 0, oWin.innerHeight || 0); | ||
w = Math.max(el.clientWidth || 0, oWin.innerWidth || 0); | ||
h = Math.max(el.clientHeight || 0, oWin.innerHeight || 0); | ||
var hasHorizontalBar = w < scrollWidth; | ||
var hasVerticalBar = h < scrollHeight; | ||
if (hasHorizontalBar) { | ||
h = el.clientHeight; | ||
} | ||
if (hasVerticalBar) { | ||
w = el.clientWidth; | ||
} | ||
} else { | ||
@@ -77,5 +91,3 @@ w = el.clientWidth; | ||
var scrollLeft = el.scrollLeft; | ||
var scrollHeight = el.scrollHeight; | ||
var scrollTop = el.scrollTop; | ||
var scrollWidth = el.scrollWidth; | ||
var scrollBottom = scrollTop + h; | ||
@@ -99,4 +111,4 @@ var scrollRight = scrollLeft + w; | ||
top: scrollTop, | ||
right: w > scrollWidth ? scrollWidth : scrollRight, | ||
bottom: h > scrollHeight ? scrollHeight : scrollBottom, | ||
right: scrollRight, | ||
bottom: scrollBottom, | ||
left: scrollLeft | ||
@@ -103,0 +115,0 @@ }; |
@@ -19,4 +19,4 @@ import { expect } from "chai"; | ||
top: 0, | ||
right: 0, | ||
bottom: 0, | ||
right: 1024, | ||
bottom: 768, | ||
left: 0 | ||
@@ -23,0 +23,0 @@ }); |
@@ -51,7 +51,21 @@ import _typeof from "reshow-runtime/es/helpers/typeof"; | ||
var nodeName = (el.nodeName || "").toLowerCase(); | ||
var isRoot = "body" === nodeName || "html" === nodeName; | ||
var isRoot = "body" === nodeName || "html" === nodeName; // defined scrollWidth and scrollHeight first. | ||
// to know if have vertical or horizontal bar. | ||
var scrollWidth = el.scrollWidth; | ||
var scrollHeight = el.scrollHeight; | ||
if (isRoot) { | ||
w = Math.max(docEl.clientWidth || 0, oWin.innerWidth || 0); | ||
h = Math.max(docEl.clientHeight || 0, oWin.innerHeight || 0); | ||
w = Math.max(el.clientWidth || 0, oWin.innerWidth || 0); | ||
h = Math.max(el.clientHeight || 0, oWin.innerHeight || 0); | ||
var hasHorizontalBar = w < scrollWidth; | ||
var hasVerticalBar = h < scrollHeight; | ||
if (hasHorizontalBar) { | ||
h = el.clientHeight; | ||
} | ||
if (hasVerticalBar) { | ||
w = el.clientWidth; | ||
} | ||
} else { | ||
@@ -63,5 +77,3 @@ w = el.clientWidth; | ||
var scrollLeft = el.scrollLeft; | ||
var scrollHeight = el.scrollHeight; | ||
var scrollTop = el.scrollTop; | ||
var scrollWidth = el.scrollWidth; | ||
var scrollBottom = scrollTop + h; | ||
@@ -85,4 +97,4 @@ var scrollRight = scrollLeft + w; | ||
top: scrollTop, | ||
right: w > scrollWidth ? scrollWidth : scrollRight, | ||
bottom: h > scrollHeight ? scrollHeight : scrollBottom, | ||
right: scrollRight, | ||
bottom: scrollBottom, | ||
left: scrollLeft | ||
@@ -89,0 +101,0 @@ }; |
{ | ||
"name": "get-scroll-info", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Get Scroll Information", | ||
@@ -5,0 +5,0 @@ "repository": "react-atomic/react-atomic-organism", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7928
233