Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
* fixing #227, V3/V4 Carousel cannot use `slideTo` to jump to the current active item
* documentation updates regarding #227
* version bump
  • Loading branch information
thednp committed Jul 12, 2018
1 parent c4bdce0 commit f587bb7
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "bootstrap.native",
"version": "2.0.23",
"version": "2.0.24",
"homepage": "http://thednp.github.io/bootstrap.native/",
"authors": [
"dnp_theme"
Expand Down
11 changes: 7 additions & 4 deletions dist/bootstrap-native-v4.js
@@ -1,4 +1,4 @@
// Native Javascript for Bootstrap 4 v2.0.23 | © dnp_theme | MIT-License
// Native Javascript for Bootstrap 4 v2.0.24 | © dnp_theme | MIT-License
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD support:
Expand Down Expand Up @@ -315,7 +315,7 @@
arrowLeft && (arrow[style][left] = arrowLeft + 'px');
};

BSN.version = '2.0.23';
BSN.version = '2.0.24';

/* Native Javascript for Bootstrap 4 | Alert
-------------------------------------------*/
Expand Down Expand Up @@ -592,8 +592,11 @@
var activeItem = this.getActiveIndex(), // the current active
orientation;

// determine slideDirection first
if ( (activeItem < next ) || (activeItem === 0 && next === total -1 ) ) {
// first return if we're on the same item #227
if ( activeItem === next ) {
return;
// or determine slideDirection
} else if ( (activeItem < next ) || (activeItem === 0 && next === total -1 ) ) {
slideDirection = self[direction] = left; // next
} else if ( (activeItem > next) || (activeItem === total - 1 && next === 0 ) ) {
slideDirection = self[direction] = right; // prev
Expand Down
4 changes: 2 additions & 2 deletions dist/bootstrap-native-v4.min.js

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions dist/bootstrap-native.js
@@ -1,4 +1,4 @@
// Native Javascript for Bootstrap 3 v2.0.23 | © dnp_theme | MIT-License
// Native Javascript for Bootstrap 3 v2.0.24 | © dnp_theme | MIT-License
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD support:
Expand Down Expand Up @@ -316,7 +316,7 @@
element.className[indexOf](position) === -1 && (element.className = element.className.replace(tipPositions,position));
};

BSN.version = '2.0.23';
BSN.version = '2.0.24';

/* Native Javascript for Bootstrap 3 | Affix
-------------------------------------------*/
Expand Down Expand Up @@ -746,8 +746,11 @@
var activeItem = this.getActiveIndex(), // the current active
orientation;

// determine slideDirection first
if ( (activeItem < next ) || (activeItem === 0 && next === total -1 ) ) {
// first return if we're on the same item #227
if ( activeItem === next ) {
return;
// or determine slideDirection
} else if ( (activeItem < next ) || (activeItem === 0 && next === total -1 ) ) {
slideDirection = self[direction] = left; // next
} else if ( (activeItem > next) || (activeItem === total - 1 && next === 0 ) ) {
slideDirection = self[direction] = right; // prev
Expand Down
4 changes: 2 additions & 2 deletions dist/bootstrap-native.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion index.html
Expand Up @@ -2816,7 +2816,8 @@ <h3>This is another caption</h3>
</div>
</div>
<div class="btn-group">
<a class="btn btn-default disabled" href="#">Jump</a>
<button class="btn btn-default"
onclick="document.getElementById('carousel-example-generic').Carousel.slideTo(0)">Start</button>
<button class="btn btn-default" data-slide-to="prev"
onclick="document.getElementById('carousel-example-generic').Carousel.slideTo(document.getElementById('carousel-example-generic').Carousel.getActiveIndex() - 1 )">PREV</button>
<button class="btn btn-default" data-slide-to="next"
Expand Down
7 changes: 5 additions & 2 deletions lib/V3/carousel-native.js
Expand Up @@ -120,8 +120,11 @@ var Carousel = function( element, options ) {
var activeItem = this.getActiveIndex(), // the current active
orientation;

// determine slideDirection first
if ( (activeItem < next ) || (activeItem === 0 && next === total -1 ) ) {
// first return if we're on the same item #227
if ( activeItem === next ) {
return;
// or determine slideDirection
} else if ( (activeItem < next ) || (activeItem === 0 && next === total -1 ) ) {
slideDirection = self[direction] = left; // next
} else if ( (activeItem > next) || (activeItem === total - 1 && next === 0 ) ) {
slideDirection = self[direction] = right; // prev
Expand Down
7 changes: 5 additions & 2 deletions lib/V4/carousel-native.js
Expand Up @@ -122,8 +122,11 @@ var Carousel = function( element, options ) {
var activeItem = this.getActiveIndex(), // the current active
orientation;

// determine slideDirection first
if ( (activeItem < next ) || (activeItem === 0 && next === total -1 ) ) {
// first return if we're on the same item #227
if ( activeItem === next ) {
return;
// or determine slideDirection
} else if ( (activeItem < next ) || (activeItem === 0 && next === total -1 ) ) {
slideDirection = self[direction] = left; // next
} else if ( (activeItem > next) || (activeItem === total - 1 && next === 0 ) ) {
slideDirection = self[direction] = right; // prev
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "bootstrap.native",
"version": "2.0.23",
"version": "2.0.24",
"description": "Native Javascript for Bootstrap, the sweetest Javascript library without jQuery.",
"main": "dist/bootstrap-native.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion v4.html
Expand Up @@ -234,7 +234,7 @@ <h2>Carousel</h2>
</a>
</div>
<div class="btn-group mt-4 mb-0">
<button class="btn btn-light" disabled>Jump</button>
<button class="btn btn-light" onclick="document.getElementById('carouselExampleIndicators').Carousel.slideTo(0)">Start</button>
<button class="btn btn-light" onclick="(function(){ var crsl = document.getElementById('carouselExampleIndicators').Carousel, idx = crsl.getActiveIndex(); crsl.slideTo(idx-1) }())">PREV</button>
<button class="btn btn-light" onclick="(function(){ var crsl = document.getElementById('carouselExampleIndicators').Carousel, idx = crsl.getActiveIndex(); crsl.slideTo(idx+1) }())">NEXT</button>
</div>
Expand Down

0 comments on commit f587bb7

Please sign in to comment.