TouchSlide 1.1 在展示显示元素不是100%宽度的时候,将元素宽度改为父级宽度的问题
TouchSlide 1.1 在展示显示元素不是100%宽度的时候,将元素宽度改为父级宽度的问题,导致不能显示部分第2个元素。问题是元素被使用了父级宽度导致的,滑动宽度还应加上左右margin的宽度:

需要修改的地方:
//130行
var slideW= conBox.parentNode.clientWidth;// mainCell滑动距离
//修改为以下内容
var winW = conBox.clientWidth;
var elW = conBox.children[0].clientWidth; // 元素宽度
var elWrate = elW / winW; //元素宽度比例
var slideMl= getStyleVal(conBox.children[0], 'marginLeft');
var slideMr= getStyleVal(conBox.children[0], 'marginRight');
var slideW= elW + slideMl+slideMr;// mainCell滑动距离
//159行
for ( var i =0; i<tempSize; i++ ){ conBox.children[i].style.cssText="display:table-cell;vertical-align:top;width:"+slideW+"px" }
//修改为
for ( var i =0; i<tempSize; i++ ){ conBox.children[i].style.cssText="display:table-cell;vertical-align:top;width:"+elW+"px" }
//修改orientationChange方法
var orientationChange = function(){
winW = twCell.clientWidth;
elW = winW * elWrate; // 元素宽度
slideW= elW + slideMl+slideMr;// mainCell滑动距离
conBox.style.width = tempSize*slideW +"px";
for ( var i =0; i<tempSize; i++ ){ conBox.children[i].style.width=elW+"px"; }
var ind = effect == "leftLoop"? index+1:index;
translate( -ind*slideW ,0 );
} 版权属于:Joyber
本文链接:https://blog.qqvbc.com/default/249.html
转载时须注明出处及本声明