MCPcopy Create free account
hub / github.com/microsoft/SandDance / buildMapping

Function buildMapping

docs/app/js/sanddance-app.js:99421–99453  ·  view source on GitHub ↗
(_ref)

Source from the content-addressed store, hash-verified

99419 }
99420}
99421function buildMapping(_ref) {
99422 var icons = _ref.icons, buffer = _ref.buffer, _ref$mapping = _ref.mapping, mapping = _ref$mapping === void 0 ? {} : _ref$mapping, _ref$xOffset = _ref.xOffset, xOffset = _ref$xOffset === void 0 ? 0 : _ref$xOffset, _ref$yOffset = _ref.yOffset, yOffset = _ref$yOffset === void 0 ? 0 : _ref$yOffset, _ref$rowHeight = _ref.rowHeight, rowHeight = _ref$rowHeight === void 0 ? 0 : _ref$rowHeight, canvasWidth = _ref.canvasWidth;
99423 var columns = [];
99424 for(var i = 0; i < icons.length; i++){
99425 var icon = icons[i];
99426 var id = getIconId(icon);
99427 if (!mapping[id]) {
99428 var height = icon.height, width = icon.width;
99429 if (xOffset + width + buffer > canvasWidth) {
99430 buildRowMapping(mapping, columns, yOffset);
99431 xOffset = 0;
99432 yOffset = rowHeight + yOffset + buffer;
99433 rowHeight = 0;
99434 columns = [];
99435 }
99436 columns.push({
99437 icon: icon,
99438 xOffset: xOffset
99439 });
99440 xOffset = xOffset + width + buffer;
99441 rowHeight = Math.max(rowHeight, height);
99442 }
99443 }
99444 if (columns.length > 0) buildRowMapping(mapping, columns, yOffset);
99445 return {
99446 mapping: mapping,
99447 rowHeight: rowHeight,
99448 xOffset: xOffset,
99449 yOffset: yOffset,
99450 canvasWidth: canvasWidth,
99451 canvasHeight: nextPowOfTwo(rowHeight + yOffset + buffer)
99452 };
99453}
99454function getDiffIcons(data, getIcon, cachedIcons) {
99455 if (!data || !getIcon) return null;
99456 cachedIcons = cachedIcons || {};

Callers 1

sanddance-app.jsFile · 0.70

Calls 5

getIconIdFunction · 0.70
buildRowMappingFunction · 0.70
nextPowOfTwoFunction · 0.70
maxMethod · 0.45

Tested by

no test coverage detected