本文整理汇总了TypeScript中tinymce/core/api/geom/Rect.inflate函数的典型用法代码示例。如果您正苦于以下问题:TypeScript inflate函数的具体用法?TypeScript inflate怎么用?TypeScript inflate使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了inflate函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: zoomFit
return memContainer.getOpt(anyInSystem).map((panel) => {
const aImg = GuiFactory.external({
element: img
});
Replacing.replaceAt(panel, 1, Option.some(aImg));
const lastViewRect = viewRectState.get();
const viewRect = {
x: 0,
y: 0,
w: img.dom().naturalWidth,
h: img.dom().naturalHeight
};
viewRectState.set(viewRect);
const rect = Rect.inflate(viewRect, -20, -20);
rectState.set(rect);
if (lastViewRect.w !== viewRect.w || lastViewRect.h !== viewRect.h) {
zoomFit(panel, img);
}
repaintImg(panel, img);
return img;
});
示例2:
LoadImage.loadImage(img).then(function () {
let rect, $img;
const lastRect = self.state.get('viewRect');
$img = self.$el.find('img');
if ($img[0]) {
$img.replaceWith(img);
} else {
const bg = document.createElement('div');
bg.className = 'mce-imagepanel-bg';
self.getEl().appendChild(bg);
self.getEl().appendChild(img);
}
rect = { x: 0, y: 0, w: img.naturalWidth, h: img.naturalHeight };
self.state.set('viewRect', rect);
self.state.set('rect', Rect.inflate(rect, -20, -20));
if (!lastRect || lastRect.w !== rect.w || lastRect.h !== rect.h) {
self.zoomFit();
}
self.repaintImage();
self.fire('load');
});
示例3: 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(panel).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');
};
示例4: function
suite.test('inflate', function () {
LegacyUnit.deepEqual(Rect.inflate(Rect.create(10, 20, 30, 40), 5, 10), Rect.create(5, 10, 40, 60));
});