Browse files

Fixed typo and enhanced the implementation.

  • Loading branch information...
1 parent fa52300 commit 5c5368d3917d9c9d72296061f8749cdedb8eb66d @asteitz asteitz committed May 7, 2012
Showing with 12 additions and 8 deletions.
  1. +12 −8 framework/source/class/qx/bom/Viewport.js
View
20 framework/source/class/qx/bom/Viewport.js
@@ -124,16 +124,18 @@ qx.Bootstrap.define("qx.bom.Viewport",
* use a one-time environment check to decide which property to use.
*
* @param win {Window?window} The window to query
- * @return {Integer} Scroll position from left edge, always a positive integer
+ * @return {Integer} Scroll position in pixels from left edge, always a positive integer or zero
*/
getScrollLeft : function(win)
{
var win = win ? win : window;
- var doc = (win||window).document;
-
+
if (typeof win.pageXOffset !== "undefined") {
- return win.pageYOffset;
- } else if (typeof doc.documentElement.scrollLeft !== "undefined") {
+ return win.pageXOffset;
+ }
+
+ var doc = win.document;
+ if (typeof doc.documentElement.scrollLeft !== "undefined") {
return doc.documentElement.scrollLeft;
} else {
return doc.body.scrollLeft;
@@ -150,16 +152,18 @@ qx.Bootstrap.define("qx.bom.Viewport",
* use a one-time environment check to decide which property to use.
*
* @param win {Window?window} The window to query
- * @return {Integer} Scroll position from top edge, always a positive integer
+ * @return {Integer} Scroll position in pixels from top edge, always a positive integer or zero
*/
getScrollTop : function(win)
{
var win = win ? win : window;
- var doc = (win||window).document;
if (typeof win.pageYOffeset !== "undefined") {
return win.pageYOffset;
- } else if (typeof doc.documentElement.scrollTop !== "undefined") {
+ }
+
+ var doc = win.document;
+ if (typeof doc.documentElement.scrollTop !== "undefined") {
return doc.documentElement.scrollTop;
} else {
return doc.body.scrollTop;

0 comments on commit 5c5368d

Please sign in to comment.