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

animator.js 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. import _Object$keys from 'babel-runtime/core-js/object/keys';
  2. import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of';
  3. import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
  4. import _createClass from 'babel-runtime/helpers/createClass';
  5. import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
  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 animit from '../../ons/animit';
  21. import BaseAnimator from '../../ons/base-animator';
  22. export var PopoverAnimator = function (_BaseAnimator) {
  23. _inherits(PopoverAnimator, _BaseAnimator);
  24. /**
  25. * @param {Object} options
  26. * @param {String} options.timing
  27. * @param {Number} options.duration
  28. * @param {Number} options.delay
  29. */
  30. function PopoverAnimator() {
  31. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  32. _ref$timing = _ref.timing,
  33. timing = _ref$timing === undefined ? 'cubic-bezier(.1, .7, .4, 1)' : _ref$timing,
  34. _ref$delay = _ref.delay,
  35. delay = _ref$delay === undefined ? 0 : _ref$delay,
  36. _ref$duration = _ref.duration,
  37. duration = _ref$duration === undefined ? 0.2 : _ref$duration;
  38. _classCallCheck(this, PopoverAnimator);
  39. return _possibleConstructorReturn(this, (PopoverAnimator.__proto__ || _Object$getPrototypeOf(PopoverAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
  40. }
  41. _createClass(PopoverAnimator, [{
  42. key: 'show',
  43. value: function show(popover, callback) {
  44. callback();
  45. }
  46. }, {
  47. key: 'hide',
  48. value: function hide(popover, callback) {
  49. callback();
  50. }
  51. }, {
  52. key: '_animate',
  53. value: function _animate(element, _ref2) {
  54. var from = _ref2.from,
  55. to = _ref2.to,
  56. options = _ref2.options,
  57. callback = _ref2.callback,
  58. _ref2$restore = _ref2.restore,
  59. restore = _ref2$restore === undefined ? false : _ref2$restore,
  60. animation = _ref2.animation;
  61. options = util.extend({}, this.options, options);
  62. if (animation) {
  63. from = animation.from;
  64. to = animation.to;
  65. }
  66. animation = animit(element);
  67. if (restore) {
  68. animation = animation.saveStyle();
  69. }
  70. animation = animation.queue(from).wait(this.delay).queue({
  71. css: to,
  72. duration: this.duration,
  73. timing: this.timing
  74. });
  75. if (restore) {
  76. animation = animation.restoreStyle();
  77. }
  78. if (callback) {
  79. animation = animation.queue(function (done) {
  80. callback();
  81. done();
  82. });
  83. }
  84. return animation;
  85. }
  86. }, {
  87. key: '_animateAll',
  88. value: function _animateAll(element, animations) {
  89. var _this2 = this;
  90. _Object$keys(animations).forEach(function (key) {
  91. return _this2._animate(element[key], animations[key]).play();
  92. });
  93. }
  94. }]);
  95. return PopoverAnimator;
  96. }(BaseAnimator);
  97. var fade = {
  98. out: {
  99. from: { opacity: 1.0 },
  100. to: { opacity: 0 }
  101. },
  102. in: {
  103. from: { opacity: 0 },
  104. to: { opacity: 1.0 }
  105. }
  106. };
  107. export var MDFadePopoverAnimator = function (_PopoverAnimator) {
  108. _inherits(MDFadePopoverAnimator, _PopoverAnimator);
  109. function MDFadePopoverAnimator() {
  110. _classCallCheck(this, MDFadePopoverAnimator);
  111. return _possibleConstructorReturn(this, (MDFadePopoverAnimator.__proto__ || _Object$getPrototypeOf(MDFadePopoverAnimator)).apply(this, arguments));
  112. }
  113. _createClass(MDFadePopoverAnimator, [{
  114. key: 'show',
  115. value: function show(popover, callback) {
  116. this._animateAll(popover, {
  117. _mask: fade.in,
  118. _popover: { animation: fade.in, restore: true, callback: callback }
  119. });
  120. }
  121. }, {
  122. key: 'hide',
  123. value: function hide(popover, callback) {
  124. this._animateAll(popover, {
  125. _mask: fade.out,
  126. _popover: { animation: fade.out, restore: true, callback: callback }
  127. });
  128. }
  129. }]);
  130. return MDFadePopoverAnimator;
  131. }(PopoverAnimator);
  132. export var IOSFadePopoverAnimator = function (_MDFadePopoverAnimato) {
  133. _inherits(IOSFadePopoverAnimator, _MDFadePopoverAnimato);
  134. function IOSFadePopoverAnimator() {
  135. _classCallCheck(this, IOSFadePopoverAnimator);
  136. return _possibleConstructorReturn(this, (IOSFadePopoverAnimator.__proto__ || _Object$getPrototypeOf(IOSFadePopoverAnimator)).apply(this, arguments));
  137. }
  138. _createClass(IOSFadePopoverAnimator, [{
  139. key: 'show',
  140. value: function show(popover, callback) {
  141. this._animateAll(popover, {
  142. _mask: fade.in,
  143. _popover: {
  144. from: {
  145. transform: 'scale3d(1.3, 1.3, 1.0)',
  146. opacity: 0
  147. },
  148. to: {
  149. transform: 'scale3d(1.0, 1.0, 1.0)',
  150. opacity: 1.0
  151. },
  152. restore: true,
  153. callback: callback
  154. }
  155. });
  156. }
  157. }]);
  158. return IOSFadePopoverAnimator;
  159. }(MDFadePopoverAnimator);