123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2017
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['../TransitionController', './TransitionDirector', '../../util/AnimationHelper'], function (BaseClass, TransitionDirector, AnimationHelper) {
- var AnimatedPathSlideShowTransitionController = BaseClass.extend({
- _duration: null,
- _cssOnScreen: {
- display: 'block',
- transform: 'scale(1)',
- position: 'absolute',
- top: '0px',
- bottom: '0px',
- left: '0px',
- right: '0px'
- },
- init: function init(options) {
- AnimatedPathSlideShowTransitionController.inherited('init', this, arguments);
- this._duration = options.duration ? options.duration : 100;
- this._timeline = options.timeline;
- },
- _beforeJump: function _beforeJump(from) {
- this._hideWidgets(from);
- return AnimatedPathSlideShowTransitionController.inherited('_beforeJump', this, arguments);
- },
- _jump: function _jump(from, to) {
- if (from && from.$el) {
- from.$el.css({
- transform: AnimationHelper.SCALE_ZERO
- }).attr('aria-hidden', 'true');
- }
- to.$el.css(this._cssOnScreen).css({ opacity: 1 }).addClass('selected').attr('aria-hidden', 'false');
- return AnimatedPathSlideShowTransitionController.inherited('_jump', this, arguments);
- },
- _afterJump: function _afterJump(from, to) {
- this._showWidgets(to);
- return AnimatedPathSlideShowTransitionController.inherited('_afterJump', this, arguments);
- },
- _beforeNext: function _beforeNext(from, to) {
- return Promise.try(function () {
- this._beforeJump(from, to);
- }.bind(this)).then(function () {
- to.$el.css(this._cssOnScreen).addClass('selected').attr('aria-hidden', 'false');
- return this._transitionWidgets(from, to);
- }.bind(this));
- },
- _next: function _next() {
- return AnimatedPathSlideShowTransitionController.inherited('_next', this, arguments);
- },
- _afterNext: function _afterNext(from, to) {
- from.$el.css({
- transform: AnimationHelper.SCALE_ZERO
- }).attr('aria-hidden', 'true');
- return this._restoreWidgets(from, to).then(this._afterJump.bind(this, from, to));
- },
- _beforePrevious: function _beforePrevious(from, to) {
- return this._beforeJump(from, to);
- },
- _previous: function _previous(from, to) {
- return this._jump(from, to);
- },
- _afterPrevious: function _afterPrevious(from, to) {
- return this._afterJump(from, to);
- },
- _transitionWidgets: function _transitionWidgets(view, target) {
- if (view && view.getLayoutView && target && target.getLayoutView) {
- this._transitionMap = this._timeline.getWidgetTransitionMap(view.getLayoutView(), target.getLayoutView());
- if (this._transitionMap) {
- var fromEvent = {
- current: view,
- to: target,
- linkIdMap: this._transitionMap
- };
- var toEvent = {
- current: target,
- from: view,
- linkIdMap: this._transitionMap
- };
- var layoutView = view.getLayoutView();
- if (layoutView && layoutView.model) {
- var rootLayout = view.getLayoutView().model.getTopLayoutModel();
- var director = new TransitionDirector({ rootLayout: rootLayout });
- var promises = [];
- promises = promises.concat(view.getLayoutView().reduce(director.getOnTransitionCallback(fromEvent)));
- promises = promises.concat(target.getLayoutView().reduce(director.getOnTransitionCallback(toEvent)));
- return Promise.all(promises);
- }
- }
- }
- return Promise.resolve();
- },
- _restoreWidgets: function _restoreWidgets(view, target) {
- if (view && view.getLayoutView && target && target.getLayoutView && this._transitionMap) {
- var fromEvent = {
- current: view,
- to: target,
- linkIdMap: this._transitionMap
- };
- var toEvent = {
- current: target,
- from: view,
- linkIdMap: this._transitionMap
- };
- this._transitionMap = null;
- var layoutView = view.getLayoutView();
- if (layoutView && layoutView.model) {
- var rootLayout = view.getLayoutView().model.getTopLayoutModel();
- var director = new TransitionDirector({ rootLayout: rootLayout });
- var promises = [];
- promises = promises.concat(view.getLayoutView().reduce(director.getAfterTransitionCallback(fromEvent)));
- promises = promises.concat(target.getLayoutView().reduce(director.getAfterTransitionCallback(toEvent)));
- return Promise.all(promises);
- }
- }
- return Promise.resolve();
- }
- });
- return AnimatedPathSlideShowTransitionController;
- });
- //# sourceMappingURL=AnimatedPathSlideShowTransitionController.js.map
|