gpt4 book ai didi

javascript - bxslider 移动第一张幻灯片

转载 作者:行者123 更新时间:2023-12-03 08:30:14 30 4
gpt4 key购买 nike

如何使第一个bxslider幻灯片向左移动-26px?我在 slider 中找到了这一行:

propValue = slider.settings.mode === 'vertical' ? 'translate3d(0, ' + value + 'px, 0)' : 'translate3d(' + value + 'px, 0, 0)';

这样我就可以将 'translate3d(' + value + 'px, 0, 0)' 更改为 'translate3d(' + (value - 26) + 'px, 0, 0 )'

它会起作用,但问题是,我正在使用具有不同参数的几张幻灯片,并且我无法修改此脚本。那么如何让它将第一张幻灯片向左移动-26px呢?

最佳答案

我尝试了一下,然后让我知道

初始化时,请执行以下操作

  $('.home .bxslider').bxSlider({
initLeftVal: 20
});


//first, add extra property to defautls
var defaults = {
initLeftVal: 0;
}

//check for this function and replace whole function( dont replace just comment out)
var setSlidePosition = function(){
var initLeftVal = slider.settings.initLeftVal;
// if last slide, not infinite loop, and number of children is larger than specified maxSlides
if(slider.children.length > slider.settings.maxSlides && slider.active.last && !slider.settings.infiniteLoop){
if (slider.settings.mode == 'horizontal'){
// get the last child's position
var lastChild = slider.children.last();
var position = lastChild.position();
// set the left position
setPositionProperty(-(position.left + initLeftVal - (slider.viewport.width() - lastChild.outerWidth())), 'reset', 0);
}else if(slider.settings.mode == 'vertical'){
// get the last showing index's position
var lastShowingIndex = slider.children.length - slider.settings.minSlides;
var position = slider.children.eq(lastShowingIndex).position();
// set the top position
setPositionProperty(-(position.top+initLeftVal), 'reset', 0);
}
// if not last slide
}else{
// get the position of the first showing slide
var position = slider.children.eq(slider.active.index * getMoveBy()).position();
// check for last slide
if (slider.active.index == getPagerQty() - 1) slider.active.last = true;
// set the repective position
if (position != undefined){
if (slider.settings.mode == 'horizontal') setPositionProperty(-(position.left+initLeftVal), 'reset', 0);
else if (slider.settings.mode == 'vertical') setPositionProperty(-(position.top+initLeftVal), 'reset', 0);
}
}
}

关于javascript - bxslider 移动第一张幻灯片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33367841/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com