开发者

iScroll jquery mobile plugin. Better to initiate this 50 times or turn touchmove even listener back on again?

This is just a general question really. To use iScroll with my mobile app, for every scrollable area, you have to initiate a new scroller:

http://cubiq.org/iscroll-4

"iScroll needs to be initialized for each scrolling area you need. 
There’s no limit to the number of iScrolls you can have on any single page, 
if not that imposed by the device memory/cpu. The type and length of the contents 
influence the number of iScrolls you can use simultaneously."

But I have 50 odd pages that need scrolling functionality. To use iScroller, I need to disable to touchmove event with:

       document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

I can reduce the amount of scrollers to just 4 if I can (somehow!) workout how to enable the touchmove event on开发者_如何学Go certain pages.

What I want to know is, would I be better enabling and disabling the touchmove event or would it be better to just initiate 50 scrollers??

Thanks in advanced.


You can use the pagecreate event to decide on which pages you'd like to enable/disable touchmove. To do it, add this per page:

$('#myPageName').live('pagecreate',function(event){
  console.log("about to create myPageName");
});

Alternatively, you could capture all pages show/hide functionality and work out some logic for those pages there.

Read the jQM events documentation for more.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜