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

animator.js 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. import iPhoneXPatch from '../../ons/iphonex-patch';
  21. export var ActionSheetAnimator = function (_BaseAnimator) {
  22. _inherits(ActionSheetAnimator, _BaseAnimator);
  23. function ActionSheetAnimator() {
  24. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  25. _ref$timing = _ref.timing,
  26. timing = _ref$timing === undefined ? 'linear' : _ref$timing,
  27. _ref$delay = _ref.delay,
  28. delay = _ref$delay === undefined ? 0 : _ref$delay,
  29. _ref$duration = _ref.duration,
  30. duration = _ref$duration === undefined ? 0.2 : _ref$duration;
  31. _classCallCheck(this, ActionSheetAnimator);
  32. return _possibleConstructorReturn(this, (ActionSheetAnimator.__proto__ || _Object$getPrototypeOf(ActionSheetAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
  33. }
  34. /**
  35. * @param {HTMLElement} dialog
  36. * @param {Function} done
  37. */
  38. _createClass(ActionSheetAnimator, [{
  39. key: 'show',
  40. value: function show(dialog, done) {
  41. done();
  42. }
  43. /**
  44. * @param {HTMLElement} dialog
  45. * @param {Function} done
  46. */
  47. }, {
  48. key: 'hide',
  49. value: function hide(dialog, done) {
  50. done();
  51. }
  52. }]);
  53. return ActionSheetAnimator;
  54. }(BaseAnimator);
  55. /**
  56. * Android style animator for Action Sheet.
  57. */
  58. export var MDActionSheetAnimator = function (_ActionSheetAnimator) {
  59. _inherits(MDActionSheetAnimator, _ActionSheetAnimator);
  60. function MDActionSheetAnimator() {
  61. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  62. _ref2$timing = _ref2.timing,
  63. timing = _ref2$timing === undefined ? 'ease' : _ref2$timing,
  64. _ref2$delay = _ref2.delay,
  65. delay = _ref2$delay === undefined ? 0 : _ref2$delay,
  66. _ref2$duration = _ref2.duration,
  67. duration = _ref2$duration === undefined ? 0.4 : _ref2$duration;
  68. _classCallCheck(this, MDActionSheetAnimator);
  69. var _this2 = _possibleConstructorReturn(this, (MDActionSheetAnimator.__proto__ || _Object$getPrototypeOf(MDActionSheetAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
  70. _this2.maskTiming = 'linear';
  71. _this2.maskDuration = 0.2;
  72. return _this2;
  73. }
  74. /**
  75. * @param {Object} dialog
  76. * @param {Function} callback
  77. */
  78. _createClass(MDActionSheetAnimator, [{
  79. key: 'show',
  80. value: function show(dialog, callback) {
  81. animit.runAll(animit(dialog._mask).queue({ opacity: 0 }).wait(this.delay).queue({ opacity: 1.0 }, {
  82. duration: this.maskDuration,
  83. timing: this.maskTiming
  84. }), animit(dialog._sheet, this.def).default({ transform: 'translate3d(0, 80%, 0)', opacity: 0 }, { transform: 'translate3d(0, 0, 0)', opacity: 1 }).queue(function (done) {
  85. callback && callback();
  86. done();
  87. }));
  88. }
  89. /**
  90. * @param {Object} dialog
  91. * @param {Function} callback
  92. */
  93. }, {
  94. key: 'hide',
  95. value: function hide(dialog, callback) {
  96. animit.runAll(animit(dialog._mask).queue({ opacity: 1 }).wait(this.delay).queue({ opacity: 0 }, {
  97. duration: this.maskDuration,
  98. timing: this.maskTiming
  99. }), animit(dialog._sheet, this.def).default({ transform: 'translate3d(0, 0, 0)', opacity: 1 }, { transform: 'translate3d(0, 80%, 0)', opacity: 0 }).queue(function (done) {
  100. callback && callback();
  101. done();
  102. }));
  103. }
  104. }]);
  105. return MDActionSheetAnimator;
  106. }(ActionSheetAnimator);
  107. /**
  108. * iOS style animator for dialog.
  109. */
  110. export var IOSActionSheetAnimator = function (_ActionSheetAnimator2) {
  111. _inherits(IOSActionSheetAnimator, _ActionSheetAnimator2);
  112. function IOSActionSheetAnimator() {
  113. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  114. _ref3$timing = _ref3.timing,
  115. timing = _ref3$timing === undefined ? 'ease' : _ref3$timing,
  116. _ref3$delay = _ref3.delay,
  117. delay = _ref3$delay === undefined ? 0 : _ref3$delay,
  118. _ref3$duration = _ref3.duration,
  119. duration = _ref3$duration === undefined ? 0.3 : _ref3$duration;
  120. _classCallCheck(this, IOSActionSheetAnimator);
  121. var _this3 = _possibleConstructorReturn(this, (IOSActionSheetAnimator.__proto__ || _Object$getPrototypeOf(IOSActionSheetAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
  122. _this3.maskTiming = 'linear';
  123. _this3.maskDuration = 0.2;
  124. if (iPhoneXPatch.isIPhoneXPortraitPatchActive()) {
  125. _this3.liftAmount = 'calc(100% + 48px)';
  126. } else if (iPhoneXPatch.isIPhoneXLandscapePatchActive()) {
  127. _this3.liftAmount = 'calc(100% + 33px)';
  128. } else {
  129. _this3.liftAmount = document.body.clientHeight / 2.0 - 1 + 'px'; // avoid Forced Synchronous Layout
  130. }
  131. return _this3;
  132. }
  133. /**
  134. * @param {Object} dialog
  135. * @param {Function} callback
  136. */
  137. _createClass(IOSActionSheetAnimator, [{
  138. key: 'show',
  139. value: function show(dialog, callback) {
  140. animit.runAll(animit(dialog._mask).queue({ opacity: 0 }).wait(this.delay).queue({ opacity: 1 }, {
  141. duration: this.maskDuration,
  142. timing: this.maskTiming
  143. }), animit(dialog._sheet, this.def).default({ transform: 'translate3d(0, ' + this.liftAmount + ', 0)' }, { transform: 'translate3d(0, 0, 0)' }).queue(function (done) {
  144. callback && callback();
  145. done();
  146. }));
  147. }
  148. /**
  149. * @param {Object} dialog
  150. * @param {Function} callback
  151. */
  152. }, {
  153. key: 'hide',
  154. value: function hide(dialog, callback) {
  155. animit.runAll(animit(dialog._mask).queue({ opacity: 1 }).wait(this.delay).queue({ opacity: 0 }, {
  156. duration: this.maskDuration,
  157. timing: this.maskTiming
  158. }), animit(dialog._sheet, this.def).default({ transform: 'translate3d(0, 0, 0)' }, { transform: 'translate3d(0, ' + this.liftAmount + ', 0)' }).queue(function (done) {
  159. callback && callback();
  160. done();
  161. }));
  162. }
  163. }]);
  164. return IOSActionSheetAnimator;
  165. }(ActionSheetAnimator);