lxw
2020-07-11 9db52f2f2dd3665fe9da1ae5657e0167c3a34d40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// define class Panel
function Panel(panel) {
    this.panel = panel;    // 面板
    this.width = this.panel.width();    // 面板初始宽度
    this.ht = this.panel.height();    // 面板初始高度
    this.parent = $('.panel').parent();    // 面板容器
    this.parentWidth = this.parent.width();    // 面板容器宽度
    this.parentHt = this.parent.height();    // 面板容器高度
}
 
Panel.prototype.setPanelLayout = function() {
    // 判断panel的高度是否超出容器的高度
    if(this.ht > this.parentHt) {
        this.panel.css('overflow-y', 'scroll');
        this.panel.height(this.parentHt);
    }
    
    console.info('样式设置已执行');
}
 
Panel.prototype.showPanel = function() {
    this.parentHt = this.parent.height();    // 面板容器高度
    var panelWidth = 300;
    this.parent.find('.panel-mask').remove();
    this.panel.animate({width: panelWidth});
    this.panel.before($('<div class="panel-mask position-left" style="float: left"></div>'));
    this.parent.find('.panel-mask').height(this.parentHt);
 
}
 
Panel.prototype.hidePanel = function() {
    this.panel.animate({width: '0'});
    this.parent.find('.panel-mask').remove();
}