motion.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. 'use strict';
  2. window.$ && window.$.Velocity && (window.Velocity = window.$.Velocity), NexT.motion = {}, NexT.motion.integrator = {
  3. queue: [],
  4. cursor: -1,
  5. init: function () {
  6. return this.queue = [], this.cursor = -1, this;
  7. },
  8. add: function (t) {
  9. return this.queue.push(t), this;
  10. },
  11. next: function () {
  12. this.cursor++;
  13. var t = this.queue[this.cursor];
  14. 'function' == typeof t && t(NexT.motion.integrator);
  15. },
  16. bootstrap: function () {
  17. this.next();
  18. }
  19. }, NexT.motion.middleWares = {
  20. logo: function (t) {
  21. var e = [], o = document.querySelector('.brand'), n = document.querySelector('.custom-logo-image'), i = document.querySelector('.site-title'), r = document.querySelector('.site-subtitle'), c = document.querySelector('.logo-line-before i'), u = document.querySelector('.logo-line-after i');
  22. function s(t, e) {
  23. return {
  24. e: t,
  25. p: { translateX: e },
  26. o: {
  27. duration: 500,
  28. sequenceQueue: !1
  29. }
  30. };
  31. }
  32. function l() {
  33. e.push({
  34. e: n,
  35. p: {
  36. opacity: 1,
  37. top: 0
  38. },
  39. o: { duration: 200 }
  40. });
  41. }
  42. o && e.push({
  43. e: o,
  44. p: { opacity: 1 },
  45. o: { duration: 200 }
  46. }), 'Mist' === CONFIG.scheme && c && u && e.push(s(c, '100%'), s(u, '-100%')), 'Muse' === CONFIG.scheme && n && l(), i && e.push({
  47. e: i,
  48. p: {
  49. opacity: 1,
  50. top: 0
  51. },
  52. o: { duration: 200 }
  53. }), r && e.push({
  54. e: r,
  55. p: {
  56. opacity: 1,
  57. top: 0
  58. },
  59. o: { duration: 200 }
  60. }), 'Pisces' !== CONFIG.scheme && 'Gemini' !== CONFIG.scheme || !n || l(), 0 < e.length ? (e[e.length - 1].o.complete = function () {
  61. t.next();
  62. }, Velocity.RunSequence(e)) : t.next(), CONFIG.motion.async && t.next();
  63. },
  64. menu: function (t) {
  65. Velocity(document.querySelectorAll('.menu-item'), 'transition.slideDownIn', {
  66. display: null,
  67. duration: 200,
  68. complete: function () {
  69. t.next();
  70. }
  71. }), CONFIG.motion.async && t.next();
  72. },
  73. subMenu: function (t) {
  74. var e = document.querySelectorAll('.sub-menu .menu-item');
  75. 0 < e.length && e.forEach(function (t) {
  76. t.style.opacity = 1;
  77. }), t.next();
  78. },
  79. postList: function (t) {
  80. var e = document.querySelectorAll('.post-block, .pagination, .comments'), o = CONFIG.motion.transition.post_block, n = document.querySelectorAll('.post-header'), i = CONFIG.motion.transition.post_header, r = document.querySelectorAll('.post-body'), c = CONFIG.motion.transition.post_body, u = document.querySelectorAll('.collection-header'), s = CONFIG.motion.transition.coll_header;
  81. if (0 < e.length) {
  82. var l = window.postMotionOptions || {
  83. stagger: 100,
  84. drag: !0,
  85. complete: function () {
  86. t.next();
  87. }
  88. };
  89. CONFIG.motion.transition.post_block && Velocity(e, 'transition.' + o, l), CONFIG.motion.transition.post_header && Velocity(n, 'transition.' + i, l), CONFIG.motion.transition.post_body && Velocity(r, 'transition.' + c, l), CONFIG.motion.transition.coll_header && Velocity(u, 'transition.' + s, l);
  90. }
  91. 'Pisces' !== CONFIG.scheme && 'Gemini' !== CONFIG.scheme || t.next();
  92. },
  93. sidebar: function (t) {
  94. var e = document.querySelector('.sidebar-inner'), o = CONFIG.motion.transition.sidebar;
  95. !o || 'Pisces' !== CONFIG.scheme && 'Gemini' !== CONFIG.scheme || Velocity(e, 'transition.' + o, {
  96. display: null,
  97. duration: 200,
  98. complete: function () {
  99. e.style.transform = 'initial';
  100. }
  101. }), t.next();
  102. }
  103. };