[英]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.