对于layui框架源码兼容性微调介绍


当前第2页 返回上一页

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

35

36

37

38

39

40

41

42

43

44

45

// 修改部分定位写法

var showDown = function(){

  // 将样式复位

  dl.css({

    top: '',

    left: '',

    right: ''

  })

  var top = reElem.offset().top + reElem.outerHeight() + 5 - $win.scrollTop()

  ,dlHeight = dl.outerHeight(), dlWidth = dl.outerWidth(), winWidth = $(window).width();

  

  index = select[0].selectedIndex; //获取最新的 selectedIndex

 

   // 判断是否在最右边的临界点

  if (dlWidth + reElem.offset().left > winWidth) {

    dl.css({

      left: 'auto',

      right: 0

    })

  }

  reElem.addClass(CLASS+'ed');

  dds.removeClass(HIDE);

  nearElem = null;

   

  //初始选中样式

  dds.eq(index).addClass(THIS).siblings().removeClass(THIS);

 

  //上下定位识别

  if(top + dlHeight > $win.height() && top >= dlHeight){

    reElem.addClass(CLASS + 'up');

  } else {

    // 定位重写定义

   

    // 动画需要的距离和弹窗的间隔,这是根据 layui 的样式来的,理论应该计算

    var ANIM_UP = 30, SPACE = 5;

    var reElemBottom = reElem.get(0).getBoundingClientRect().bottom;

    var dlTop = parseInt(dl.css('top'));

    var winHeight = $win.height();

    if (reElemBottom + dlHeight + ANIM_UP > winHeight ) {

      var computeValue = dlTop - (reElemBottom + SPACE - (winHeight - dlHeight - ANIM_UP))

      dl.css('top', computeValue)

    }

  }

  followScroll();

}

tree.js

描述:我使用的是 layui2.4.5 版本,内部的 tree功能已经满足了,但是因为图标问题,这里我干脆隐藏

解决:

1

2

3

4

5

6

7

8

9

10

11

12

// 第一处修改

Tree.prototype.tree = function() {

   // 大概在 line 48

   var li = $(['<li '+ (hasChild ? " is-branch " : " is-leaf ") + (item.spread ? 'data-spread="'+ item.spread +'"' : '') +'>'

}

 

// 第二处修改

 

// 大概在 72 - 76 注释掉

 

/*+ ('<i class="layui-icon layui-tree-'+ (hasChild ? "branch" : "leaf") +'">'+ (

         hasChild ? ( item.spread ? icon.branch[1] : icon.branch[0]) : icon.leaf) +'</i>') */ //节点图标

更多layui框架知识请关注layui框架教程。

以上就是对于layui框架源码兼容性微调介绍的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

layui的laydate组件中添加设置一周开始的方法

什么是layui

layui抓取表单数据

layui代码修饰器不显示样式怎么解决

layui中table的sort排序介绍

使用layui表格实现后台分页的方法

layui是软件吗

layui框架常用输入框介绍

改造传统jquery扩展为layui模块方法介绍

layui打开的layer的iframe窗口怎么关闭

更多相关阅读请进入《layui》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...