Merge pull request #251 from tatarinov/master
Renamed 'int' helper in 'getInt' #250
This commit is contained in:
commit
9b3301fd0c
@ -17,7 +17,7 @@
|
|||||||
})(function ($) {
|
})(function ($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function int(x) {
|
function getInt(x) {
|
||||||
if (typeof x === 'string') {
|
if (typeof x === 'string') {
|
||||||
return parseInt(x, 10);
|
return parseInt(x, 10);
|
||||||
} else {
|
} else {
|
||||||
@ -107,20 +107,20 @@
|
|||||||
var scrollbarXActive;
|
var scrollbarXActive;
|
||||||
var scrollbarXWidth;
|
var scrollbarXWidth;
|
||||||
var scrollbarXLeft;
|
var scrollbarXLeft;
|
||||||
var scrollbarXBottom = int($scrollbarXRail.css('bottom'));
|
var scrollbarXBottom = getInt($scrollbarXRail.css('bottom'));
|
||||||
var isScrollbarXUsingBottom = scrollbarXBottom === scrollbarXBottom; // !isNaN
|
var isScrollbarXUsingBottom = scrollbarXBottom === scrollbarXBottom; // !isNaN
|
||||||
var scrollbarXTop = isScrollbarXUsingBottom ? null : int($scrollbarXRail.css('top'));
|
var scrollbarXTop = isScrollbarXUsingBottom ? null : getInt($scrollbarXRail.css('top'));
|
||||||
var railBorderXWidth = int($scrollbarXRail.css('borderLeftWidth')) + int($scrollbarXRail.css('borderRightWidth'));
|
var railBorderXWidth = getInt($scrollbarXRail.css('borderLeftWidth')) + getInt($scrollbarXRail.css('borderRightWidth'));
|
||||||
|
|
||||||
var $scrollbarYRail = $("<div class='ps-scrollbar-y-rail'>").appendTo($this);
|
var $scrollbarYRail = $("<div class='ps-scrollbar-y-rail'>").appendTo($this);
|
||||||
var $scrollbarY = $("<div class='ps-scrollbar-y'>").appendTo($scrollbarYRail);
|
var $scrollbarY = $("<div class='ps-scrollbar-y'>").appendTo($scrollbarYRail);
|
||||||
var scrollbarYActive;
|
var scrollbarYActive;
|
||||||
var scrollbarYHeight;
|
var scrollbarYHeight;
|
||||||
var scrollbarYTop;
|
var scrollbarYTop;
|
||||||
var scrollbarYRight = int($scrollbarYRail.css('right'));
|
var scrollbarYRight = getInt($scrollbarYRail.css('right'));
|
||||||
var isScrollbarYUsingRight = scrollbarYRight === scrollbarYRight; // !isNaN
|
var isScrollbarYUsingRight = scrollbarYRight === scrollbarYRight; // !isNaN
|
||||||
var scrollbarYLeft = isScrollbarYUsingRight ? null : int($scrollbarYRail.css('left'));
|
var scrollbarYLeft = isScrollbarYUsingRight ? null : getInt($scrollbarYRail.css('left'));
|
||||||
var railBorderYWidth = int($scrollbarYRail.css('borderTopWidth')) + int($scrollbarYRail.css('borderBottomWidth'));
|
var railBorderYWidth = getInt($scrollbarYRail.css('borderTopWidth')) + getInt($scrollbarYRail.css('borderBottomWidth'));
|
||||||
|
|
||||||
function updateScrollTop(currentTop, deltaY) {
|
function updateScrollTop(currentTop, deltaY) {
|
||||||
var newTop = currentTop + deltaY;
|
var newTop = currentTop + deltaY;
|
||||||
@ -134,7 +134,7 @@
|
|||||||
scrollbarYTop = newTop;
|
scrollbarYTop = newTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
var scrollTop = int(scrollbarYTop * (contentHeight - containerHeight) / (containerHeight - scrollbarYHeight));
|
var scrollTop = getInt(scrollbarYTop * (contentHeight - containerHeight) / (containerHeight - scrollbarYHeight));
|
||||||
$this.scrollTop(scrollTop);
|
$this.scrollTop(scrollTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@
|
|||||||
scrollbarXLeft = newLeft;
|
scrollbarXLeft = newLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
var scrollLeft = int(scrollbarXLeft * (contentWidth - containerWidth) / (containerWidth - scrollbarXWidth));
|
var scrollLeft = getInt(scrollbarXLeft * (contentWidth - containerWidth) / (containerWidth - scrollbarXWidth));
|
||||||
$this.scrollLeft(scrollLeft);
|
$this.scrollLeft(scrollLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,8 +211,8 @@
|
|||||||
|
|
||||||
if (!settings.suppressScrollX && containerWidth + settings.scrollXMarginOffset < contentWidth) {
|
if (!settings.suppressScrollX && containerWidth + settings.scrollXMarginOffset < contentWidth) {
|
||||||
scrollbarXActive = true;
|
scrollbarXActive = true;
|
||||||
scrollbarXWidth = getThumbSize(int(containerWidth * containerWidth / contentWidth));
|
scrollbarXWidth = getThumbSize(getInt(containerWidth * containerWidth / contentWidth));
|
||||||
scrollbarXLeft = int($this.scrollLeft() * (containerWidth - scrollbarXWidth) / (contentWidth - containerWidth));
|
scrollbarXLeft = getInt($this.scrollLeft() * (containerWidth - scrollbarXWidth) / (contentWidth - containerWidth));
|
||||||
} else {
|
} else {
|
||||||
scrollbarXActive = false;
|
scrollbarXActive = false;
|
||||||
scrollbarXWidth = 0;
|
scrollbarXWidth = 0;
|
||||||
@ -222,8 +222,8 @@
|
|||||||
|
|
||||||
if (!settings.suppressScrollY && containerHeight + settings.scrollYMarginOffset < contentHeight) {
|
if (!settings.suppressScrollY && containerHeight + settings.scrollYMarginOffset < contentHeight) {
|
||||||
scrollbarYActive = true;
|
scrollbarYActive = true;
|
||||||
scrollbarYHeight = getThumbSize(int(containerHeight * containerHeight / contentHeight));
|
scrollbarYHeight = getThumbSize(getInt(containerHeight * containerHeight / contentHeight));
|
||||||
scrollbarYTop = int($this.scrollTop() * (containerHeight - scrollbarYHeight) / (contentHeight - containerHeight));
|
scrollbarYTop = getInt($this.scrollTop() * (containerHeight - scrollbarYHeight) / (contentHeight - containerHeight));
|
||||||
} else {
|
} else {
|
||||||
scrollbarYActive = false;
|
scrollbarYActive = false;
|
||||||
scrollbarYHeight = 0;
|
scrollbarYHeight = 0;
|
||||||
@ -503,7 +503,7 @@
|
|||||||
|
|
||||||
$scrollbarY.bind(eventClass('click'), stopPropagation);
|
$scrollbarY.bind(eventClass('click'), stopPropagation);
|
||||||
$scrollbarYRail.bind(eventClass('click'), function (e) {
|
$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 positionTop = e.pageY - $scrollbarYRail.offset().top - halfOfScrollbarLength;
|
||||||
var maxPositionTop = containerHeight - scrollbarYHeight;
|
var maxPositionTop = containerHeight - scrollbarYHeight;
|
||||||
var positionRatio = positionTop / maxPositionTop;
|
var positionRatio = positionTop / maxPositionTop;
|
||||||
@ -519,7 +519,7 @@
|
|||||||
|
|
||||||
$scrollbarX.bind(eventClass('click'), stopPropagation);
|
$scrollbarX.bind(eventClass('click'), stopPropagation);
|
||||||
$scrollbarXRail.bind(eventClass('click'), function (e) {
|
$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 positionLeft = e.pageX - $scrollbarXRail.offset().left - halfOfScrollbarLength;
|
||||||
var maxPositionLeft = containerWidth - scrollbarXWidth;
|
var maxPositionLeft = containerWidth - scrollbarXWidth;
|
||||||
var positionRatio = positionLeft / maxPositionLeft;
|
var positionRatio = positionLeft / maxPositionLeft;
|
||||||
|
Loading…
Reference in New Issue
Block a user