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

animator.js 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 _inherits from 'babel-runtime/helpers/inherits';
  6. /*
  7. Copyright 2013-2015 ASIAL CORPORATION
  8. Licensed under the Apache License, Version 2.0 (the "License");
  9. you may not use this file except in compliance with the License.
  10. You may obtain a copy of the License at
  11. http://www.apache.org/licenses/LICENSE-2.0
  12. Unless required by applicable law or agreed to in writing, software
  13. distributed under the License is distributed on an "AS IS" BASIS,
  14. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. See the License for the specific language governing permissions and
  16. limitations under the License.
  17. */
  18. import util from '../../ons/util';
  19. import styler from '../../ons/styler';
  20. import contentReady from '../../ons/content-ready';
  21. import BaseAnimator from '../../ons/base-animator';
  22. var SplitterAnimator = function (_BaseAnimator) {
  23. _inherits(SplitterAnimator, _BaseAnimator);
  24. function SplitterAnimator() {
  25. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  26. _ref$timing = _ref.timing,
  27. timing = _ref$timing === undefined ? 'cubic-bezier(.1, .7, .1, 1)' : _ref$timing,
  28. _ref$duration = _ref.duration,
  29. duration = _ref$duration === undefined ? 0.3 : _ref$duration,
  30. _ref$delay = _ref.delay,
  31. delay = _ref$delay === undefined ? 0 : _ref$delay;
  32. _classCallCheck(this, SplitterAnimator);
  33. return _possibleConstructorReturn(this, (SplitterAnimator.__proto__ || _Object$getPrototypeOf(SplitterAnimator)).call(this, { timing: timing, duration: duration, delay: delay }));
  34. }
  35. _createClass(SplitterAnimator, [{
  36. key: 'updateOptions',
  37. value: function updateOptions() {
  38. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  39. util.extend(this, {
  40. timing: this.timing, duration: this.duration, delay: this.delay
  41. }, options);
  42. }
  43. /**
  44. * @param {Element} sideElement
  45. */
  46. }, {
  47. key: 'activate',
  48. value: function activate(sideElement) {
  49. var _this2 = this;
  50. var splitter = sideElement.parentNode;
  51. contentReady(splitter, function () {
  52. _this2._side = sideElement;
  53. _this2._oppositeSide = splitter.right !== sideElement && splitter.right || splitter.left !== sideElement && splitter.left;
  54. _this2._content = splitter.content;
  55. _this2._mask = splitter.mask;
  56. });
  57. }
  58. }, {
  59. key: 'deactivate',
  60. value: function deactivate() {
  61. this.clearTransition();
  62. this._mask && this.clearMask();
  63. this._content = this._side = this._oppositeSide = this._mask = null;
  64. }
  65. }, {
  66. key: 'clearTransition',
  67. value: function clearTransition() {
  68. var _this3 = this;
  69. 'side mask content'.split(/\s+/).forEach(function (e) {
  70. return _this3['_' + e] && styler.clear(_this3['_' + e], 'transform transition');
  71. });
  72. }
  73. }, {
  74. key: 'clearMask',
  75. value: function clearMask() {
  76. // Check if the other side needs the mask before clearing
  77. if (!this._oppositeSide || this._oppositeSide.mode === 'split' || !this._oppositeSide.isOpen) {
  78. this._mask.style.opacity = '';
  79. this._mask.style.display = 'none';
  80. }
  81. }
  82. /**
  83. * @param {Number} distance
  84. */
  85. }, {
  86. key: 'translate',
  87. value: function translate(distance) {}
  88. /**
  89. * @param {Function} done
  90. */
  91. }, {
  92. key: 'open',
  93. value: function open(done) {
  94. done();
  95. }
  96. /**
  97. * @param {Function} done
  98. */
  99. }, {
  100. key: 'close',
  101. value: function close(done) {
  102. done();
  103. }
  104. }, {
  105. key: 'minus',
  106. get: function get() {
  107. return this._side.side === 'right' ? '-' : '';
  108. }
  109. }]);
  110. return SplitterAnimator;
  111. }(BaseAnimator);
  112. export default SplitterAnimator;