我有一个带有固定全屏工具栏的jQuery移动页面,其中启用了data-tap-toggle。
在工具栏下面,我定位了一个横幅,当工具栏隐藏时,它应该向上滑动,当工具栏显示时,它会向下滑动。
jQuery移动通过应用和删除ui-fixed-hidden类来切换toolbar --遗憾的是,在toolbar小部件的文档中找不到相应的toggle、hide或show事件。
如何检测toolbar何时被切换,以重新定位我的横幅?
.banner {
position: fixed;
background-color: darkseagreen;
top: 46px;
min-height: 48px;
width: 100%;
text-align: center;
line-height: 48px;
}<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.css">
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>
</head>
<body>
<div data-role="page" id="page-one">
<div data-theme="a" data-role="header" data-position="fixed" data-fullscreen="true">
<h1>First Page</h1>
</div>
<div data-role="content">
<div class="banner">call-to-action</div>
</div>
<div data-theme="a" data-role="footer" data-position="fixed" data-fullscreen="true">
<h3>Footer</h3>
</div>
</div>
</body>
</html>
发布于 2017-08-21 08:48:37
解决方案1
扩展mobile.toolbar小部件。
$.widget("mobile.toolbar", $.mobile.toolbar, {
toggle: function() {
this[this._visible ? "hide" : "show"]();
if (this._visible) {
/* visible */
} else {
/* hidden */
}
}
});解决方案2
听动画结束事件。
$(document).on("pagecreate", function() {
$(".ui-header").on("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function(e) {
/* do something */
});
});https://stackoverflow.com/questions/45786080
复制相似问题