General.Web/wwwroot/lib/codemirror-5.31.0/test/scroll_test.js

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

(function() {
  "use strict";

  namespace = "scroll_";

  testCM("bars_hidden", function(cm) {
    for (var i = 0;; i++) {
      var wrapBox = cm.getWrapperElement().getBoundingClientRect();
      var scrollBox = cm.getScrollerElement().getBoundingClientRect();
      is(wrapBox.bottom < scrollBox.bottom - 10);
      is(wrapBox.right < scrollBox.right - 10);
      if (i == 1) break;
      cm.getWrapperElement().style.height = "auto";
      cm.refresh();
    }
  });
  
  function barH(cm) { return byClassName(cm.getWrapperElement(), "CodeMirror-hscrollbar")[0]; }
  function barV(cm) { return byClassName(cm.getWrapperElement(), "CodeMirror-vscrollbar")[0]; }

  function displayBottom(cm, scrollbar) {
    if (scrollbar && cm.display.scroller.offsetHeight > cm.display.scroller.clientHeight)
      return barH(cm).getBoundingClientRect().top;
    else
      return cm.getWrapperElement().getBoundingClientRect().bottom - 1;
  }

  function displayRight(cm, scrollbar) {
    if (scrollbar && cm.display.scroller.offsetWidth > cm.display.scroller.clientWidth)
      return barV(cm).getBoundingClientRect().left;
    else
      return cm.getWrapperElement().getBoundingClientRect().right - 1;
  }

  function testMovedownFixed(cm, hScroll) {
    cm.setSize("100px", "100px");
    if (hScroll) cm.setValue(new Array(100).join("x"));
    var bottom = displayBottom(cm, hScroll);
    for (var i = 0; i < 30; i++) {
      cm.replaceSelection("x\n");
      var cursorBottom = cm.cursorCoords(null, "window").bottom;
      is(cursorBottom <= bottom);
    }
    is(cursorBottom >= bottom - 5);
  }

  testCM("movedown_fixed", function(cm) {testMovedownFixed(cm, false);});
  testCM("movedown_hscroll_fixed", function(cm) {testMovedownFixed(cm, true);});

  function testMovedownResize(cm, hScroll) {
    cm.getWrapperElement().style.height = "auto";
    if (hScroll) cm.setValue(new Array(100).join("x"));
    cm.refresh();
    for (var i = 0; i < 30; i++) {
      cm.replaceSelection("x\n");
      var bottom = displayBottom(cm, hScroll);
      var cursorBottom = cm.cursorCoords(null, "window").bottom;
      is(cursorBottom <= bottom);
      is(cursorBottom >= bottom - 5);
    }
后面还有 66 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。