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


TypeScript DOM.getPos方法代碼示例

本文整理匯總了TypeScript中tinymce/core/dom/DOMUtils.DOM.getPos方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DOM.getPos方法的具體用法?TypeScript DOM.getPos怎麽用?TypeScript DOM.getPos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tinymce/core/dom/DOMUtils.DOM的用法示例。


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

示例1: function

const transposeUiContainer = function (element, pos) {
  if (element && DOMUtils.DOM.getStyle(element, 'position', true) !== 'static') {
    const containerPos = DOMUtils.DOM.getPos(element);
    const dx = containerPos.x - element.scrollLeft;
    const dy = containerPos.y - element.scrollTop;
    return transpose(pos, -dx, -dy);
  } else {
    return transpose(pos, 0, 0);
  }
};
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:10,代碼來源:Coords.ts

示例2: function

const getUiContainerDelta = function () {
  const uiContainer = Env.container;
  if (uiContainer && DOMUtils.DOM.getStyle(uiContainer, 'position', true) !== 'static') {
    const containerPos = DOMUtils.DOM.getPos(uiContainer);
    const dx = uiContainer.scrollLeft - containerPos.x;
    const dy = uiContainer.scrollTop - containerPos.y;
    return Option.some({
      x: dx,
      y: dy
    });
  } else {
    return Option.none();
  }
};
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:14,代碼來源:UiContainer.ts

示例3: function

const showSuggestions = function (editor, pluginUrl, lastSuggestionsState, startedState, textMatcherState, word, spans) {
  const items = [], suggestions = lastSuggestionsState.get().suggestions[word];

  Tools.each(suggestions, function (suggestion) {
    items.push({
      text: suggestion,
      onclick () {
        editor.insertContent(editor.dom.encode(suggestion));
        editor.dom.remove(spans);
        Actions.checkIfFinished(editor, startedState, textMatcherState);
      }
    });
  });

  items.push({ text: '-' });

  const hasDictionarySupport = lastSuggestionsState.get().hasDictionarySupport;
  if (hasDictionarySupport) {
    items.push({
      text: 'Add to Dictionary', onclick () {
        Actions.addToDictionary(editor, pluginUrl, startedState, textMatcherState, word, spans);
      }
    });
  }

  items.push.apply(items, [
    {
      text: 'Ignore', onclick () {
        Actions.ignoreWord(editor, startedState, textMatcherState, word, spans);
      }
    },

    {
      text: 'Ignore all', onclick () {
        Actions.ignoreWord(editor, startedState, textMatcherState, word, spans, true);
      }
    }
  ]);

  // Render menu
  suggestionsMenu = Factory.create('menu', {
    items,
    context: 'contextmenu',
    onautohide (e) {
      if (e.target.className.indexOf('spellchecker') !== -1) {
        e.preventDefault();
      }
    },
    onhide () {
      suggestionsMenu.remove();
      suggestionsMenu = null;
    }
  });

  suggestionsMenu.renderTo(document.body);

  // Position menu
  const pos = DOMUtils.DOM.getPos(editor.getContentAreaContainer());
  const targetPos = editor.dom.getPos(spans[0]);
  const root = editor.dom.getRoot();

  // Adjust targetPos for scrolling in the editor
  if (root.nodeName === 'BODY') {
    targetPos.x -= root.ownerDocument.documentElement.scrollLeft || root.scrollLeft;
    targetPos.y -= root.ownerDocument.documentElement.scrollTop || root.scrollTop;
  } else {
    targetPos.x -= root.scrollLeft;
    targetPos.y -= root.scrollTop;
  }

  pos.x += targetPos.x;
  pos.y += targetPos.y;

  suggestionsMenu.moveTo(pos.x, pos.y + spans[0].offsetHeight);
};
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:75,代碼來源:SuggestionsMenu.ts

示例4: getPos

    if (elm.getBoundingClientRect) {
      const rect = elm.getBoundingClientRect();

      width = Math.max(rect.width || (rect.right - rect.left), elm.offsetWidth);
      height = Math.max(rect.height || (rect.bottom - rect.bottom), elm.offsetHeight);
    } else {
      width = elm.offsetWidth;
      height = elm.offsetHeight;
    }

    return { width, height };
  },

  getPos (elm, root?) {
    return DOMUtils.DOM.getPos(elm, root || funcs.getContainer());
  },

  getContainer () {
    return Env.container ? Env.container : document.body;
  },

  getViewPort (win?) {
    return DOMUtils.DOM.getViewPort(win);
  },

  get (id) {
    return document.getElementById(id);
  },

  addClass (elm, cls) {
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:30,代碼來源:DomUtils.ts


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