在使用slimScroll时,不支持resize调整;今天看了一下源码,修改部分源码使支持resize;
function setScroll(){
$(".box-list").slimScroll({
height: boxHeight,
alwaysVisible: true,
});
}
setScroll();
$(window).on("resize",setScroll);
源码调整部分:
if(f.isPlainObject(h)) {
if("height" in h && "auto" == h.height) {
b.parent().css("height", "auto");
b.css("height", "auto");
var q = b.parent().parent().height();
console.log(b[0]);
b.parent().css("height", q);
b.css("height", q)
}else if("height" in h && b.height() != parseInt(h.height)){
b.parent().css("height",h.height);
b.css("height", h.height)
}
if("scrollTo" in h) n = parseInt(a.scrollTo);
else if("scrollBy" in h) n += parseInt(a.scrollBy);
else if("destroy" in h) {
c.remove();
g.remove();
b.unwrap();
return
}
m(n, !1, !0)
}