Без опису

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 iPhoneXPatch from '../../ons/iphonex-patch';
  21. import ToastAnimator from './animator';
  22. /**
  23. * Fall-fade Toast Animator
  24. */
  25. var FallToastAnimator = function (_ToastAnimator) {
  26. _inherits(FallToastAnimator, _ToastAnimator);
  27. function FallToastAnimator() {
  28. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  29. _ref$timing = _ref.timing,
  30. timing = _ref$timing === undefined ? 'ease' : _ref$timing,
  31. _ref$delay = _ref.delay,
  32. delay = _ref$delay === undefined ? 0 : _ref$delay,
  33. _ref$duration = _ref.duration,
  34. duration = _ref$duration === undefined ? 0.35 : _ref$duration;
  35. _classCallCheck(this, FallToastAnimator);
  36. var _this = _possibleConstructorReturn(this, (FallToastAnimator.__proto__ || _Object$getPrototypeOf(FallToastAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
  37. if (iPhoneXPatch.isIPhoneXPortraitPatchActive()) {
  38. _this.fallAmount = 'calc(-100% - 44px)';
  39. } else {
  40. _this.fallAmount = '-100%';
  41. }
  42. return _this;
  43. }
  44. /**
  45. * @param {HTMLElement} toast
  46. * @param {Function} callback
  47. */
  48. _createClass(FallToastAnimator, [{
  49. key: 'show',
  50. value: function show(toast, callback) {
  51. toast = toast._toast;
  52. this._updatePosition(toast);
  53. animit.runAll(animit(toast, this.def).default({ transform: 'translate3d(0, ' + this.fallAmount + ', 0)', opacity: 0 }, { transform: 'translate3d(0, 0, 0)', opacity: 1 }).queue(function (done) {
  54. callback && callback();
  55. done();
  56. }));
  57. }
  58. /**
  59. * @param {HTMLElement} toast
  60. * @param {Function} callback
  61. */
  62. }, {
  63. key: 'hide',
  64. value: function hide(toast, callback) {
  65. var _this2 = this;
  66. toast = toast._toast;
  67. this._updatePosition(toast);
  68. animit.runAll(animit(toast, this.def).default({ transform: 'translate3d(0, 0, 0)', opacity: 1 }, { transform: 'translate3d(0, ' + this.fallAmount + ', 0)', opacity: 0 }).queue(function (done) {
  69. _this2._updatePosition(toast, true);
  70. callback && callback();
  71. done();
  72. }));
  73. }
  74. }, {
  75. key: '_updatePosition',
  76. value: function _updatePosition(toast, cleanUp) {
  77. var correctTop = void 0;
  78. if (iPhoneXPatch.isIPhoneXPortraitPatchActive()) {
  79. correctTop = '44px';
  80. } else {
  81. correctTop = '0';
  82. }
  83. if (toast.style.top !== correctTop) {
  84. toast.style.top = correctTop;
  85. toast.style.bottom = 'initial';
  86. }
  87. }
  88. }]);
  89. return FallToastAnimator;
  90. }(ToastAnimator);
  91. export default FallToastAnimator;