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

ascend-animator.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 animit from '../../ons/animit';
  20. import platform from '../../ons/platform';
  21. import iPhoneXPatch from '../../ons/iphonex-patch';
  22. import ToastAnimator from './animator';
  23. /**
  24. * Ascend Toast Animator.
  25. */
  26. var AscendToastAnimator = function (_ToastAnimator) {
  27. _inherits(AscendToastAnimator, _ToastAnimator);
  28. function AscendToastAnimator() {
  29. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  30. _ref$timing = _ref.timing,
  31. timing = _ref$timing === undefined ? 'ease' : _ref$timing,
  32. _ref$delay = _ref.delay,
  33. delay = _ref$delay === undefined ? 0 : _ref$delay,
  34. _ref$duration = _ref.duration,
  35. duration = _ref$duration === undefined ? 0.25 : _ref$duration;
  36. _classCallCheck(this, AscendToastAnimator);
  37. var _this = _possibleConstructorReturn(this, (AscendToastAnimator.__proto__ || _Object$getPrototypeOf(AscendToastAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
  38. _this.messageDelay = _this.duration * 0.4 + _this.delay; // Delay message opacity change
  39. if (platform.isAndroid()) {
  40. _this.ascension = 48; // Toasts are always 1 line
  41. } else {
  42. if (iPhoneXPatch.isIPhoneXPortraitPatchActive()) {
  43. _this.ascension = 98; // 64 + 34
  44. } else if (iPhoneXPatch.isIPhoneXLandscapePatchActive()) {
  45. _this.ascension = 85; // 64 + 21
  46. } else {
  47. _this.ascension = 64;
  48. }
  49. }
  50. return _this;
  51. }
  52. /**
  53. * @param {HTMLElement} toast
  54. * @param {Function} callback
  55. */
  56. _createClass(AscendToastAnimator, [{
  57. key: 'show',
  58. value: function show(toast, callback) {
  59. toast = toast._toast;
  60. util.globals.fabOffset = this.ascension;
  61. animit.runAll(animit(toast, this.def).default({ transform: 'translate3d(0, ' + this.ascension + 'px, 0)' }, { transform: 'translate3d(0, 0, 0)' }).queue(function (done) {
  62. callback && callback();
  63. done();
  64. }), animit(this._getFabs()).wait(this.delay).queue({ transform: 'translate3d(0, -' + this.ascension + 'px, 0) scale(1)' }, this.def), animit(util.arrayFrom(toast.children), this.def).default({ opacity: 0 }, { opacity: 1 }));
  65. }
  66. /**
  67. * @param {HTMLElement} toast
  68. * @param {Function} callback
  69. */
  70. }, {
  71. key: 'hide',
  72. value: function hide(toast, callback) {
  73. toast = toast._toast;
  74. util.globals.fabOffset = 0;
  75. animit.runAll(animit(toast, this.def).default({ transform: 'translate3d(0, 0, 0)' }, { transform: 'translate3d(0, ' + this.ascension + 'px, 0)' }).queue(function (done) {
  76. callback && callback();
  77. done();
  78. }), animit(this._getFabs(), this.def).wait(this.delay).queue({ transform: 'translate3d(0, 0, 0) scale(1)' }, this.def), animit(util.arrayFrom(toast.children), this.def).default({ opacity: 1 }, { opacity: 0 }));
  79. }
  80. }, {
  81. key: '_getFabs',
  82. value: function _getFabs() {
  83. return util.arrayFrom(document.querySelectorAll('ons-fab[position~=bottom], ons-speed-dial[position~=bottom]')).filter(function (fab) {
  84. return fab.visible;
  85. });
  86. }
  87. }]);
  88. return AscendToastAnimator;
  89. }(ToastAnimator);
  90. export default AscendToastAnimator;