From 20053e9cf1496b6d232f176978eadf7ac93acb78 Mon Sep 17 00:00:00 2001 From: tatarinov Date: Fri, 14 Nov 2014 10:00:59 +0400 Subject: [PATCH 1/2] Renamed 'int' helper in 'getInt' #250 --- src/perfect-scrollbar.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/perfect-scrollbar.js b/src/perfect-scrollbar.js index 9e5c2ee..37a1452 100644 --- a/src/perfect-scrollbar.js +++ b/src/perfect-scrollbar.js @@ -17,13 +17,13 @@ })(function ($) { 'use strict'; - function int(x) { + function getInt(x) { if (typeof x === 'string') { return parseInt(x, 10); } else { return ~~x; } - } + }; var defaultSettings = { wheelSpeed: 1, @@ -107,20 +107,20 @@ var scrollbarXActive; var scrollbarXWidth; var scrollbarXLeft; - var scrollbarXBottom = int($scrollbarXRail.css('bottom')); + var scrollbarXBottom = getInt($scrollbarXRail.css('bottom')); var isScrollbarXUsingBottom = scrollbarXBottom === scrollbarXBottom; // !isNaN - var scrollbarXTop = isScrollbarXUsingBottom ? null : int($scrollbarXRail.css('top')); - var railBorderXWidth = int($scrollbarXRail.css('borderLeftWidth')) + int($scrollbarXRail.css('borderRightWidth')); + var scrollbarXTop = isScrollbarXUsingBottom ? null : getInt($scrollbarXRail.css('top')); + var railBorderXWidth = getInt($scrollbarXRail.css('borderLeftWidth')) + getInt($scrollbarXRail.css('borderRightWidth')); var $scrollbarYRail = $("
").appendTo($this); var $scrollbarY = $("
").appendTo($scrollbarYRail); var scrollbarYActive; var scrollbarYHeight; var scrollbarYTop; - var scrollbarYRight = int($scrollbarYRail.css('right')); + var scrollbarYRight = getInt($scrollbarYRail.css('right')); var isScrollbarYUsingRight = scrollbarYRight === scrollbarYRight; // !isNaN - var scrollbarYLeft = isScrollbarYUsingRight ? null : int($scrollbarYRail.css('left')); - var railBorderYWidth = int($scrollbarYRail.css('borderTopWidth')) + int($scrollbarYRail.css('borderBottomWidth')); + var scrollbarYLeft = isScrollbarYUsingRight ? null : getInt($scrollbarYRail.css('left')); + var railBorderYWidth = getInt($scrollbarYRail.css('borderTopWidth')) + getInt($scrollbarYRail.css('borderBottomWidth')); function updateScrollTop(currentTop, deltaY) { var newTop = currentTop + deltaY; @@ -134,7 +134,7 @@ scrollbarYTop = newTop; } - var scrollTop = int(scrollbarYTop * (contentHeight - containerHeight) / (containerHeight - scrollbarYHeight)); + var scrollTop = getInt(scrollbarYTop * (contentHeight - containerHeight) / (containerHeight - scrollbarYHeight)); $this.scrollTop(scrollTop); } @@ -150,7 +150,7 @@ scrollbarXLeft = newLeft; } - var scrollLeft = int(scrollbarXLeft * (contentWidth - containerWidth) / (containerWidth - scrollbarXWidth)); + var scrollLeft = getInt(scrollbarXLeft * (contentWidth - containerWidth) / (containerWidth - scrollbarXWidth)); $this.scrollLeft(scrollLeft); } @@ -211,8 +211,8 @@ if (!settings.suppressScrollX && containerWidth + settings.scrollXMarginOffset < contentWidth) { scrollbarXActive = true; - scrollbarXWidth = getThumbSize(int(containerWidth * containerWidth / contentWidth)); - scrollbarXLeft = int($this.scrollLeft() * (containerWidth - scrollbarXWidth) / (contentWidth - containerWidth)); + scrollbarXWidth = getThumbSize(getInt(containerWidth * containerWidth / contentWidth)); + scrollbarXLeft = getInt($this.scrollLeft() * (containerWidth - scrollbarXWidth) / (contentWidth - containerWidth)); } else { scrollbarXActive = false; scrollbarXWidth = 0; @@ -222,8 +222,8 @@ if (!settings.suppressScrollY && containerHeight + settings.scrollYMarginOffset < contentHeight) { scrollbarYActive = true; - scrollbarYHeight = getThumbSize(int(containerHeight * containerHeight / contentHeight)); - scrollbarYTop = int($this.scrollTop() * (containerHeight - scrollbarYHeight) / (contentHeight - containerHeight)); + scrollbarYHeight = getThumbSize(getInt(containerHeight * containerHeight / contentHeight)); + scrollbarYTop = getInt($this.scrollTop() * (containerHeight - scrollbarYHeight) / (contentHeight - containerHeight)); } else { scrollbarYActive = false; scrollbarYHeight = 0; @@ -503,7 +503,7 @@ $scrollbarY.bind(eventClass('click'), stopPropagation); $scrollbarYRail.bind(eventClass('click'), function (e) { - var halfOfScrollbarLength = int(scrollbarYHeight / 2); + var halfOfScrollbarLength = getInt(scrollbarYHeight / 2); var positionTop = e.pageY - $scrollbarYRail.offset().top - halfOfScrollbarLength; var maxPositionTop = containerHeight - scrollbarYHeight; var positionRatio = positionTop / maxPositionTop; @@ -519,7 +519,7 @@ $scrollbarX.bind(eventClass('click'), stopPropagation); $scrollbarXRail.bind(eventClass('click'), function (e) { - var halfOfScrollbarLength = int(scrollbarXWidth / 2); + var halfOfScrollbarLength = getInt(scrollbarXWidth / 2); var positionLeft = e.pageX - $scrollbarXRail.offset().left - halfOfScrollbarLength; var maxPositionLeft = containerWidth - scrollbarXWidth; var positionRatio = positionLeft / maxPositionLeft; From a94df46fe3529c39dc673c521f401cf66a2de072 Mon Sep 17 00:00:00 2001 From: tatarinov Date: Fri, 14 Nov 2014 10:25:19 +0400 Subject: [PATCH 2/2] Removed unnecessary semicolon --- src/perfect-scrollbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/perfect-scrollbar.js b/src/perfect-scrollbar.js index 37a1452..2e82972 100644 --- a/src/perfect-scrollbar.js +++ b/src/perfect-scrollbar.js @@ -23,7 +23,7 @@ } else { return ~~x; } - }; + } var defaultSettings = { wheelSpeed: 1,