I'm trying to add a class "disabled" to the pager if the slider has only 1 slide showing, and nothing to actually slide.
I'm sliding a div, not a list.
It's just a basic div:
<div class="bxslider2">
<div class="wrap">
...
</div>
</div>
Here is the jquery for the slider:
$('.bxslider2').bxSlider({
mode: 'horizontal',
speed: '180',
pagerType:'full',
pager:'true',
captions: false
});
I would like to not show the pager if there is only 1 slide showing.
Thanks for any help!
Justin
I faced the same trouble and here is my solution: we should count how many child elements we have under .bxslider2 block
$(".bxslider2>.wrap").length
and if there is only one, then set option to 'false', otherwise to 'true'.
$('.bxslider2').bxSlider({
mode: 'horizontal',
speed: '180',
pagerType:'full',
pager: ($(".bxslider2>.wrap").length > 1) ? true: false,
captions: false
});
Hope it will helps.
I use css to achieve this.
.bx-pager-item:first-of-type:last-of-type {
display: none
}
Here is a solution if you have more than one bxslider on the page.
$('.bxslider').each(function() {
var options = {
mode: 'fade',
};
if ($(this).find('li').length === 1) {
options.pager = false;
}
$(this).bxSlider(options);
});
Goes through each slider and finds if it has only one li. If so, add pager: false to the object passed to bxSlider.
a nice way to solve this thing is to reload the object like that
and change the controls per number of the items :
var slideQty = $('.bxslider').bxSlider({
minSlides: 1,
maxSlides: 3,
slideWidth: 110,
slideMargin: 0,
adaptiveHeight: true,
pager: false,
moveSlides: 1,
onSlideAfter: function ($slideElement, oldIndex, newIndex) { NextSlide(oldIndex, newIndex); }
});
var count = slideQty.getSlideCount();
if (count < 7) {
slideQty.reloadSlider({
controls : false,
minSlides: 1,
maxSlides: 3,
slideWidth: 110,
slideMargin: 0,
adaptiveHeight: true,
pager: false,
moveSlides: 1,
onSlideAfter: function ($slideElement, oldIndex, newIndex) { NextSlide(oldIndex, newIndex); }
});
}
return false;
Try this it works for me!!
var slider = $('#slider').bxSlider();
$('.bx-next, .bx-prev, .bx-pager a').click(function(){
// time to wait (in ms)
var wait = 1000;
setTimeout(function(){
slider.startAuto();
}, wait);
});
Related
I want to create a ticker newspaper mode slider with swiper js. I have used the following codes, they are not working perfectly.
var mySwiper = new Swiper('.swiper-container', {
speed: 1000,
loop: true,
autoplay: true,
cssEase:'linear',
});
please suggest what can I do?
i think this will help you in your case
let SwiperTicker = new Swiper('.swiper--top', {
spaceBetween: 0,
centeredSlides: true,
speed: 6000,
autoplay: {
delay: 1,
},
loop: true,
slidesPerView:'auto',
allowTouchMove: false,
disableOnInteraction: true
});
Swiper doesn't have parameter cssEase.
I can work fine to add css.
.swiper-wrapper{transition-timing-function:linear; }
https://github.com/nolimits4web/Swiper/issues/496
So basically, i'm trying to get the position of the slide and then update the html by adding a class to that slide. But I can't figure out how to get the current position everytime I swipe, how to update the swipe_active data.
This is the vue js file.
mounted(){
let element = document.getElementById('mySwipe');
if (window.innerWidth< 550){
window.mySwipe = Swipe (element, {
startSlide: 1,
auto: 0,
autoRestart: true,
continuous: true,
disableScroll: true,
stopPropagation: true,
callback: function(index, element) {},
transitionEnd: function(index, element) {}
});
}
this.swipe_active = window.mySwipe.getPos();
}
This is the html
<div :class="{black_swipe : swipe_active === 0 }"></div>
<div :class="{black_swipe : swipe_active === 1 }"></div>
mounted hook is called only once i.e when the component is finished mounting the DOM.
There is a callback property your have available in the config option you pass while creating a new Swipe instance. This property takes a function that will be called after every slide change
you can use this to update the swipe_active data.
mounted(){
let element = document.getElementById('mySwipe');
if (window.innerWidth< 550){
window.mySwipe = new Swipe (element, {
startSlide: 1,
auto: 0,
autoRestart: true,
continuous: true,
disableScroll: true,
stopPropagation: true,
callback: this.swipeCallback,
transitionEnd: function(index, element) {}
});
}
this.swipe_active = window.mySwipe.getPos();
},
methods: {
swipeCallback(index, element){
this.swipe_active = window.mySwipe.getPos();
}
}
I have a Slick slider with some images and some html5 videos.
I have managed to make the Prev/Next arrows work: if I click on the arrows the slider goes to the next video (it plays automatically) and the previous one is paused.
Now I've added a button to pause/play the current video, but I can't find a way to make it work properly. The button works only the first time a video is played. If I change slide and go back to the same video I am not able to pause it anymore.
$('.sliderVideo').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: true,
fade: true,
dots: true,
autoplay: true,
autoplaySpeed: 1000,
adaptiveHeight: true,
pauseOnHover:false,
cssEase: 'linear'});
$('.sliderVideo').on('beforeChange', function(event, slick, currentSlide, nextSlide){
$("video").each(function(){
$(this).get(0).pause();
});
});
$('.sliderVideo').on('afterChange', function(event, slick, currentSlide) {
var vid = $(slick.$slides[currentSlide]).find('video');
if (vid.length > 0) {
$('.sliderVideo').slick('slickPause');
$(vid).get(0).play();
var MyPlayButton = $(slick.$slides[currentSlide]).find('.play-button');
//var MyPlayButton = $('.play-button');
MyPlayButton.on('click', function () {
if ($(vid).get(0).paused) {
$(vid).get(0).play();
console.log('play');
} else {
$(vid).get(0).pause();
console.log('paused');
}
return false;
});
}
});
$('video').on('ended',function(){
$('.sliderVideo').slick('slickPlay');});
I would really appreciate your help.
I've created a fiddle https://jsfiddle.net/8ds3Lrxm/22/
OK, fixed this way:
var MyPlayButton = null;
$('.sliderVideo').on('beforeChange', function(event, slick, currentSlide, nextSlide){
if (null !== MyPlayButton) {
MyPlayButton.off('click');
}
$("video").each(function(){
$(this).get(0).pause();
});
});
A very simple way (keeping it simple is best)
this way we reset the video whenever we start playing it...
$('#slider_id').on('beforeChange', function(event, slick, currentSlide, nextSlide){
// pause old video (better performance)
var old_vid = $('#slider_id .slide:eq('+currentSlide+')').find('video');
$(old_vid).get(0).pause();
// play current video from start
var cur_vid = $('#slider_id .slide:eq('+nextSlide+')').find('video');
$(cur_vid).get(0).currentTime = 0;
$(cur_vid).get(0).play();
});
$('.video_banner_slider').on('beforeChange', function(event, slick, currentSlide, nextSlide){
console.log(currentSlide);
$("video").each(function(){
$(this).get(0).pause();
});
});
I've integrated swiper slide with coverflow effect, now I don't want the effect for first and last slide. can we remove the effect for only first and lst slide.???
You can check your position and disable "swipe to prev" when you are in the first tab, and "swipe to next" when you are in the last one. Like this,
var swiper = new Swiper('.swiper-container', {
effect:'coverflow',
pagination: '#progressbar',
paginationType: 'progress',
nextButton: '#next-button',
prevButton: '#prev-button',
spaceBetween: 30,
onInit: function (swiper) {
if (swiper.activeIndex == 0) swiper.lockSwipeToPrev();
if (swiper.isEnd) swiper.lockSwipeToNext();
},
onSlideChangeStart: function (swiper) {
if (swiper.activeIndex == 0) swiper.lockSwipeToPrev();
else swiper.unlockSwipeToPrev();
if (swiper.isEnd) swiper.lockSwipeToNext();
else swiper.unlockSwipeToNext();
},
});
I guess you mean the slideShadows property. If so, you can easily show/hide it, as following:
var mySwiper = new Swiper('.swiper-container', {
coverflowEffect: {
rotate: 30,
slideShadows: false,
},
});
I was fix hyperlink states via CSS like below sample and it's working fine.
.swiper-slide a {
pointer-events: none !important;
}
.swiper-slide.swiper-slide-next a {
pointer-events: unset !important;
}
Ok, so I would like to have a slider that looks like this one.
Just can't figure out where we can at least have these delimiter separators? So if you see there are 7 delimiters and we have large labels on the first 4-th and the last delimeter.
How would you approach this task?
This is a rather old question but I was faced with the very same need today. Building on GenieWanted's answer, I came to this:
...
{
xtype: 'sliderfield',
maxValue: 5,
label: 'Some data',
html: '<table width="100%" align="left"><tr><td width="25%">Min</td><td width="50%" align="center">Med</td><td width="25%" align="right">Max</td></tr></table>'
}
...
which works very well for me, and avoids messing around to find the correct number of needed. Also, I suspect that results would vary from device to device using .
There is no way of adding a label inside sliderfield. However, you can indeed add HTML to acheive the required output. On the config panel, go to HTML property, and add something like this:
<div style="padding-left:1em">| | |<div>Low Average High </div></div>
The output I have got:
You just need to playaround with the alignment of your text in the HTML. That will do!
Good Luck!
You can create Custom Slider like this
Ext.ns('Ext.ux');
Ext.ux.CustomSlider = Ext.extend(Object, {
valueTextClass: 'x-slider-value-text',
showSliderBothEndValue: true,
sliderEndValueStyle: 'color: black',
constructor: function(config){
Ext.apply(this, config);
Ext.ux.CustomSlider.superclass.constructor.apply(this, arguments);
},
init: function(parent) {
var me = this;
parent.on({
painted: {
fn: function(component) {
if (me.showSliderBothEndValue) me.showSliderEndValue(this);
if (!this.valueTextEl) {
this.valueTextEl = component.element.createChild({
cls: me.valueTextClass
});
}
}
}
});
},
showSliderEndValue: function(slider) {
var sliderPosX = slider.getComponent().getThumb().element.getX();
var thumbHeight = slider.getComponent().getThumb().element.getHeight();
var sliderLength = slider.getComponent().element.getWidth();
var minValueEl = slider.getComponent().element.createChild();
minValueEl.setHtml(slider.getComponent().getMinValue());
minValueEl.applyStyles('overflow:hidden;position:absolute');
minValueEl.applyStyles(this.sliderEndValueStyle);
minValueEl.setLeft(14);
minValueEl.setTop(thumbHeight -7);
var maxValueEl = slider.getComponent().element.createChild();
maxValueEl.setHtml(slider.getComponent().getMaxValue());
maxValueEl.applyStyles('overflow:hidden;position:absolute');
maxValueEl.applyStyles(this.sliderEndValueStyle);
maxValueEl.setLeft(sliderLength-45);
maxValueEl.setTop(thumbHeight - 7);
}
});
And create slider like this
var slider = {
xtype: 'sliderfield',
flex : 6,
label: "Percentage",
name: "Percentage",
value : 50,
minValue : 0,
maxValue : 100,
labelWrap : true,
labelAlign : 'left',
increment : 10,
plugins: [new Ext.ux.CustomSlider({
showSliderBothEndValue: true
})],
listeners: {
painted: function (slider) {
var sliderPanelItems = this.parent.getInnerItems();
sliderPanelItems[1].setValue(this.getValue());
},
change: function (me,slider, thumb, newVal, oldVal, opts) {
var sliderPanelItems = this.parent.getInnerItems();
sliderPanelItems[1].setValue(newVal);
}
}
};
Result will be like this
I did this using this link