[英]edit parameters of iscroll4 given at the time of initialisation
我正在尝试在Cordova 2.1.0的IOS应用程序开发中使用iscroll4。
<script type="application/javascript" src="iscroll.js"></script>
<script type="text/javascript">
var myScroll;
function loaded() {
setTimeout(function () {
myScroll = new iScroll('wrapper');
}, 100);
}
window.addEventListener('load', loaded, false);
</script>
如果我想编辑参数,如vScroll,vScrollBar,fixedScrollbar等,即动态。 初始化iscroll(myScroll = new iScroll('wrapper');)之后,如何在javascript中进行操作。 提前致谢。
我不会尝试寻找“在任何情况下都可行”的解决方案。
我会:
例如,您可以设置以下选项:
myScroller = new iScroll( el, { x:20, y:30, onRefresh: function(){ alert(11); } } );
考虑到我的步骤,您是否要修改这3个(或更多)?
x,y,scrollbarClass
在初始化中,我们看到使用了x和y(第120行):
//设置起始位置that.x = that.options.x; that.y = that.options.y;
这意味着这些选项不仅影响运行时的内容,而且在初始化期间还会修改that.x和that.y(到目前为止,甚至还很简单)。
3。
myScroller.x = newX;
myScroller.options.x = newX;
myScroller.y = newY;
myScroller.options.y = newY;
// Also depeneds on x & y, but only do this if you actually useTransform and care about this!
/*
* obtain required variables..
*/
var appVersion = navigator.appVersion,
vendor = (/webkit/i).test(appVersion) ? 'webkit' :
(/firefox/i).test(navigator.userAgent) ? 'Moz' :
'opera' in window ? 'O' : '',
has3d = 'WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix(),
trnOpen = 'translate' + (has3d ? '3d(' : '('),
trnClose = has3d ? ',0)' : ')';
// Code that actually matters, and where we use above variables
if (that.options.useTransform) that.scroller.style[vendor + 'Transform'] = trnOpen + that.newX + 'px,' + that.newY + 'px' + trnClose;
else that.scroller.style.cssText += ';position:absolute;top:' + that.newY + 'px;left:' + that.newX + 'px';
4。
myScroller.options.onRefresh = function() { alert(33); }
也许您甚至可以在options.onDestroy属性中完成所有这些操作;)
更新:我也注意到了destroy功能,如果您想“完全清除”滚动条,它可能会很方便。 但是我没有看到能删除实际创建的滚动条的代码,但是我不确定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.