UNPKG

impress.me

Version:

Create impress.js presentations from markdown documents with style

52 lines (51 loc) 2.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ColumnPositionStrategy = void 0; const helpers_1 = require("../helpers"); const shape_1 = require("../shape"); const linear_position_strategy_1 = require("./linear-position.strategy"); class ColumnPositionStrategy { constructor(config) { this.config = config; this.scale = 0.4; this.shape = shape_1.shapeConfig[this.config.shape]; this.offset = { x: -(this.config.width / 2) - ((this.shape.width + this.shape.siblingOffset.x) * this.scale / 2), y: (this.shape.height + this.shape.parentOffset.y - 1080) * 0.2, z: 0, scale: this.scale, }; } calculate(node) { if (node.classes && node.classes.includes('overview')) { return linear_position_strategy_1.overviewPosition(node, this.config, this.shape.width, this.scale); } let siblingIndex; let siblings; let previousSibling; switch (node.depth) { case 1: return { x: 0, y: 0, z: 0, scale: 1, }; case 2: { siblingIndex = node.parent.children.indexOf(node); if (siblingIndex === 0) { // first h2 step return Object.assign(Object.assign({}, this.offset), { x: this.offset.x + ((this.shape.width + this.shape.siblingOffset.x) * this.offset.scale) }); } siblings = node.parent.children; previousSibling = siblings[siblingIndex - 1]; return Object.assign(Object.assign({}, this.offset), { x: previousSibling.pos.x + ((this.shape.width + this.shape.siblingOffset.x) * this.offset.scale) }); } default: { siblingIndex = helpers_1.findIndex(node.parent, node); return Object.assign(Object.assign({}, this.offset), { x: node.parent.pos.x, y: this.offset.y + ((this.shape.height + this.shape.siblingOffset.y) * siblingIndex * this.offset.scale) }); } } } } exports.ColumnPositionStrategy = ColumnPositionStrategy;