• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript Rect.clamp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中tinymce/core/geom/Rect.clamp函数的典型用法代码示例。如果您正苦于以下问题:TypeScript clamp函数的具体用法?TypeScript clamp怎么用?TypeScript clamp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了clamp函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: function

  suite.test('clamp', function () {
    LegacyUnit.deepEqual(
      Rect.clamp(Rect.create(10, 20, 30, 40), Rect.create(10, 20, 30, 40)),
      Rect.create(10, 20, 30, 40)
    );

    LegacyUnit.deepEqual(
      Rect.clamp(Rect.create(5, 20, 30, 40), Rect.create(10, 20, 30, 40)),
      Rect.create(10, 20, 25, 40)
    );

    LegacyUnit.deepEqual(
      Rect.clamp(Rect.create(5, 20, 30, 40), Rect.create(10, 20, 30, 40), true),
      Rect.create(10, 20, 30, 40)
    );
  });
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:16,代码来源:RectTest.ts


示例2: moveRect

  function moveRect(handle, startRect, deltaX, deltaY) {
    let x, y, w, h, rect;

    x = startRect.x;
    y = startRect.y;
    w = startRect.w;
    h = startRect.h;

    x += deltaX * handle.deltaX;
    y += deltaY * handle.deltaY;
    w += deltaX * handle.deltaW;
    h += deltaY * handle.deltaH;

    if (w < 20) {
      w = 20;
    }

    if (h < 20) {
      h = 20;
    }

    rect = currentRect = Rect.clamp({ x, y, w, h }, clampRect, handle.name === 'move');
    rect = getRelativeRect(clampRect, rect);

    instance.fire('updateRect', { rect });
    setInnerRect(rect);
  }
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:27,代码来源:CropRect.ts


示例3: function

const calcByPositions = function (testPositions1, testPositions2, targetRect, contentAreaRect, panelRect) {
  let relPos, relRect, outputPanelRect;

  const paddedContentRect = {
    x: contentAreaRect.x,
    y: contentAreaRect.y,
    w: contentAreaRect.w + (contentAreaRect.w < (panelRect.w + targetRect.w) ? panelRect.w : 0),
    h: contentAreaRect.h + (contentAreaRect.h < (panelRect.h + targetRect.h) ? panelRect.h : 0)
  };

  relPos = Rect.findBestRelativePosition(panelRect, targetRect, paddedContentRect, testPositions1);
  targetRect = Rect.clamp(targetRect, paddedContentRect);

  if (relPos) {
    relRect = Rect.relativePosition(panelRect, targetRect, relPos);
    outputPanelRect = moveTo(panelRect, relRect);
    return result(outputPanelRect, relPos);
  }

  targetRect = Rect.intersect(paddedContentRect, targetRect);
  if (targetRect) {
    relPos = Rect.findBestRelativePosition(panelRect, targetRect, paddedContentRect, testPositions2);

    if (relPos) {
      relRect = Rect.relativePosition(panelRect, targetRect, relPos);
      outputPanelRect = moveTo(panelRect, relRect);
      return result(outputPanelRect, relPos);
    }

    outputPanelRect = moveTo(panelRect, targetRect);
    return result(outputPanelRect, relPos);
  }

  return null;
};
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:35,代码来源:Layout.ts


示例4: function

  const reposition = function (match, shouldShow?) {
    let relPos, panelRect, elementRect, contentAreaRect, panel, relRect, testPositions, smallElementWidthThreshold;
    const handler = Settings.getInlineToolbarPositionHandler(editor);

    if (editor.removed) {
      return;
    }

    if (!match || !match.toolbar.panel) {
      hideAllFloatingPanels(editor);
      return;
    }

    testPositions = [
      'bc-tc', 'tc-bc',
      'tl-bl', 'bl-tl',
      'tr-br', 'br-tr'
    ];

    panel = match.toolbar.panel;

    // Only show the panel on some events not for example nodeChange since that fires when context menu is opened
    if (shouldShow) {
      panel.show();
    }

    elementRect = getElementRect(match.element);
    panelRect = DOM.getRect(panel.getEl());
    contentAreaRect = DOM.getRect(editor.getContentAreaContainer() || editor.getBody());

    const delta = UiContainer.getUiContainerDelta().getOr({ x: 0, y: 0 });
    elementRect.x += delta.x;
    elementRect.y += delta.y;
    panelRect.x += delta.x;
    panelRect.y += delta.y;
    contentAreaRect.x += delta.x;
    contentAreaRect.y += delta.y;

    smallElementWidthThreshold = 25;

    if (DOM.getStyle(match.element, 'display', true) !== 'inline') {
      // We need to use these instead of the rect values since the style
      // size properites might not be the same as the real size for a table if it has a caption
      const clientRect = match.element.getBoundingClientRect();
      elementRect.w = clientRect.width;
      elementRect.h = clientRect.height;
    }

    if (!editor.inline) {
      contentAreaRect.w = editor.getDoc().documentElement.offsetWidth;
    }

    // Inflate the elementRect so it doesn't get placed above resize handles
    if (editor.selection.controlSelection.isResizable(match.element) && elementRect.w < smallElementWidthThreshold) {
      elementRect = Rect.inflate(elementRect, 0, 8);
    }

    relPos = Rect.findBestRelativePosition(panelRect, elementRect, contentAreaRect, testPositions);
    elementRect = Rect.clamp(elementRect, contentAreaRect);

    if (relPos) {
      relRect = Rect.relativePosition(panelRect, elementRect, relPos);
      movePanelTo(panel, userConstrain(handler, relRect.x, relRect.y, elementRect, contentAreaRect, panelRect));
    } else {
      // Allow overflow below the editor to avoid placing toolbars ontop of tables
      contentAreaRect.h += panelRect.h;

      elementRect = Rect.intersect(contentAreaRect, elementRect);
      if (elementRect) {
        relPos = Rect.findBestRelativePosition(panelRect, elementRect, contentAreaRect, [
          'bc-tc', 'bl-tl', 'br-tr'
        ]);

        if (relPos) {
          relRect = Rect.relativePosition(panelRect, elementRect, relPos);
          movePanelTo(panel, userConstrain(handler, relRect.x, relRect.y, elementRect, contentAreaRect, panelRect));
        } else {
          movePanelTo(panel, userConstrain(handler, elementRect.x, elementRect.y, elementRect, contentAreaRect, panelRect));
        }
      } else {
        panel.hide();
      }
    }

    togglePositionClass(panel, relPos, function (pos1, pos2) {
      return pos1 === pos2;
    });

    // drawRect(contentAreaRect, 'blue');
    // drawRect(elementRect, 'red');
    // drawRect(panelRect, 'green');
  };
开发者ID:howardjing,项目名称:tinymce,代码行数:92,代码来源:ContextToolbars.ts



注:本文中的tinymce/core/geom/Rect.clamp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript Rect.create函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ClientRect.isBelow函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap