Skip to content

Calendar永远只会往下弹出,弹到页面外面去了 #1

@Diluka

Description

@Diluka

临时修复方案,仅针对DatePicker,没有处理DatetimePicker

CSS:

.bui-calendar2:before {
    content: '';
    display: inline-block;
    border-top: 7px solid rgba(0, 0, 0, 0.2);
    border-right: 7px solid transparent;
    border-bottom-width: 0;
    border-left: 7px solid transparent;
    position: absolute;
    left: 5px;
    bottom: -7px !important;
    top: auto !important;
}

.bui-calendar2:after {
    content: '';
    display: inline-block;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 0;
    border-top: 6px solid #fff;
    position: absolute;
    left: 6px;
    bottom: -6px;
    top: auto;
}

JS:

/**
 * 修复dp永远往下弹出的bug
 * @param $ jQuery
 * @param Calendar BUI.Calendar
 */
function datepickerFix($, Calendar) {

    //删除已经生成的dp
    $(".bui-datepicker").remove();

    //重新创建dp
    var datepicker = new Calendar.DatePicker({
        trigger: '.calendar',
        delegateTrigger: true,
        autoRender: true
    });

    //添加show事件响应
    datepicker.on("show", function (e) {

        var $dp = $(e.target.get("el"));

        if ($(window).height() < $dp.offset().top + $dp.height()) {
            $dp.offset({top: $dp.offset().top - $dp.height() - 32});
            $dp.find(".bui-calendar").addClass("bui-calendar2");
        } else {
            $dp.find(".bui-calendar").removeClass("bui-calendar2");
        }
    });

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions