Skip to content

Commit

Permalink
fix loop: few slide items
Browse files Browse the repository at this point in the history
  • Loading branch information
ganlanyuan committed Nov 19, 2017
1 parent 2bf9183 commit c47b6eb
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 71 deletions.
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,26 @@ There are 2 ways to get slider information, both return `info` Object:
```javascript
// info Object
info = {
container: container, // slider container
slideItems: slideItems, // slides list
navContainer: navContainer, // nav container
navItems: navItems, // dots list
controlsContainer: controlsContainer, // controls container
prevButton: prevButton, // previous button
nextButton: nextButton, // next button
items: items, // items on a page
slideBy: slideBy // items slide by
cloneCount: cloneCount, // cloned slide count
slideCount: slideCount, // original slide count
slideCountNew: slideCountNew, // total slide count after initialization
index: index, // current index
indexCached: indexCached, // previous index
navCurrent: navCurrent, // current dot index
navCurrentCached: navCurrentCached, // previous dot index
visibleNavIndexes: visibleNavIndexes, // visible nav indexes
container: container, // slider container
slideItems: slideItems, // slides list
navContainer: navContainer, // nav container
navItems: navItems, // dots list
controlsContainer: controlsContainer, // controls container
hasControls: hasControls, // indicate if controls exist
prevButton: prevButton, // previous button
nextButton: nextButton, // next button
items: items, // items on a page
slideBy: slideBy // items slide by
cloneCount: cloneCount, // cloned slide count
slideCount: slideCount, // original slide count
slideCountNew: slideCountNew, // total slide count after initialization
index: index, // current index
indexCached: indexCached, // previous index
navCurrent: navCurrent, // current dot index
navCurrentCached: navCurrentCached, // previous dot index
visibleNavIndexes: visibleNavIndexes, // visible nav indexes
visibleNavIndexesCached: visibleNavIndexesCached,
event: e || {}, // event object if available
event: e || {}, // event object if available
};
```

Expand Down
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.

4 changes: 2 additions & 2 deletions dist/tiny-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,8 @@ var tns = function(options) {
// activate visible slides
// add aria attrs
// set animation classes and left value for gallery slider
var itemsTem = loop ? items : Math.min(slideCount, items);
for (var i = index; i < index + itemsTem; i++) {
// use slide count when slides are fewer than items
for (var i = index; i < index + Math.min(slideCount, items); i++) {
var item = slideItems[i];
setAttrs(item, {'aria-hidden': 'false'});
removeAttrs(item, ['tabindex']);
Expand Down
4 changes: 2 additions & 2 deletions src/tiny-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ export var tns = function(options) {
// activate visible slides
// add aria attrs
// set animation classes and left value for gallery slider
var itemsTem = loop ? items : Math.min(slideCount, items);
for (var i = index; i < index + itemsTem; i++) {
// use slide count when slides are fewer than items
for (var i = index; i < index + Math.min(slideCount, items); i++) {
var item = slideItems[i];
setAttrs(item, {'aria-hidden': 'false'});
removeAttrs(item, ['tabindex']);
Expand Down
4 changes: 2 additions & 2 deletions src/tiny-slider.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ export var tns = function(options) {
// activate visible slides
// add aria attrs
// set animation classes and left value for gallery slider
var itemsTem = loop ? items : Math.min(slideCount, items);
for (var i = index; i < index + itemsTem; i++) {
// use slide count when slides are fewer than items
for (var i = index; i < index + Math.min(slideCount, items); i++) {
var item = slideItems[i];
setAttrs(item, {'aria-hidden': 'false'});
removeAttrs(item, ['tabindex']);
Expand Down
10 changes: 5 additions & 5 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1106,39 +1106,39 @@ <h2>
<div class="autoHeight" id="autoHeight">
<div>
<div>
<img src="images/1000x800/1.png" alt="">
<img src="images/1000x600/1.png" alt="">
</div>
<p>
Sunt dignissimos distinctio, veniam, tenetur aspernatur nulla!
</p>
</div>
<div>
<div>
<img src="images/1000x900/2.png" alt="">
<img src="images/1000x700/2.png" alt="">
</div>
<p>
Corrupti, libero minima nihil expedita officiis? Quo.
</p>
</div>
<div>
<div>
<img src="images/1000x800/3.png" alt="">
<img src="images/1000x600/3.png" alt="">
</div>
<p>
Alias rem, ab impedit recusandae repellat tempore.
</p>
</div>
<div>
<div>
<img src="images/1000x800/4.png" alt="">
<img src="images/1000x600/4.png" alt="">
</div>
<p>
Nisi inventore quo delectus perspiciatis voluptatibus, quae.
</p>
</div>
<div>
<div>
<img src="images/1000x800/5.png" alt="">
<img src="images/1000x900/5.png" alt="">
</div>
<p>
Nisi harum earum consectetur laudantium iusto, laboriosam.
Expand Down
18 changes: 0 additions & 18 deletions tests/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@ window.speed = Number(document.body.getAttribute('data-speed'));
window.edgepadding = 50;
window.gutter = 10;
window.options = {
// 'test': {
// mode: 'gallery',
// gutter: 20,
// edgePadding: 50,
// items: 2,
// disable: true,
// responsive: {
// 600: {
// items: 3,
// controls: true,
// disable: false,
// },
// 900: {
// items: 4,
// disable: true,
// }
// }
// },
'base': {
container: '',
items: 3,
Expand Down
18 changes: 0 additions & 18 deletions tests/js/script.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,6 @@ window.speed = Number(document.body.getAttribute('data-speed'));
window.edgepadding = 50;
window.gutter = 10;
window.options = {
// 'test': {
// mode: 'gallery',
// gutter: 20,
// edgePadding: 50,
// items: 2,
// disable: true,
// responsive: {
// 600: {
// items: 3,
// controls: true,
// disable: false,
// },
// 900: {
// items: 4,
// disable: true,
// }
// }
// },
'base': {
container: '',
items: 3,
Expand Down
8 changes: 4 additions & 4 deletions tests/tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -1634,31 +1634,31 @@ <h2>
<div class="autoHeight" id="autoHeight">
<div>
<div>
<img src="images/1000x600/1.png" alt="">
<img src="images/1000x700/1.png" alt="">
</div>
<p>
Sunt dignissimos distinctio, veniam, tenetur aspernatur nulla!
</p>
</div>
<div>
<div>
<img src="images/1000x900/2.png" alt="">
<img src="images/1000x700/2.png" alt="">
</div>
<p>
Corrupti, libero minima nihil expedita officiis? Quo.
</p>
</div>
<div>
<div>
<img src="images/1000x700/3.png" alt="">
<img src="images/1000x800/3.png" alt="">
</div>
<p>
Alias rem, ab impedit recusandae repellat tempore.
</p>
</div>
<div>
<div>
<img src="images/1000x700/4.png" alt="">
<img src="images/1000x600/4.png" alt="">
</div>
<p>
Nisi inventore quo delectus perspiciatis voluptatibus, quae.
Expand Down

0 comments on commit c47b6eb

Please sign in to comment.