Skip to content

Commit

Permalink
rm padding before and after for non-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ganlanyuan committed Jul 31, 2018
1 parent 4fe12e9 commit 566b8a7
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dist/min/tiny-slider.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sourcemaps/tiny-slider.js.map

Large diffs are not rendered by default.

24 changes: 21 additions & 3 deletions dist/tiny-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -1109,8 +1109,8 @@ var tns = function(options) {
slideItems = container.children;
}

initSliderTransform();
initSheet();
initSliderTransform();
if (!autoWidth) { initUI(); }
if (responsive) { setBreakpointZone(); }

Expand Down Expand Up @@ -2250,17 +2250,21 @@ var tns = function(options) {
}

function getSliderWidth () {
return fixedWidth ? (fixedWidth + gutter) * slideCountNew - gutter: slidePositions[slideCountNew - 1] + slideItems[slideCountNew - 1].getBoundingClientRect().width - gutter;
var width = fixedWidth ? (fixedWidth + gutter) * slideCountNew :
slidePositions[slideCountNew - 1] + slideItems[slideCountNew - 1].getBoundingClientRect().width;
return width - gutter;
}

function getRightBoundary () {
var result = - (getSliderWidth() - viewport);
var result = viewport - getSliderWidth();
if (edgePadding) { result += edgePadding - gutter; }
if (result > 0) { result = 0; }
return result;
}

function getContainerTransformValue (num) {
if (num == null) { num = index; }

var val;
if (horizontal && !autoWidth) {
if (fixedWidth) {
Expand All @@ -2274,8 +2278,22 @@ var tns = function(options) {
}

if (hasRightDeadZone) { val = Math.max(val, rightBoundary); }
if (horizontal && !loop && edgePadding) {
var gap = edgePadding;

if (!autoWidth && !fixedWidth) {
gap = TRANSFORM ? gap * 100 / (viewport * slideCountNew / items) : gap / viewport;
}

if (num <= 0) {
val -= gap;
} else if (num >= indexMax && !autoWidth && !fixedWidth) {
val += gap;
}
}

val += (horizontal && !autoWidth && !fixedWidth) ? '%' : 'px';

return val;
}

Expand Down
24 changes: 21 additions & 3 deletions src/tiny-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,8 @@ export var tns = function(options) {
slideItems = container.children;
}

initSliderTransform();
initSheet();
initSliderTransform();
if (!autoWidth) { initUI(); }
if (responsive) { setBreakpointZone(); }

Expand Down Expand Up @@ -1816,17 +1816,21 @@ export var tns = function(options) {
}

function getSliderWidth () {
return fixedWidth ? (fixedWidth + gutter) * slideCountNew - gutter: slidePositions[slideCountNew - 1] + slideItems[slideCountNew - 1].getBoundingClientRect().width - gutter;
var width = fixedWidth ? (fixedWidth + gutter) * slideCountNew :
slidePositions[slideCountNew - 1] + slideItems[slideCountNew - 1].getBoundingClientRect().width;
return width - gutter;
}

function getRightBoundary () {
var result = - (getSliderWidth() - viewport);
var result = viewport - getSliderWidth();
if (edgePadding) { result += edgePadding - gutter; }
if (result > 0) { result = 0; }
return result;
}

function getContainerTransformValue (num) {
if (num == null) { num = index; }

var val;
if (horizontal && !autoWidth) {
if (fixedWidth) {
Expand All @@ -1840,8 +1844,22 @@ export var tns = function(options) {
}

if (hasRightDeadZone) { val = Math.max(val, rightBoundary); }
if (horizontal && !loop && edgePadding) {
var gap = edgePadding;

if (!autoWidth && !fixedWidth) {
gap = TRANSFORM ? gap * 100 / (viewport * slideCountNew / items) : gap / viewport;
}

if (num <= 0) {
val -= gap;
} else if (num >= indexMax && !autoWidth && !fixedWidth) {
val += gap;
}
}

val += (horizontal && !autoWidth && !fixedWidth) ? '%' : 'px';

return val;
}

Expand Down
24 changes: 21 additions & 3 deletions src/tiny-slider.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,8 @@ export var tns = function(options) {
slideItems = container.children;
}

initSliderTransform();
initSheet();
initSliderTransform();
if (!autoWidth) { initUI(); }
if (responsive) { setBreakpointZone(); }

Expand Down Expand Up @@ -1816,17 +1816,21 @@ export var tns = function(options) {
}

function getSliderWidth () {
return fixedWidth ? (fixedWidth + gutter) * slideCountNew - gutter: slidePositions[slideCountNew - 1] + slideItems[slideCountNew - 1].getBoundingClientRect().width - gutter;
var width = fixedWidth ? (fixedWidth + gutter) * slideCountNew :
slidePositions[slideCountNew - 1] + slideItems[slideCountNew - 1].getBoundingClientRect().width;
return width - gutter;
}

function getRightBoundary () {
var result = - (getSliderWidth() - viewport);
var result = viewport - getSliderWidth();
if (edgePadding) { result += edgePadding - gutter; }
if (result > 0) { result = 0; }
return result;
}

function getContainerTransformValue (num) {
if (num == null) { num = index; }

var val;
if (horizontal && !autoWidth) {
if (fixedWidth) {
Expand All @@ -1840,8 +1844,22 @@ export var tns = function(options) {
}

if (hasRightDeadZone) { val = Math.max(val, rightBoundary); }
if (horizontal && !loop && edgePadding) {
var gap = edgePadding;

if (!autoWidth && !fixedWidth) {
gap = TRANSFORM ? gap * 100 / (viewport * slideCountNew / items) : gap / viewport;
}

if (num <= 0) {
val -= gap;
} else if (num >= indexMax && !autoWidth && !fixedWidth) {
val += gap;
}
}

val += (horizontal && !autoWidth && !fixedWidth) ? '%' : 'px';

return val;
}

Expand Down

0 comments on commit 566b8a7

Please sign in to comment.