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

lift-animator.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. * Lift-fade Toast Animator
  24. */
  25. var LiftToastAnimator = function (_ToastAnimator) {
  26. _inherits(LiftToastAnimator, _ToastAnimator);
  27. function LiftToastAnimator() {
  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, LiftToastAnimator);
  36. var _this = _possibleConstructorReturn(this, (LiftToastAnimator.__proto__ || _Object$getPrototypeOf(LiftToastAnimator)).call(this, { timing: timing, delay: delay, duration: duration }));
  37. _this.bodyHeight = document.body.clientHeight; // avoid Forced Synchronous Layout
  38. if (iPhoneXPatch.isIPhoneXPortraitPatchActive()) {
  39. _this.liftAmount = 'calc(100% + 34px)';
  40. } else if (iPhoneXPatch.isIPhoneXLandscapePatchActive()) {
  41. _this.liftAmount = 'calc(100% + 21px)';
  42. } else {
  43. _this.liftAmount = '100%';
  44. }
  45. return _this;
  46. }
  47. /**
  48. * @param {HTMLElement} toast
  49. * @param {Function} callback
  50. */
  51. _createClass(LiftToastAnimator, [{
  52. key: 'show',
  53. value: function show(toast, callback) {
  54. toast = toast._toast;
  55. animit.runAll(animit(toast, this.def).default({ transform: 'translate3d(0, ' + this.liftAmount + ', 0)', opacity: 0 }, { transform: 'translate3d(0, 0, 0)', opacity: 1 }).queue(function (done) {
  56. callback && callback();
  57. done();
  58. }));
  59. }
  60. /**
  61. * @param {HTMLElement} toast
  62. * @param {Function} callback
  63. */
  64. }, {
  65. key: 'hide',
  66. value: function hide(toast, callback) {
  67. toast = toast._toast;
  68. animit.runAll(animit(toast, this.def).default({ transform: 'translate3d(0, 0, 0)', opacity: 1 }, { transform: 'translate3d(0, ' + this.liftAmount + ', 0)', opacity: 0 }).queue(function (done) {
  69. callback && callback();
  70. done();
  71. }));
  72. }
  73. }, {
  74. key: '_updatePosition',
  75. value: function _updatePosition(toast) {
  76. if (parseInt(toast.style.top, 10) === 0) {
  77. toast.style.top = toast.style.bottom = '';
  78. }
  79. }
  80. }]);
  81. return LiftToastAnimator;
  82. }(ToastAnimator);
  83. export default LiftToastAnimator;