Skip to content

Commit

Permalink
reset padding for non-loop, update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ganlanyuan committed Aug 2, 2018
1 parent 88ba2ba commit 7faa060
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 68 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.

27 changes: 14 additions & 13 deletions dist/tiny-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2278,19 +2278,20 @@ 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;
}
}
// // remove edge padding for non-loop
// 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';

Expand Down
27 changes: 14 additions & 13 deletions src/tiny-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -1844,19 +1844,20 @@ 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;
}
}
// // remove edge padding for non-loop
// 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';

Expand Down
27 changes: 14 additions & 13 deletions src/tiny-slider.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -1844,19 +1844,20 @@ 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;
}
}
// // remove edge padding for non-loop
// 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';

Expand Down
33 changes: 13 additions & 20 deletions tests/js/tests-async-es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -1438,62 +1438,55 @@ function testResponsive6() {
viewport = wrapper.clientWidth;
assertionEdgePadding = child0.getBoundingClientRect().left === edgepadding && child0.getBoundingClientRect().right === viewport - (edgepadding - gutter);

// go to the second slide
nextButton.click();
_context7.next = 7;
return wait(1000);

case 7:

// resize window
newWindow.style.width = slideWidth * 2 + 100 + 'px';
_context7.next = 10;
_context7.next = 7;
return wait(1000);

case 10:
case 7:
if (assertionEdgePadding) {
assertionEdgePadding = child0.getBoundingClientRect().left === 0;
}
assertionControlsNav = getComputedStyle(controls, null).display === 'none' && getComputedStyle(nav, null).display === 'none';

// resize window
newWindow.style.width = slideWidth + edgepadding * 2 - gutter + 'px';
_context7.next = 15;
_context7.next = 12;
return wait(1000);

case 15:
case 12:
if (assertionEdgePadding) {
viewport = wrapper.clientWidth;
assertionEdgePadding = child1.getBoundingClientRect().left === edgepadding + gutter && child1.getBoundingClientRect().right === viewport - (edgepadding - gutter * 2);
assertionEdgePadding = child0.getBoundingClientRect().left === edgepadding && child0.getBoundingClientRect().right === viewport - (edgepadding - gutter);
}
if (assertionControlsNav) {
assertionControlsNav = getComputedStyle(controls, null).display !== 'none' && getComputedStyle(nav, null).display !== 'none';
}

updateTest(testEdgePaddingT, assertionEdgePadding);
updateTest(testControlsNavT, assertionControlsNav);
_context7.next = 25;
_context7.next = 22;
break;

case 21:
_context7.prev = 21;
case 18:
_context7.prev = 18;
_context7.t0 = _context7['catch'](0);

updateTest(testEdgePaddingT, assertionEdgePadding);
updateTest(testControlsNavT, assertionControlsNav);

case 25:
_context7.prev = 25;
case 22:
_context7.prev = 22;

document.body.removeChild(newWindow);
return _context7.finish(25);
return _context7.finish(22);

case 28:
case 25:
case 'end':
return _context7.stop();
}
}
}, _callee7, this, [[0, 21, 25, 28]]);
}, _callee7, this, [[0, 18, 22, 25]]);
}));

return function responsive6Tests() {
Expand Down
9 changes: 2 additions & 7 deletions tests/js/tests-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,6 @@ function testResponsive6 () {
nav = wrapper.querySelector('.tns-nav'),
child0 = container.children[0],
child1 = container.children[1],
// child2 = container.children[2],
childL = container.children[container.children.length - 1],
prevButton = controls.children[0],
nextButton = controls.children[1],
Expand All @@ -1311,10 +1310,6 @@ function testResponsive6 () {
child0.getBoundingClientRect().left === edgepadding &&
child0.getBoundingClientRect().right === viewport - (edgepadding - gutter);

// go to the second slide
nextButton.click();
await wait(1000);

// resize window
newWindow.style.width = (slideWidth * 2 + 100) + 'px';
await wait(1000);
Expand All @@ -1331,8 +1326,8 @@ function testResponsive6 () {
if (assertionEdgePadding) {
viewport = wrapper.clientWidth;
assertionEdgePadding =
child1.getBoundingClientRect().left === edgepadding + gutter &&
child1.getBoundingClientRect().right === viewport - (edgepadding - gutter * 2);
child0.getBoundingClientRect().left === edgepadding &&
child0.getBoundingClientRect().right === viewport - (edgepadding - gutter);
}
if (assertionControlsNav) {
assertionControlsNav =
Expand Down

0 comments on commit 7faa060

Please sign in to comment.