我使用jquery mobile ui制作了一个页面,可以左右滑动,但是这对我来说不起作用,因为我只想滑动内容,而不是整个页面,我尝试使用data-role="content"
,但它不再起作用,只有使用data-role="page"
才能实现滑动动画,但只针对内容,是否可能实现?
我有一些<article>
,我想将它们向左/右滑动...但我不想滑动标题和其他内容...只想滑动中间的部分。
如果可能,还要禁用那个愚蠢的jquery mobile主题。
//Le
代码结构
<header data-role="header"> .... </header>
<section>
<!-- only this part I want to swipe, one article at a time -->
<article data-role="page"> ..... </article>
<article data-role="page"> ..... </article>
<article data-role="page"> ..... </article>
<article data-role="page"> ..... </article>
<!-- only this part I want to swipe, one article at a time -->
</section>
<footer> ... </footer>
$('article').bind("swipeleft", function(){
var nextpage = $(this).next('article[data-role="page"]');
// swipe using id of next page if exists
if (nextpage.length > 0) {
$.mobile.changePage(nextpage, {transition: "slide",
reverse: false}, true, true);
}
});
$('article').bind("swiperight", function(){
var prevpage = $(this).prev('article[data-role="page"]');
if (prevpage.length > 0) {
$.mobile.changePage(prevpage, {transition: "slide",
reverse: true}, true, true);
}
});