码迷,mamicode.com
首页 > 其他好文 > 详细

优化laydate日期选取控件位于页面最右侧时会撑开页面的问题

时间:2017-07-07 21:38:38      阅读:354      评论:0      收藏:0      [点我收藏+]

标签:方法   问题   日期   otto   ima   height   blog   date   rect   

 

laydate控件是我到目前以来用过最顺心的控件,虽然该控件已经非常优秀了,但在使用中还是会遇到点问题。

如果该控件位于页面的最右侧,点击后会出现如下问题。

技术分享

 

可以看到点击后页面被撑大了。

 

解决方案:

修改laydate.js文件,先找到orien方法的定义,修改为:

c.orien = function (a, b) {
        var d, e = c.elem.getBoundingClientRect();
        var win_left = e.left + (b ? 0 : c.scroll(1)) + "px";
        if ((c.elem.offsetLeft + a.clientWidth) > document.documentElement.clientWidth) {
            win_left = c.elem.offsetLeft - (a.clientWidth - c.elem.clientWidth) + "px";
        }
        a.style.left = win_left;
        d = e.bottom + a.offsetHeight / 1.5 <= c.winarea() ? e.bottom - 1 : e.top > a.offsetHeight / 1.5 ? e.top - a.offsetHeight + 1 : c.winarea() - a.offsetHeight, a.style.top = d + (b ? 0 : c.scroll()) + "px"
    }

 

最后

技术分享

 

优化laydate日期选取控件位于页面最右侧时会撑开页面的问题

标签:方法   问题   日期   otto   ima   height   blog   date   rect   

原文地址:http://www.cnblogs.com/microgreatwall/p/7133779.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!