Skip to content

Commit

Permalink
Fixed some bug with Carousel and transitionEnd.
Browse files Browse the repository at this point in the history
  • Loading branch information
thednp committed Feb 14, 2017
1 parent 8828c11 commit b0548c7
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 69 deletions.
2 changes: 1 addition & 1 deletion assets/css/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ p .btn-group {margin-bottom: 20px}
-webkit-transform: translate3d( 0%, 0, 0);
transform: translate3d(0%, 0, 0);
opacity:1;
visibility: visible;
/*visibility: visible; */
}

/* Declare heights because of positioning of img element */
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap.native",
"version": "2.0.4",
"version": "2.0.5",
"homepage": "http://thednp.github.io/bootstrap.native/",
"authors": [
"dnp_theme"
Expand Down
36 changes: 20 additions & 16 deletions dist/bootstrap-native-v4.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Native Javascript for Bootstrap 4 v2.0.4 | © dnp_theme | MIT-License
// Native Javascript for Bootstrap 4 v2.0.5 | © dnp_theme | MIT-License
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD support:
Expand Down Expand Up @@ -181,8 +181,8 @@
element.removeEventListener(event, handler, false);
},
one = function (element, event, handler) { // one since 2.0.4
on(element, event, function handlerWrapper(){
handler();
on(element, event, function handlerWrapper(e){
handler(e);
off(element, event, handlerWrapper);
});
},
Expand Down Expand Up @@ -577,21 +577,25 @@
addClass(slides[next],carouselItem +'-'+ slideDirection);
addClass(slides[activeItem],carouselItem +'-'+ slideDirection);

one(slides[next], transitionEndEvent, function(){
isSliding = self.isSliding = false;
one(slides[activeItem], transitionEndEvent, function(e) {
var timeout = e[target] !== slides[activeItem] ? e.elapsedTime*1000 : 0;
setTimeout(function(){
isSliding = self.isSliding = false;

addClass(slides[next],active);
removeClass(slides[activeItem],active);
addClass(slides[next],active);
removeClass(slides[activeItem],active);

removeClass(slides[next],carouselItem +'-'+ orientation);
removeClass(slides[next],carouselItem +'-'+ slideDirection);
removeClass(slides[activeItem],carouselItem +'-'+ slideDirection);
removeClass(slides[next],carouselItem +'-'+ orientation);
removeClass(slides[next],carouselItem +'-'+ slideDirection);
removeClass(slides[activeItem],carouselItem +'-'+ slideDirection);

if ( self[interval] && !hasClass(element,paused) ) {
self.cycle();
}
bootstrapCustomEvent.call(element, slidEvent, component, slides[next]); // here we go with the slid event
});
bootstrapCustomEvent.call(element, slidEvent, component, slides[next]);

if ( !document.hidden && self[interval] && !hasClass(element,paused) ) {
self.cycle();
}
},timeout);
});

} else {
addClass(slides[next],active);
Expand All @@ -602,7 +606,7 @@
if ( self[interval] && !hasClass(element,paused) ) {
self.cycle();
}
bootstrapCustomEvent.call(element, slidEvent, component, slides[next]); // here we go with the slid event
bootstrapCustomEvent.call(element, slidEvent, component, slides[next]);
}, 100 );
}
};
Expand Down
4 changes: 2 additions & 2 deletions dist/bootstrap-native-v4.min.js

Large diffs are not rendered by default.

37 changes: 21 additions & 16 deletions dist/bootstrap-native.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Native Javascript for Bootstrap 3 v2.0.4 | © dnp_theme | MIT-License
// Native Javascript for Bootstrap 3 v2.0.5 | © dnp_theme | MIT-License
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD support:
Expand Down Expand Up @@ -193,8 +193,8 @@
element.removeEventListener(event, handler, false);
},
one = function (element, event, handler) { // one since 2.0.4
on(element, event, function handlerWrapper(){
handler();
on(element, event, function handlerWrapper(e){
handler(e);
off(element, event, handlerWrapper);
});
},
Expand Down Expand Up @@ -737,27 +737,32 @@
setActivePage( next );

if ( supportTransitions && hasClass(element,'slide') ) {

addClass(slides[next],orientation);
slides[next][offsetWidth];
slides[next][offsetWidth];
addClass(slides[next],slideDirection);
addClass(slides[activeItem],slideDirection);

one(slides[next], transitionEndEvent, function() { //we're gonna fake waiting for the animation to finish, cleaner and better
isSliding = self.isSliding = false;
one(slides[activeItem], transitionEndEvent, function(e) {
var timeout = e[target] !== slides[activeItem] ? e.elapsedTime*1000 : 0;
setTimeout(function(){
isSliding = self.isSliding = false;

addClass(slides[next],active);
removeClass(slides[activeItem],active);
addClass(slides[next],active);
removeClass(slides[activeItem],active);

removeClass(slides[next],orientation);
removeClass(slides[next],slideDirection);
removeClass(slides[activeItem],slideDirection);
removeClass(slides[next],orientation);
removeClass(slides[next],slideDirection);
removeClass(slides[activeItem],slideDirection);

if ( self[interval] && !hasClass(element,paused) ) {
self.cycle();
}
bootstrapCustomEvent.call(element, slidEvent, component, slides[next]); // here we go with the slid event
bootstrapCustomEvent.call(element, slidEvent, component, slides[next]);

if ( self[interval] && !hasClass(element,paused) ) {
self.cycle();
}
},timeout);
});

} else {
addClass(slides[next],active);
slides[next][offsetWidth];
Expand Down
4 changes: 2 additions & 2 deletions dist/bootstrap-native.min.js

Large diffs are not rendered by default.

31 changes: 18 additions & 13 deletions lib/V3/carousel-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,27 +152,32 @@ var Carousel = function( element, options ) {
setActivePage( next );

if ( supportTransitions && hasClass(element,'slide') ) {

addClass(slides[next],orientation);
slides[next][offsetWidth];
slides[next][offsetWidth];
addClass(slides[next],slideDirection);
addClass(slides[activeItem],slideDirection);

one(slides[next], transitionEndEvent, function() { //we're gonna fake waiting for the animation to finish, cleaner and better
isSliding = self.isSliding = false;
one(slides[activeItem], transitionEndEvent, function(e) {
var timeout = e[target] !== slides[activeItem] ? e.elapsedTime*1000 : 0;
setTimeout(function(){
isSliding = self.isSliding = false;

addClass(slides[next],active);
removeClass(slides[activeItem],active);
addClass(slides[next],active);
removeClass(slides[activeItem],active);

removeClass(slides[next],orientation);
removeClass(slides[next],slideDirection);
removeClass(slides[activeItem],slideDirection);
removeClass(slides[next],orientation);
removeClass(slides[next],slideDirection);
removeClass(slides[activeItem],slideDirection);

if ( self[interval] && !hasClass(element,paused) ) {
self.cycle();
}
bootstrapCustomEvent.call(element, slidEvent, component, slides[next]); // here we go with the slid event
bootstrapCustomEvent.call(element, slidEvent, component, slides[next]);

if ( self[interval] && !hasClass(element,paused) ) {
self.cycle();
}
},timeout);
});

} else {
addClass(slides[next],active);
slides[next][offsetWidth];
Expand Down
4 changes: 2 additions & 2 deletions lib/V3/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ var globalObject = typeof global !== 'undefined' ? global : this||window,
element.removeEventListener(event, handler, false);
},
one = function (element, event, handler) { // one since 2.0.4
on(element, event, function handlerWrapper(){
handler();
on(element, event, function handlerWrapper(e){
handler(e);
off(element, event, handlerWrapper);
});
},
Expand Down
30 changes: 17 additions & 13 deletions lib/V4/carousel-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,21 +158,25 @@ var Carousel = function( element, options ) {
addClass(slides[next],carouselItem +'-'+ slideDirection);
addClass(slides[activeItem],carouselItem +'-'+ slideDirection);

one(slides[next], transitionEndEvent, function(){
isSliding = self.isSliding = false;
one(slides[activeItem], transitionEndEvent, function(e) {
var timeout = e[target] !== slides[activeItem] ? e.elapsedTime*1000 : 0;
setTimeout(function(){
isSliding = self.isSliding = false;

addClass(slides[next],active);
removeClass(slides[activeItem],active);
addClass(slides[next],active);
removeClass(slides[activeItem],active);

removeClass(slides[next],carouselItem +'-'+ orientation);
removeClass(slides[next],carouselItem +'-'+ slideDirection);
removeClass(slides[activeItem],carouselItem +'-'+ slideDirection);
removeClass(slides[next],carouselItem +'-'+ orientation);
removeClass(slides[next],carouselItem +'-'+ slideDirection);
removeClass(slides[activeItem],carouselItem +'-'+ slideDirection);

if ( self[interval] && !hasClass(element,paused) ) {
self.cycle();
}
bootstrapCustomEvent.call(element, slidEvent, component, slides[next]); // here we go with the slid event
});
bootstrapCustomEvent.call(element, slidEvent, component, slides[next]);

if ( !document.hidden && self[interval] && !hasClass(element,paused) ) {
self.cycle();
}
},timeout);
});

} else {
addClass(slides[next],active);
Expand All @@ -183,7 +187,7 @@ var Carousel = function( element, options ) {
if ( self[interval] && !hasClass(element,paused) ) {
self.cycle();
}
bootstrapCustomEvent.call(element, slidEvent, component, slides[next]); // here we go with the slid event
bootstrapCustomEvent.call(element, slidEvent, component, slides[next]);
}, 100 );
}
};
Expand Down
4 changes: 2 additions & 2 deletions lib/V4/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ var globalObject = typeof global !== 'undefined' ? global : this||window,
element.removeEventListener(event, handler, false);
},
one = function (element, event, handler) { // one since 2.0.4
on(element, event, function handlerWrapper(){
handler();
on(element, event, function handlerWrapper(e){
handler(e);
off(element, event, handlerWrapper);
});
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap.native",
"version": "2.0.4",
"version": "2.0.5",
"description": "Native Javascript for Bootstrap, the sweetest Javascript library without jQuery.",
"main": "dist/bootstrap-native.js",
"scripts": {
Expand Down

0 comments on commit b0548c7

Please sign in to comment.