Skip to content

Commit

Permalink
Math.round in some case clips the slides
Browse files Browse the repository at this point in the history
Math.round replaced with Math.ceil
  • Loading branch information
OrbintSoft committed May 9, 2014
1 parent c5b6cf0 commit bf493c9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/idangerous.swiper.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,11 @@ var Swiper = function (selector, params) {
}
else {
slideHeight = isH ? _this.height : _this.height / params.slidesPerView;
if (params.roundLengths) slideHeight = Math.round(slideHeight);
if (params.roundLengths) slideHeight = Math.ceil(slideHeight);
wrapperHeight = isH ? _this.height : _this.slides.length * slideHeight;
}
slideWidth = isH ? _this.width / params.slidesPerView : _this.width;
if (params.roundLengths) slideWidth = Math.round(slideWidth);
if (params.roundLengths) slideWidth = Math.ceil(slideWidth);
wrapperWidth = isH ? _this.slides.length * slideWidth : _this.width;
slideSize = isH ? slideWidth : slideHeight;

Expand Down Expand Up @@ -1804,7 +1804,7 @@ var Swiper = function (selector, params) {
if (currentPosition <= -maxWrapperPosition()) newPosition = -maxWrapperPosition();
}
else {
newPosition = currentPosition < 0 ? Math.round(currentPosition / groupSize) * groupSize : 0;
newPosition = currentPosition < 0 ? Math.ceil(currentPosition / groupSize) * groupSize : 0;
}
if (params.scrollContainer) {
newPosition = currentPosition < 0 ? currentPosition : 0;
Expand Down Expand Up @@ -1856,7 +1856,7 @@ var Swiper = function (selector, params) {
currentPosition += animationStep * time / (1000 / 60);
condition = direction === 'toNext' ? currentPosition > newPosition : currentPosition < newPosition;
if (condition) {
_this.setWrapperTranslate(Math.round(currentPosition));
_this.setWrapperTranslate(Math.ceil(currentPosition));
_this._DOMAnimating = true;
window.setTimeout(function () {
anim();
Expand Down Expand Up @@ -2592,7 +2592,7 @@ Swiper.prototype = {
returnWidth = el.offsetWidth - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right'));
}
if (outer) returnWidth += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right'));
if (round) return Math.round(returnWidth);
if (round) return Math.ceil(returnWidth);
else return returnWidth;
},
getHeight: function (el, outer, round) {
Expand All @@ -2606,7 +2606,7 @@ Swiper.prototype = {
returnHeight = el.offsetHeight - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom'));
}
if (outer) returnHeight += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom'));
if (round) return Math.round(returnHeight);
if (round) return Math.ceil(returnHeight);
else return returnHeight;
},
getOffset: function (el) {
Expand Down

0 comments on commit bf493c9

Please sign in to comment.