()
| 54 | |
| 55 | // 绘制Ruler |
| 56 | let _drawRuler = function () { |
| 57 | |
| 58 | let _t = 0, _h = 30, _w = 30; |
| 59 | let $win = jQuery(window); |
| 60 | let $page = jQuery('html'); |
| 61 | let elScroll = jQuery(document.scrollingElement || 'html'); |
| 62 | let $width = Math.max($win.width(), $page.width(), elScroll[0].scrollWidth); |
| 63 | let $height = Math.max($win.height(), $page.height(), elScroll[0].scrollHeight); |
| 64 | let rulerTop = jQuery('#fe-helper-ruler-top').width($width); |
| 65 | let rulerLeft = jQuery('#fe-helper-ruler-left').height($height); |
| 66 | |
| 67 | if (!rulerTop.children().length || rulerTop.children().last().position().left < $width - 50) { |
| 68 | rulerTop.html(''); |
| 69 | for (let i = 30; i <= $width; i += 10) { |
| 70 | _t = (i % 50) ? 10 : 0; |
| 71 | jQuery('<div class="h-line"></div>').appendTo('#fe-helper-ruler-top').css({ |
| 72 | left: i - 1, |
| 73 | top: _t + 15, |
| 74 | height: _h - _t - 5 |
| 75 | }); |
| 76 | if (_t === 0 && i !== 0) { |
| 77 | jQuery('<div class="h-text">' + i + '</div>').appendTo('#fe-helper-ruler-top').css({ |
| 78 | left: i - (String(i).length * 4) |
| 79 | }); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | if (!rulerLeft.children().length || rulerLeft.children().last().position().top < $height - 50) { |
| 85 | rulerLeft.html(''); |
| 86 | for (let i = 0; i <= $height; i += 10) { |
| 87 | _l = (i % 50) ? 10 : 0; |
| 88 | jQuery('<div class="v-line"></div>').appendTo('#fe-helper-ruler-left').css({ |
| 89 | left: _l + 15, |
| 90 | top: i - 1, |
| 91 | width: _w - _l - 5 |
| 92 | }); |
| 93 | if (_l === 0) { |
| 94 | jQuery('<div class="v-text">' + i + '</div>').appendTo('#fe-helper-ruler-left').css({ |
| 95 | top: i - (String(i).length * 4), |
| 96 | left: i === 0 ? 5 : 0 |
| 97 | }); |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | }; |
| 102 | |
| 103 | // 创建页面标尺 |
| 104 | let _createPageRuler = function () { |
no test coverage detected