Unidirectional Bootstrap 3 carousel
up vote
0
down vote
favorite
I am working on a custom Bootstrap 3 carousel, with vertical, unidirectional, slide transitions.
I want to prevent slide transitions from overlapping when the bullets are clicked in random order and rapid succession.
I came up with this solution that relies on disabling them as long as a slide transition is in progress, then enabling them between transitions:
var carouselDuration = function() {
$.fn.carousel.Constructor.TRANSITION_DURATION = 1000;
}
carouselDuration();
// While a transition is in progress (slide event), do this
$('#myCarousel').on('slide.bs.carousel', function (e) {
var $indicator = $(this).find('.carousel-indicators>li');
$indicator.css('pointer-events', 'none');
});
// While a transition has finished (slid event), do this
$('#myCarousel').on('slid.bs.carousel', function (e) {
var $indicator = $(this).find('.carousel-indicators>li');
$indicator.css('pointer-events', 'auto');
});
.carousel.vertical {
position: relative;
}
.carousel.vertical .carousel-inner {
height: 100%;
width: auto;
}
.carousel.vertical .carousel-inner>.item {
width: auto;
transition: 1s ease-in-out;
transform: translate3d(0, 100%, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.next,
.carousel.vertical .carousel-inner>.prev,
.carousel.vertical .carousel-inner>.right {
transform: translate3d(0, 100%, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.left,
.carousel.vertical .carousel-inner>.prev.right,
.carousel.vertical .carousel-inner>.next.left,
.carousel.vertical .carousel-inner>.active {
transform: translate3d(0, 0, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.active.right,
.carousel.vertical .carousel-inner>.active.left {
transform: translate3d(0, -100%, 0);
top: 0;
}
.carousel.vertical .carousel-indicators {
display: inline-block;
width: auto;
padding: 0;
margin: 0;
left: auto;
right: 10px;
bottom: 2px;
z-index: 9;
font-size: 0;
}
.carousel.vertical .carousel-indicators li {
border: none;
cursor: pointer;
display: inline-block;
width: 18px;
height: 18px;
text-indent: -9999px;
background: url("https://grgs.ro/1/i/sprite.png") no-repeat -528px -502px;
}
.carousel.vertical .carousel-indicators li.active {
background-position: -528px -524px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div id="myCarousel" class="carousel vertical slide" data-ride="carousel" data-interval="9000">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="https://picsum.photos/1200/300/?gravity=east" alt="">
</div>
<div class="item">
<img src="https://picsum.photos/1200/300/?gravity=south" alt="">
</div>
<div class="item">
<img src="https://picsum.photos/1200/300/?gravity=west" alt="">
</div>
</div>
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
</div>
</div>
Still, I am looking for a queuing mechanism, as it is more natural and elegant.
javascript jquery css animation twitter-bootstrap
add a comment |
up vote
0
down vote
favorite
I am working on a custom Bootstrap 3 carousel, with vertical, unidirectional, slide transitions.
I want to prevent slide transitions from overlapping when the bullets are clicked in random order and rapid succession.
I came up with this solution that relies on disabling them as long as a slide transition is in progress, then enabling them between transitions:
var carouselDuration = function() {
$.fn.carousel.Constructor.TRANSITION_DURATION = 1000;
}
carouselDuration();
// While a transition is in progress (slide event), do this
$('#myCarousel').on('slide.bs.carousel', function (e) {
var $indicator = $(this).find('.carousel-indicators>li');
$indicator.css('pointer-events', 'none');
});
// While a transition has finished (slid event), do this
$('#myCarousel').on('slid.bs.carousel', function (e) {
var $indicator = $(this).find('.carousel-indicators>li');
$indicator.css('pointer-events', 'auto');
});
.carousel.vertical {
position: relative;
}
.carousel.vertical .carousel-inner {
height: 100%;
width: auto;
}
.carousel.vertical .carousel-inner>.item {
width: auto;
transition: 1s ease-in-out;
transform: translate3d(0, 100%, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.next,
.carousel.vertical .carousel-inner>.prev,
.carousel.vertical .carousel-inner>.right {
transform: translate3d(0, 100%, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.left,
.carousel.vertical .carousel-inner>.prev.right,
.carousel.vertical .carousel-inner>.next.left,
.carousel.vertical .carousel-inner>.active {
transform: translate3d(0, 0, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.active.right,
.carousel.vertical .carousel-inner>.active.left {
transform: translate3d(0, -100%, 0);
top: 0;
}
.carousel.vertical .carousel-indicators {
display: inline-block;
width: auto;
padding: 0;
margin: 0;
left: auto;
right: 10px;
bottom: 2px;
z-index: 9;
font-size: 0;
}
.carousel.vertical .carousel-indicators li {
border: none;
cursor: pointer;
display: inline-block;
width: 18px;
height: 18px;
text-indent: -9999px;
background: url("https://grgs.ro/1/i/sprite.png") no-repeat -528px -502px;
}
.carousel.vertical .carousel-indicators li.active {
background-position: -528px -524px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div id="myCarousel" class="carousel vertical slide" data-ride="carousel" data-interval="9000">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="https://picsum.photos/1200/300/?gravity=east" alt="">
</div>
<div class="item">
<img src="https://picsum.photos/1200/300/?gravity=south" alt="">
</div>
<div class="item">
<img src="https://picsum.photos/1200/300/?gravity=west" alt="">
</div>
</div>
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
</div>
</div>
Still, I am looking for a queuing mechanism, as it is more natural and elegant.
javascript jquery css animation twitter-bootstrap
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working on a custom Bootstrap 3 carousel, with vertical, unidirectional, slide transitions.
I want to prevent slide transitions from overlapping when the bullets are clicked in random order and rapid succession.
I came up with this solution that relies on disabling them as long as a slide transition is in progress, then enabling them between transitions:
var carouselDuration = function() {
$.fn.carousel.Constructor.TRANSITION_DURATION = 1000;
}
carouselDuration();
// While a transition is in progress (slide event), do this
$('#myCarousel').on('slide.bs.carousel', function (e) {
var $indicator = $(this).find('.carousel-indicators>li');
$indicator.css('pointer-events', 'none');
});
// While a transition has finished (slid event), do this
$('#myCarousel').on('slid.bs.carousel', function (e) {
var $indicator = $(this).find('.carousel-indicators>li');
$indicator.css('pointer-events', 'auto');
});
.carousel.vertical {
position: relative;
}
.carousel.vertical .carousel-inner {
height: 100%;
width: auto;
}
.carousel.vertical .carousel-inner>.item {
width: auto;
transition: 1s ease-in-out;
transform: translate3d(0, 100%, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.next,
.carousel.vertical .carousel-inner>.prev,
.carousel.vertical .carousel-inner>.right {
transform: translate3d(0, 100%, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.left,
.carousel.vertical .carousel-inner>.prev.right,
.carousel.vertical .carousel-inner>.next.left,
.carousel.vertical .carousel-inner>.active {
transform: translate3d(0, 0, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.active.right,
.carousel.vertical .carousel-inner>.active.left {
transform: translate3d(0, -100%, 0);
top: 0;
}
.carousel.vertical .carousel-indicators {
display: inline-block;
width: auto;
padding: 0;
margin: 0;
left: auto;
right: 10px;
bottom: 2px;
z-index: 9;
font-size: 0;
}
.carousel.vertical .carousel-indicators li {
border: none;
cursor: pointer;
display: inline-block;
width: 18px;
height: 18px;
text-indent: -9999px;
background: url("https://grgs.ro/1/i/sprite.png") no-repeat -528px -502px;
}
.carousel.vertical .carousel-indicators li.active {
background-position: -528px -524px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div id="myCarousel" class="carousel vertical slide" data-ride="carousel" data-interval="9000">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="https://picsum.photos/1200/300/?gravity=east" alt="">
</div>
<div class="item">
<img src="https://picsum.photos/1200/300/?gravity=south" alt="">
</div>
<div class="item">
<img src="https://picsum.photos/1200/300/?gravity=west" alt="">
</div>
</div>
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
</div>
</div>
Still, I am looking for a queuing mechanism, as it is more natural and elegant.
javascript jquery css animation twitter-bootstrap
I am working on a custom Bootstrap 3 carousel, with vertical, unidirectional, slide transitions.
I want to prevent slide transitions from overlapping when the bullets are clicked in random order and rapid succession.
I came up with this solution that relies on disabling them as long as a slide transition is in progress, then enabling them between transitions:
var carouselDuration = function() {
$.fn.carousel.Constructor.TRANSITION_DURATION = 1000;
}
carouselDuration();
// While a transition is in progress (slide event), do this
$('#myCarousel').on('slide.bs.carousel', function (e) {
var $indicator = $(this).find('.carousel-indicators>li');
$indicator.css('pointer-events', 'none');
});
// While a transition has finished (slid event), do this
$('#myCarousel').on('slid.bs.carousel', function (e) {
var $indicator = $(this).find('.carousel-indicators>li');
$indicator.css('pointer-events', 'auto');
});
.carousel.vertical {
position: relative;
}
.carousel.vertical .carousel-inner {
height: 100%;
width: auto;
}
.carousel.vertical .carousel-inner>.item {
width: auto;
transition: 1s ease-in-out;
transform: translate3d(0, 100%, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.next,
.carousel.vertical .carousel-inner>.prev,
.carousel.vertical .carousel-inner>.right {
transform: translate3d(0, 100%, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.left,
.carousel.vertical .carousel-inner>.prev.right,
.carousel.vertical .carousel-inner>.next.left,
.carousel.vertical .carousel-inner>.active {
transform: translate3d(0, 0, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.active.right,
.carousel.vertical .carousel-inner>.active.left {
transform: translate3d(0, -100%, 0);
top: 0;
}
.carousel.vertical .carousel-indicators {
display: inline-block;
width: auto;
padding: 0;
margin: 0;
left: auto;
right: 10px;
bottom: 2px;
z-index: 9;
font-size: 0;
}
.carousel.vertical .carousel-indicators li {
border: none;
cursor: pointer;
display: inline-block;
width: 18px;
height: 18px;
text-indent: -9999px;
background: url("https://grgs.ro/1/i/sprite.png") no-repeat -528px -502px;
}
.carousel.vertical .carousel-indicators li.active {
background-position: -528px -524px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div id="myCarousel" class="carousel vertical slide" data-ride="carousel" data-interval="9000">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="https://picsum.photos/1200/300/?gravity=east" alt="">
</div>
<div class="item">
<img src="https://picsum.photos/1200/300/?gravity=south" alt="">
</div>
<div class="item">
<img src="https://picsum.photos/1200/300/?gravity=west" alt="">
</div>
</div>
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
</div>
</div>
Still, I am looking for a queuing mechanism, as it is more natural and elegant.
var carouselDuration = function() {
$.fn.carousel.Constructor.TRANSITION_DURATION = 1000;
}
carouselDuration();
// While a transition is in progress (slide event), do this
$('#myCarousel').on('slide.bs.carousel', function (e) {
var $indicator = $(this).find('.carousel-indicators>li');
$indicator.css('pointer-events', 'none');
});
// While a transition has finished (slid event), do this
$('#myCarousel').on('slid.bs.carousel', function (e) {
var $indicator = $(this).find('.carousel-indicators>li');
$indicator.css('pointer-events', 'auto');
});
.carousel.vertical {
position: relative;
}
.carousel.vertical .carousel-inner {
height: 100%;
width: auto;
}
.carousel.vertical .carousel-inner>.item {
width: auto;
transition: 1s ease-in-out;
transform: translate3d(0, 100%, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.next,
.carousel.vertical .carousel-inner>.prev,
.carousel.vertical .carousel-inner>.right {
transform: translate3d(0, 100%, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.left,
.carousel.vertical .carousel-inner>.prev.right,
.carousel.vertical .carousel-inner>.next.left,
.carousel.vertical .carousel-inner>.active {
transform: translate3d(0, 0, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.active.right,
.carousel.vertical .carousel-inner>.active.left {
transform: translate3d(0, -100%, 0);
top: 0;
}
.carousel.vertical .carousel-indicators {
display: inline-block;
width: auto;
padding: 0;
margin: 0;
left: auto;
right: 10px;
bottom: 2px;
z-index: 9;
font-size: 0;
}
.carousel.vertical .carousel-indicators li {
border: none;
cursor: pointer;
display: inline-block;
width: 18px;
height: 18px;
text-indent: -9999px;
background: url("https://grgs.ro/1/i/sprite.png") no-repeat -528px -502px;
}
.carousel.vertical .carousel-indicators li.active {
background-position: -528px -524px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div id="myCarousel" class="carousel vertical slide" data-ride="carousel" data-interval="9000">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="https://picsum.photos/1200/300/?gravity=east" alt="">
</div>
<div class="item">
<img src="https://picsum.photos/1200/300/?gravity=south" alt="">
</div>
<div class="item">
<img src="https://picsum.photos/1200/300/?gravity=west" alt="">
</div>
</div>
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
</div>
</div>
var carouselDuration = function() {
$.fn.carousel.Constructor.TRANSITION_DURATION = 1000;
}
carouselDuration();
// While a transition is in progress (slide event), do this
$('#myCarousel').on('slide.bs.carousel', function (e) {
var $indicator = $(this).find('.carousel-indicators>li');
$indicator.css('pointer-events', 'none');
});
// While a transition has finished (slid event), do this
$('#myCarousel').on('slid.bs.carousel', function (e) {
var $indicator = $(this).find('.carousel-indicators>li');
$indicator.css('pointer-events', 'auto');
});
.carousel.vertical {
position: relative;
}
.carousel.vertical .carousel-inner {
height: 100%;
width: auto;
}
.carousel.vertical .carousel-inner>.item {
width: auto;
transition: 1s ease-in-out;
transform: translate3d(0, 100%, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.next,
.carousel.vertical .carousel-inner>.prev,
.carousel.vertical .carousel-inner>.right {
transform: translate3d(0, 100%, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.left,
.carousel.vertical .carousel-inner>.prev.right,
.carousel.vertical .carousel-inner>.next.left,
.carousel.vertical .carousel-inner>.active {
transform: translate3d(0, 0, 0);
top: 0;
}
.carousel.vertical .carousel-inner>.active.right,
.carousel.vertical .carousel-inner>.active.left {
transform: translate3d(0, -100%, 0);
top: 0;
}
.carousel.vertical .carousel-indicators {
display: inline-block;
width: auto;
padding: 0;
margin: 0;
left: auto;
right: 10px;
bottom: 2px;
z-index: 9;
font-size: 0;
}
.carousel.vertical .carousel-indicators li {
border: none;
cursor: pointer;
display: inline-block;
width: 18px;
height: 18px;
text-indent: -9999px;
background: url("https://grgs.ro/1/i/sprite.png") no-repeat -528px -502px;
}
.carousel.vertical .carousel-indicators li.active {
background-position: -528px -524px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div id="myCarousel" class="carousel vertical slide" data-ride="carousel" data-interval="9000">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="https://picsum.photos/1200/300/?gravity=east" alt="">
</div>
<div class="item">
<img src="https://picsum.photos/1200/300/?gravity=south" alt="">
</div>
<div class="item">
<img src="https://picsum.photos/1200/300/?gravity=west" alt="">
</div>
</div>
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
</div>
</div>
javascript jquery css animation twitter-bootstrap
javascript jquery css animation twitter-bootstrap
edited Nov 13 at 16:59
200_success
127k15148410
127k15148410
asked Nov 13 at 13:19
Razvan Zamfir
738
738
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f207554%2funidirectional-bootstrap-3-carousel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown