bxslider 移动第一张幻灯片
bxslider move first slide
如何让第一个bxslider滑动向左移动-26px?我在滑块中找到了这一行:
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);
}
}
}
如何让第一个bxslider滑动向左移动-26px?我在滑块中找到了这一行:
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);
}
}
}