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

animator.js 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 animit from '../../ons/animit';
  19. import BaseAnimator from '../../ons/base-animator';
  20. export var DialogAnimator = function (_BaseAnimator) {
  21. _inherits(DialogAnimator, _BaseAnimator);
  22. function DialogAnimator() {
  23. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  24. _ref$timing = _ref.timing,
  25. timing = _ref$timing === undefined ? 'linear' : _ref$timing,
  26. _ref$delay = _ref.delay,
  27. delay = _ref$delay === undefined ? 0 : _ref$delay,
  28. _ref$duration = _ref.duration,
  29. duration = _ref$duration === undefined ? 0.2 : _ref$duration;
  30. _classCallCheck(this, DialogAnimator);
  31. return _possibleConstructorReturn(this, (DialogAnimator.__proto__ || _Object$getPrototypeOf(DialogAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
  32. }
  33. /**
  34. * @param {HTMLElement} dialog
  35. * @param {Function} done
  36. */
  37. _createClass(DialogAnimator, [{
  38. key: 'show',
  39. value: function show(dialog, done) {
  40. done();
  41. }
  42. /**
  43. * @param {HTMLElement} dialog
  44. * @param {Function} done
  45. */
  46. }, {
  47. key: 'hide',
  48. value: function hide(dialog, done) {
  49. done();
  50. }
  51. }]);
  52. return DialogAnimator;
  53. }(BaseAnimator);
  54. /**
  55. * Android style animator for dialog.
  56. */
  57. export var AndroidDialogAnimator = function (_DialogAnimator) {
  58. _inherits(AndroidDialogAnimator, _DialogAnimator);
  59. function AndroidDialogAnimator() {
  60. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  61. _ref2$timing = _ref2.timing,
  62. timing = _ref2$timing === undefined ? 'ease-in-out' : _ref2$timing,
  63. _ref2$delay = _ref2.delay,
  64. delay = _ref2$delay === undefined ? 0 : _ref2$delay,
  65. _ref2$duration = _ref2.duration,
  66. duration = _ref2$duration === undefined ? 0.3 : _ref2$duration;
  67. _classCallCheck(this, AndroidDialogAnimator);
  68. return _possibleConstructorReturn(this, (AndroidDialogAnimator.__proto__ || _Object$getPrototypeOf(AndroidDialogAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
  69. }
  70. /**
  71. * @param {Object} dialog
  72. * @param {Function} callback
  73. */
  74. _createClass(AndroidDialogAnimator, [{
  75. key: 'show',
  76. value: function show(dialog, callback) {
  77. callback = callback ? callback : function () {};
  78. animit.runAll(animit(dialog._mask, this.def).default({ opacity: 0 }, { opacity: 1 }), animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, -60%, 0)', opacity: 0 }, { transform: 'translate3d(-50%, -50%, 0)', opacity: 1 }).queue(function (done) {
  79. callback();
  80. done();
  81. }));
  82. }
  83. /**
  84. * @param {Object} dialog
  85. * @param {Function} callback
  86. */
  87. }, {
  88. key: 'hide',
  89. value: function hide(dialog, callback) {
  90. callback = callback ? callback : function () {};
  91. animit.runAll(animit(dialog._mask, this.def).default({ opacity: 1 }, { opacity: 0 }), animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, -50%, 0)', opacity: 1 }, { transform: 'translate3d(-50%, -60%, 0)', opacity: 0 }).queue(function (done) {
  92. callback();
  93. done();
  94. }));
  95. }
  96. }]);
  97. return AndroidDialogAnimator;
  98. }(DialogAnimator);
  99. /**
  100. * iOS style animator for dialog.
  101. */
  102. export var IOSDialogAnimator = function (_DialogAnimator2) {
  103. _inherits(IOSDialogAnimator, _DialogAnimator2);
  104. function IOSDialogAnimator() {
  105. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  106. _ref3$timing = _ref3.timing,
  107. timing = _ref3$timing === undefined ? 'ease-in-out' : _ref3$timing,
  108. _ref3$delay = _ref3.delay,
  109. delay = _ref3$delay === undefined ? 0 : _ref3$delay,
  110. _ref3$duration = _ref3.duration,
  111. duration = _ref3$duration === undefined ? 0.2 : _ref3$duration;
  112. _classCallCheck(this, IOSDialogAnimator);
  113. var _this3 = _possibleConstructorReturn(this, (IOSDialogAnimator.__proto__ || _Object$getPrototypeOf(IOSDialogAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
  114. _this3.bodyHeight = document.body.clientHeight; // avoid Forced Synchronous Layout
  115. return _this3;
  116. }
  117. /**
  118. * @param {Object} dialog
  119. * @param {Function} callback
  120. */
  121. _createClass(IOSDialogAnimator, [{
  122. key: 'show',
  123. value: function show(dialog, callback) {
  124. callback = callback ? callback : function () {};
  125. animit.runAll(animit(dialog._mask, this.def).default({ opacity: 0 }, { opacity: 1 }), animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, ' + (this.bodyHeight / 2.0 - 1) + 'px, 0)' }, { transform: 'translate3d(-50%, -50%, 0)' }).queue(function (done) {
  126. callback();
  127. done();
  128. }));
  129. }
  130. /**
  131. * @param {Object} dialog
  132. * @param {Function} callback
  133. */
  134. }, {
  135. key: 'hide',
  136. value: function hide(dialog, callback) {
  137. callback = callback ? callback : function () {};
  138. animit.runAll(animit(dialog._mask, this.def).default({ opacity: 1 }, { opacity: 0 }), animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, -50%, 0)' }, { transform: 'translate3d(-50%, ' + (this.bodyHeight / 2.0 - 1) + 'px, 0)' }).queue(function (done) {
  139. callback();
  140. done();
  141. }));
  142. }
  143. }]);
  144. return IOSDialogAnimator;
  145. }(DialogAnimator);
  146. /**
  147. * Slide animator for dialog.
  148. */
  149. export var SlideDialogAnimator = function (_DialogAnimator3) {
  150. _inherits(SlideDialogAnimator, _DialogAnimator3);
  151. function SlideDialogAnimator() {
  152. var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  153. _ref4$timing = _ref4.timing,
  154. timing = _ref4$timing === undefined ? 'cubic-bezier(.1, .7, .4, 1)' : _ref4$timing,
  155. _ref4$delay = _ref4.delay,
  156. delay = _ref4$delay === undefined ? 0 : _ref4$delay,
  157. _ref4$duration = _ref4.duration,
  158. duration = _ref4$duration === undefined ? 0.2 : _ref4$duration;
  159. _classCallCheck(this, SlideDialogAnimator);
  160. var _this4 = _possibleConstructorReturn(this, (SlideDialogAnimator.__proto__ || _Object$getPrototypeOf(SlideDialogAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
  161. _this4.bodyHeight = document.body.clientHeight; // avoid Forced Synchronous Layout
  162. return _this4;
  163. }
  164. /**
  165. * @param {Object} dialog
  166. * @param {Function} callback
  167. */
  168. _createClass(SlideDialogAnimator, [{
  169. key: 'show',
  170. value: function show(dialog, callback) {
  171. callback = callback ? callback : function () {};
  172. animit.runAll(animit(dialog._mask, this.def).default({ opacity: 0 }, { opacity: 1 }), animit(dialog._dialog, this.def).default(
  173. // FIXME: This should avoid Forced Synchronous Layout. Otherwise, fade animation of mask will be broken.
  174. { transform: 'translate3d(-50%, ' + (-(this.bodyHeight / 2.0) + 1 - dialog._dialog.clientHeight) + 'px, 0)' }, { transform: 'translate3d(-50%, -50%, 0)' }).queue(function (done) {
  175. callback();
  176. done();
  177. }));
  178. }
  179. /**
  180. * @param {Object} dialog
  181. * @param {Function} callback
  182. */
  183. }, {
  184. key: 'hide',
  185. value: function hide(dialog, callback) {
  186. callback = callback ? callback : function () {};
  187. animit.runAll(animit(dialog._mask, this.def).default({ opacity: 1 }, { opacity: 0 }), animit(dialog._dialog, this.def).default({ transform: 'translate3d(-50%, -50%, 0)' },
  188. // FIXME: This should avoid Forced Synchronous Layout. Otherwise, fade animation of mask will be broken.
  189. { transform: 'translate3d(-50%, ' + (-(this.bodyHeight / 2.0) + 1 - dialog._dialog.clientHeight) + 'px, 0)' }).queue(function (done) {
  190. callback();
  191. done();
  192. }));
  193. }
  194. }]);
  195. return SlideDialogAnimator;
  196. }(DialogAnimator);