我在用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= javascript (‘包装器’);),我如何在javascript中完成它。提前谢谢。
发布于 2012-10-16 09:12:39
我不会试图寻找一种“在每一种情况下都有效”的解决方案。
我会:
例如,可以设置以下选项:
myScroller = new iScroll( el, { x:20, y:30, onRefresh: function(){ alert(11); } } );考虑到我的步骤,您想要修改这3(或更多)吗?
这意味着这些选项不仅会影响运行时的内容,在初始化过程中还会修改.even..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属性中完成所有这些事情;)
更新:我也注意到了破坏功能,如果你想“完全清除”滚动体,可能会很方便。但我没有看到会删除物理创建的滚动条的代码,但我不确定。
https://stackoverflow.com/questions/12891187
复制相似问题