Guest User

Untitled

a guest
May 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. import {TimelineMax, Power4} from "gsap";
  2.  
  3. const duration = 0.5;
  4. const easeing = Power4.easeInOut;
  5. const animateModal = {
  6. show(background, target, content, close){
  7. var tl = new TimelineMax();
  8. return tl
  9. .to(target, 0,
  10. {
  11. width: content.offsetWidth
  12. })
  13. .to(target, 0,
  14. {
  15. height: content.offsetHeight
  16. })
  17. .to(background, 0,
  18. {
  19. display: 'initial',
  20. },
  21. )
  22. .from(background, duration,
  23. {
  24. opacity: 0,
  25. ease: easeing,
  26. },
  27. 0)
  28. .from(target, duration,
  29. {
  30. top: -target.offsetHeight,
  31. ease: easeing,
  32. },
  33. 0)
  34.  
  35. },
  36. hide(background, target, content, close, cb){
  37. var tl = new TimelineMax();
  38. return tl
  39. .to(target, duration,
  40. {
  41. top: -target.offsetHeight,
  42. ease: easeing,
  43. })
  44. .to(background, duration,
  45. {
  46. opacity: 0,
  47. ease: easeing,
  48. },0
  49. )
  50. .to(background, 0,
  51. {
  52. display: 'none',
  53. },
  54. )
  55. .call(cb)
  56. },
  57. resize(target, content){
  58. var tl = new TimelineMax();
  59. return tl
  60. .to(target, duration/5,
  61. {
  62. width: content.offsetWidth,
  63. })
  64. .to(target, duration/5,
  65. {
  66. height: content.offsetHeight
  67. })
  68. .to(content, duration/5,
  69. {
  70. opacity: 1,
  71. })
  72. },
  73. resize2(target, content){
  74. var tl = new TimelineMax();
  75. return tl
  76. .to(target, 0,
  77. {
  78. width: content.offsetWidth,
  79. height: content.offsetHeight,
  80. top: '50%',
  81. left: '50%',
  82. })
  83. },
  84. changeContent(content, cb){
  85. var tl = new TimelineMax();
  86. return tl
  87. .to(content, duration/5,
  88. {
  89. opacity: 0,
  90. })
  91. .call(cb)
  92. }
  93. }
  94.  
  95. export default animateModal
Add Comment
Please, Sign In to add comment