Javascript 在pageload上,应隐藏底部面板
我在页面底部有一个用于面板显示/隐藏的jQuery。 但是面板在页面加载时弹出。我需要在页面加载时隐藏面板&我需要在切换时显示它 这是我的JS:Javascript 在pageload上,应隐藏底部面板,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我在页面底部有一个用于面板显示/隐藏的jQuery。 但是面板在页面加载时弹出。我需要在页面加载时隐藏面板&我需要在切换时显示它 这是我的JS: (function($) { jQuery(document).ready(function() { Panel.init(); $(document).on('click', '.tab-controller', function() { Panel.togglePanel(); }); }); var Panel = { isVisi
(function($) {
jQuery(document).ready(function() {
Panel.init();
$(document).on('click', '.tab-controller', function() {
Panel.togglePanel();
});
});
var Panel = {
isVisible : true,
showMessage : null,
hideMessage : null,
animationDuration : 650,
animationEasing : 'linear',
init : function() {
},
hidePanel : function() {
$('.panel-wrapper').animate({
bottom : -(Panel.getAnimationOffset())
}, Panel.animationDuration, Panel.animationEasing, function() {
Panel.isVisible = false;
Panel.updateTabMessage();
});
},
showPanel : function() {
$('.panel-wrapper').animate({
bottom : 0
}, Panel.animationDuration, Panel.animationEasing, function() {
Panel.isVisible = true;
Panel.updateTabMessage();
});
},
togglePanel : function() {
((this.isVisible) ? this.hidePanel : this.showPanel)();
},
updateTabMessage : function() {
if (this.isVisible) {
$('.tab-controller .close').show();
$('.tab-controller .show').hide();
} else {
$('.tab-controller .close').hide();
$('.tab-controller .show').show();
}
},
getAnimationOffset : function() {
return $('.panel-content').height();
}
}
})(jQuery);
我尝试了isVisible=false,但没有成功。所以我在init函数中调用了hidePanel,它现在可以正常工作了,但问题是面板在页面加载时隐藏了动画。我根本不想在页面加载时显示面板 这是我的CSS:
.panel-wrapper * {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.panel-wrapper {
position: fixed;
left: 0;
bottom: 0;
overflow: hidden;
width: 100%;
font-family: sans-serif;
}
.panel-controller {
position: relative;
overflow: hidden;
width: 100%;
}
.tab-controller {
float: right;
margin-right: 50px;
padding: 10px 10px 5px;
background-color: #8C293B;
-webkit-border-radius: 15px 15px 0 0;
-moz-border-radius: 15px 15px 0 0;
border-radius: 15px 15px 0 0;
}
.tab-controller * {
display: block;
font-family: sans-serif;
font-size: 16px;
font-weight: bold;
color: white;
cursor: pointer;
}
.tab-controller .show {
display: none;
}
.panel-content {
overflow: hidden;
width: 100%;
background-color: #8C293B;
}
这是我的HTML:
<div class="panel-wrapper">
<div class="panel-controller">
<div class="tab-controller"> <span class="close">CLOSE PANEL</span> <span class="show">OPEN PANEL</span> </div>
</div>
<div class="panel-content">
Panel content goes here
</div>
</div>
关闭面板打开面板
面板内容在这里
默认情况下,您可以将isVisible字段设置为false,但如果您希望保持此状态,则应在init中调用hidePanel可能还有更多,但hidePanel()函数中有错误:
hidePanel : function() {
$('.panel-wrapper').animate({
bottom : -( Panel.get('<a href="http://www.jqueryscript.net/animation/">Animation</a>').Offset()) //errorline
}, Panel.animationDuration, Panel.animationEasing, function() {
Panel.isVisible = false;
Panel.up('<a href="http://www.jqueryscript.net/time-clock/">date</a>').TabMessage(); //errorline
});
},
这条线看起来也很可疑(什么是TabMessage?)
Panel.up(“”).TabMessage();
我尝试使用isVisible=false,但它不起作用。所以我在init函数中调用了hidePanel,它现在可以正常工作了,但问题是面板在页面加载时隐藏了动画。我根本不想在页面加载上显示面板。您可以在init中重新编码hidePanel,而不使用动画方法。我尝试在不使用动画方法的情况下重新编码hidePanel。但我没能做到。你能把代码贴在这里吗。。。thanx提前@spooark
bottom : -(Panel.get<a href="http://www.jqueryscript.net/animation/">Animation</a>Offset())
bottom : -( Panel.get('<a href="http://www.jqueryscript.net/animation/">Animation</a>').Offset()) //errorline
})(jQuery);
Panel.up('<a href="http://www.jqueryscript.net/time-clock/">date</a>').TabMessage();