[英]“JQuery Bottom Content Panel” Load as “hidden” instead of “show”
I'm currently trying to get this: http://www.jqueryscript.net/layout/Creating-A-Toggable-Bottom-Content-Panel-Using-jQuery-CSS.html 我目前正在尝试获取此信息: http : //www.jqueryscript.net/layout/Creating-A-Toggable-Bottom-Content-Panel-Using-jQuery-CSS.html
To load as hidden and ready to be opened instead of already opened. 加载为隐藏状态并准备好打开而不是已经打开。 Below is the main.js code:
下面是main.js代码:
(function($) {
jQuery(document).ready(function() {
Panel.init();
$(document).on('click', '.tab-controller', function() {
Panel.togglePanel();
});
});
var Panel = {
isVisible : false,
showMessage : null,
hideMessage : null,
animationDuration : 350,
animationEasing : 'linear',
init : function() {
},
showPanel : function() {
$('.panel-wrapper').animate({
bottom : 0
}, Panel.animationDuration, Panel.animationEasing, function() {
Panel.isVisible = true;
Panel.updateTabMessage();
});
},
hidePanel : function() {
$('.panel-wrapper').animate({
bottom : -(Panel.getAnimationOffset())
}, Panel.animationDuration, Panel.animationEasing, function() {
Panel.isVisible = false;
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);
I've been staring at this for hours and have gone braindead, I think I might be missing something basic. 我一直盯着这个看了好几个小时,已经死了,我想我可能缺少一些基本的东西。 Would this have anything to do with the CSS?
这与CSS有什么关系吗? Any help would be greatly appreciated, thanks!
任何帮助将不胜感激,谢谢!
Try this: 尝试这个:
init : function() {
this.hidePanel();
},
Instead of leaving the init empty. 而不是将init留空。
I made the following modifications so that the isVisible
flag determines whether the panel starts OPEN or CLOSED: 我进行了以下修改,以便
isVisible
标志确定面板是开始OPEN还是CLOSED:
Modify the hidePanel()
function so that we can pass it a flag. 修改
hidePanel()
函数,以便我们可以向其传递一个标志。 The flag determines whether the panel should animate or "snap" shut. 该标志确定面板是应该关闭动画还是“捕捉”关闭。 This gives us the option to close the menu instantly upon init without any animation.
这使我们可以选择在启动时立即关闭菜单而无需任何动画。
hidePanel: function (snap) { $('.panel-wrapper').animate({ bottom: -(Panel.getAnimationOffset()) }, (snap ? 0 : Panel.animationDuration), Panel.animationEasing, function () { Panel.isVisible = false; Panel.updateTabMessage(); }); },
Modify the init()
function to check the isVisible
flag and "snap" the panel shut if appropriate: 修改
init()
函数以检查isVisible
标志,并在适当情况下“捕捉”面板关闭:
init: function () { if (!this.isVisible) { this.hidePanel(true); } },
Modify the togglePanel()
function to pass the "snap" flag to hidePanel()
as false (do animation): 修改
togglePanel()
函数以将“ snap”标志传递给false的hidePanel()
(做动画):
togglePanel: function () { ((this.isVisible) ? this.hidePanel(false) : this.showPanel)(); },
Set the intial isVisible
value to false
: 将初始
isVisible
值设置为false
:
isVisible: false,
To start with the panel open, just set the isVisible
flag to true
: 要从打开面板开始,只需将
isVisible
标志设置为true
:
isVisible: true,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.