當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript dom-globals.ClientRect類代碼示例

本文整理匯總了TypeScript中@ephox/dom-globals.ClientRect的典型用法代碼示例。如果您正苦於以下問題:TypeScript ClientRect類的具體用法?TypeScript ClientRect怎麽用?TypeScript ClientRect使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ClientRect類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: deflate

 return Arr.bind(tds, (td) => {
   const rect = deflate(roundRect(td.getBoundingClientRect()), -1);
   return [
     { x: rect.left, y: getYAxisValue(rect), cell: td },
     { x: rect.right, y: getYAxisValue(rect), cell: td }
   ];
 });
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:7,代碼來源:TableCells.ts

示例2: getBrClientRect

const getBoundingClientRect = (item: Element | Range): ClientRect => {
  let clientRect, clientRects;

  clientRects = item.getClientRects();
  if (clientRects.length > 0) {
    clientRect = GeomClientRect.clone(clientRects[0]);
  } else {
    clientRect = GeomClientRect.clone(item.getBoundingClientRect());
  }

  if (!isRange(item) && isBr(item) && isZeroRect(clientRect)) {
    return getBrClientRect(item);
  }

  if (isZeroRect(clientRect) && isRange(item)) {
    return getBoundingClientRectWebKitText(item);
  }

  return clientRect;
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:20,代碼來源:CaretPosition.ts

示例3: function

  const addCharacterOffset = function (container, offset) {
    const range = createRange(container.ownerDocument);

    if (offset < container.data.length) {
      if (ExtendingChar.isExtendingChar(container.data[offset])) {
        return clientRects;
      }

      // WebKit returns two client rects for a position after an extending
      // character a\uxxx|b so expand on "b" and collapse to start of "b" box
      if (ExtendingChar.isExtendingChar(container.data[offset - 1])) {
        range.setStart(container, offset);
        range.setEnd(container, offset + 1);

        if (!isHiddenWhiteSpaceRange(range)) {
          addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect(range), false));
          return clientRects;
        }
      }
    }

    if (offset > 0) {
      range.setStart(container, offset - 1);
      range.setEnd(container, offset);

      if (!isHiddenWhiteSpaceRange(range)) {
        addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect(range), false));
      }
    }

    if (offset < container.data.length) {
      range.setStart(container, offset);
      range.setEnd(container, offset + 1);

      if (!isHiddenWhiteSpaceRange(range)) {
        addUniqueAndValidRect(collapseAndInflateWidth(getBoundingClientRect(range), true));
      }
    }
  };
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:39,代碼來源:CaretPosition.ts

示例4: hide

  const show = (before: boolean, element: HTMLElement): Range => {
    let clientRect, rng;

    hide();

    if (isTableCell(element)) {
      return null;
    }

    if (isBlock(element)) {
      caretContainerNode = CaretContainer.insertBlock('p', element, before);
      clientRect = getAbsoluteClientRect(root, element, before);
      DomQuery(caretContainerNode).css('top', clientRect.top);

      const caret = DomQuery('<div class="mce-visual-caret" data-mce-bogus="all"></div>').css(clientRect).appendTo(root)[0];
      lastVisualCaret.set(Option.some({ caret, element, before }));

      lastVisualCaret.get().each((caretState) => {
        if (before) {
          DomQuery(caretState.caret).addClass('mce-visual-caret-before');
        }
      });

      startBlink();

      rng = element.ownerDocument.createRange();
      rng.setStart(caretContainerNode, 0);
      rng.setEnd(caretContainerNode, 0);
    } else {
      caretContainerNode = CaretContainer.insertInline(element, before);
      rng = element.ownerDocument.createRange();

      if (isContentEditableFalse(caretContainerNode.nextSibling)) {
        rng.setStart(caretContainerNode, 0);
        rng.setEnd(caretContainerNode, 0);
      } else {
        rng.setStart(caretContainerNode, 1);
        rng.setEnd(caretContainerNode, 1);
      }

      return rng;
    }

    return rng;
  };
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:45,代碼來源:FakeCaret.ts

示例5: getAbsoluteClientRect

 lastVisualCaret.get().each((caretState) => {
   const clientRect = getAbsoluteClientRect(root, caretState.element, caretState.before);
   DomQuery(caretState.caret).css(clientRect);
 });
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:4,代碼來源:FakeCaret.ts


注:本文中的@ephox/dom-globals.ClientRect類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。