Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Diluka opened this issue Jun 25, 2015 · 0 comments
Open

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

Diluka opened this issue Jun 25, 2015 · 0 comments

Comments

@Diluka
Copy link

Diluka commented Jun 25, 2015

临时修复方案,仅针对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");
        }
    });

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant