'use strict'; /** * Licensed Materials - Property of IBM IBM Cognos Products: BI Cloud (C) * Copyright IBM Corp. 2016, 2017, 2018 US Government Users Restricted Rights - Use, * duplication or disclosure restricted by GSA ADP Schedule Contract with IBM * Corp. */ define(['./PanAndZoomLayout', 'text!./templates/Sequence.html', 'text!./templates/SequenceItems.html'], function (BaseClass, SequenceTemplate, SequenceItemsTemplate) { var magicStepHeightRatio = 640 / 440; var LayoutTemplate = BaseClass.extend({ changePageSize: function changePageSize(event) { var info = { scenePadding: 16, sceneHeight: event.value.height, stepHeight: event.value.height * magicStepHeightRatio, width: event.value.width }; info.offsetWidth = info.width + info.scenePadding; info.offsetHeight = info.stepHeight + info.scenePadding; info.halfOffsetWidth = info.offsetWidth / 2; info.halfOffsetHeight = info.offsetHeight / 2; this._boxLayoutInfo = info; this.sceneLocations = [{ x: 0, y: 0, scale: 1 }]; }, /** * Called to get the location of the center of the specified scene * * @param index - * index of the scene. * @param viewport - * viewport to scale the scene to * @param sceneModel - * model to retrieve the size from * @return an object with an x, y, and a scale * */ _getSceneLocation: function _getSceneLocation(index, viewport) { var info = this._boxLayoutInfo; var layoutBox = this.sceneLocations[0]; var xOffset = info.offsetWidth * index; var viewportScale = this._computeViewportScale(viewport, this._boxLayoutInfo.offsetHeight, this._boxLayoutInfo.offsetWidth); return { x: xOffset * viewportScale, y: layoutBox.y, scale: layoutBox.scale, sceneHeight: info.sceneHeight * viewportScale, sceneWidth: info.width * viewportScale, stepHeight: info.stepHeight * viewportScale, stepWidth: info.width * viewportScale }; }, /** * Called to get the location of the center of the overview * @param viewport - * the viewport the overview has to be scaled to. * @return an object with an x, y, and a scale * */ _getOverviewLocation: function _getOverviewLocation(viewport) { // first scene is always on the left var x1 = this._boxLayoutInfo.halfOffsetWidth * -1; var y1 = this._boxLayoutInfo.halfOffsetHeight; // use last scene to figure out how far right we are. var lastScene = this._getSceneLocation(this.model.items.length - 1); var x2 = lastScene.x + this._boxLayoutInfo.halfOffsetWidth; var y2 = lastScene.y - this._boxLayoutInfo.halfOffsetHeight; var xScale = (x2 - x1) / this._boxLayoutInfo.offsetWidth; var yScale = (y2 - y1) / this._boxLayoutInfo.offsetHeight; var x = (x2 + x1) / 2; var y = (y2 + y1) / 2; var viewportScale = this._computeViewportScale(viewport, this._boxLayoutInfo.offsetHeight, this._boxLayoutInfo.offsetWidth); var scaleRatio = this._computeScaleRatio(viewport); var scale = Math.max(xScale, yScale) * scaleRatio; return { scale: scale > 1 ? scale : 1, x: x * viewportScale, y: y * viewportScale }; }, _computeScaleRatio: function _computeScaleRatio(viewport) { var ratioWidth = this._boxLayoutInfo.offsetWidth / this._boxLayoutInfo.offsetHeight; var viewportRatioWidth = viewport.width / viewport.height; return ratioWidth / viewportRatioWidth; } }); /* used by HtmlTemplates.js */ LayoutTemplate.getTemplate = function () { return [SequenceTemplate, SequenceItemsTemplate]; }; return LayoutTemplate; }); //# sourceMappingURL=PanAndZoomLayout6.js.map