Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

md-slide-animator.js 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of';
  2. import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
  3. import _createClass from 'babel-runtime/helpers/createClass';
  4. import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
  5. import _get from 'babel-runtime/helpers/get';
  6. import _inherits from 'babel-runtime/helpers/inherits';
  7. /*
  8. Copyright 2013-2015 ASIAL CORPORATION
  9. Licensed under the Apache License, Version 2.0 (the "License");
  10. you may not use this file except in compliance with the License.
  11. You may obtain a copy of the License at
  12. http://www.apache.org/licenses/LICENSE-2.0
  13. Unless required by applicable law or agreed to in writing, software
  14. distributed under the License is distributed on an "AS IS" BASIS,
  15. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. See the License for the specific language governing permissions and
  17. limitations under the License.
  18. */
  19. import util from '../../ons/util';
  20. import NavigatorAnimator from './animator';
  21. import animit from '../../ons/animit';
  22. /**
  23. * Slide animator for navigator transition.
  24. */
  25. var MDSlideNavigatorAnimator = function (_NavigatorAnimator) {
  26. _inherits(MDSlideNavigatorAnimator, _NavigatorAnimator);
  27. function MDSlideNavigatorAnimator() {
  28. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  29. _ref$timing = _ref.timing,
  30. timing = _ref$timing === undefined ? 'cubic-bezier(.1, .7, .4, 1)' : _ref$timing,
  31. _ref$delay = _ref.delay,
  32. delay = _ref$delay === undefined ? 0 : _ref$delay,
  33. _ref$duration = _ref.duration,
  34. duration = _ref$duration === undefined ? 0.3 : _ref$duration;
  35. _classCallCheck(this, MDSlideNavigatorAnimator);
  36. var _this = _possibleConstructorReturn(this, (MDSlideNavigatorAnimator.__proto__ || _Object$getPrototypeOf(MDSlideNavigatorAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
  37. _this.blackMaskOpacity = 0.4;
  38. _this.backgroundMask = util.createElement('<div style="position: absolute; width: 100%; height: 100%; z-index: 2;' + 'background-color: black; opacity: 0;"></div>');
  39. return _this;
  40. }
  41. /**
  42. * @param {Object} enterPage
  43. * @param {Object} leavePage
  44. * @param {Function} callback
  45. */
  46. _createClass(MDSlideNavigatorAnimator, [{
  47. key: 'push',
  48. value: function push(enterPage, leavePage, callback) {
  49. var _this2 = this;
  50. this.backgroundMask.remove();
  51. leavePage.parentElement.insertBefore(this.backgroundMask, leavePage.nextSibling);
  52. var unblock = _get(MDSlideNavigatorAnimator.prototype.__proto__ || _Object$getPrototypeOf(MDSlideNavigatorAnimator.prototype), 'block', this).call(this, enterPage);
  53. animit.runAll(animit(this.backgroundMask, this.def).default({ transform: 'translate3d(0, 0, 0)', opacity: 0 }, { opacity: this.blackMaskOpacity }).queue(function (done) {
  54. _this2.backgroundMask.remove();
  55. done();
  56. }), animit(enterPage, this.def).default({ transform: 'translate3d(100%, 0, 0)' }, { transform: 'translate3d(0, 0, 0)' }), animit(leavePage, this.def).default({ transform: 'translate3d(0, 0, 0)' }, { transform: 'translate3d(-45%, 0, 0)' }).queue(function (done) {
  57. unblock();
  58. callback();
  59. done();
  60. }));
  61. }
  62. /**
  63. * @param {Object} enterPage
  64. * @param {Object} leavePage
  65. * @param {Function} callback
  66. */
  67. }, {
  68. key: 'pop',
  69. value: function pop(enterPage, leavePage, callback) {
  70. var _this3 = this;
  71. this.backgroundMask.remove();
  72. enterPage.parentNode.insertBefore(this.backgroundMask, enterPage.nextSibling);
  73. var unblock = _get(MDSlideNavigatorAnimator.prototype.__proto__ || _Object$getPrototypeOf(MDSlideNavigatorAnimator.prototype), 'block', this).call(this, enterPage);
  74. animit.runAll(animit(this.backgroundMask, this.def).default({ transform: 'translate3d(0, 0, 0)', opacity: this.blackMaskOpacity }, { opacity: 0 }).queue(function (done) {
  75. _this3.backgroundMask.remove();
  76. done();
  77. }), animit(enterPage, this.def).default({ transform: 'translate3d(-45%, 0, 0)', opacity: .9 }, { transform: 'translate3d(0, 0, 0)', opacity: 1 }), animit(leavePage, this.def).default({ transform: 'translate3d(0, 0, 0)' }, { transform: 'translate3d(100%, 0, 0)' }).queue(function (done) {
  78. unblock();
  79. callback();
  80. done();
  81. }));
  82. }
  83. }]);
  84. return MDSlideNavigatorAnimator;
  85. }(NavigatorAnimator);
  86. export default MDSlideNavigatorAnimator;