v1.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. $(function()
  2. {
  3. // 修复连接曲线位置
  4. const fixReleasePathLine = function()
  5. {
  6. const $lines = $('.release-paths .release-line');
  7. $lines.each(function()
  8. {
  9. const $line = $(this);
  10. const $next = $line.next();
  11. let $nextLine, $linkLine;
  12. if($next.hasClass('release-line'))
  13. {
  14. $nextLine = $next;
  15. }
  16. else if($next.hasClass('release-link-line'))
  17. {
  18. $linkLine = $next;
  19. $nextLine = $next.next();
  20. }
  21. if ($nextLine && $nextLine.length)
  22. {
  23. if(!$linkLine) $linkLine = $('<div class="release-link-line" />').insertAfter($line)
  24. const $startPos = $line.find(':first-child > a').position();
  25. const $endPos = $nextLine.find(':last-child > a').position();
  26. $linkLine.css({
  27. top: $startPos.top + 6,
  28. left: $startPos.left + 12,
  29. width: $endPos.left - $startPos.left,
  30. height: 172
  31. });
  32. }
  33. });
  34. const $paths = $('.release-path');
  35. $paths.each(function()
  36. {
  37. const $path = $(this);
  38. const $next = $path.next();
  39. let $nextPath, $linkLine;
  40. if($next.hasClass('release-path'))
  41. {
  42. $nextPath = $next;
  43. }
  44. else if($next.hasClass('release-link-line'))
  45. {
  46. $linkLine = $next;
  47. $nextPath = $next.next();
  48. }
  49. if ($nextPath && $nextPath.length)
  50. {
  51. if(!$linkLine) $linkLine = $('<div class="release-link-line" />').insertAfter($path);
  52. const $startPos = $path.find('.grow > .release-line:last-child > :first-child > a').position();
  53. const $endPos = $nextPath.find('.grow > .release-line:first-child > :last-child > a').position();
  54. $linkLine.css({
  55. top: $startPos.top + 6,
  56. left: $startPos.left + 12,
  57. width: $endPos.left - $startPos.left,
  58. height: 172
  59. });
  60. }
  61. });
  62. };
  63. fixReleasePathLine();
  64. window.addEventListener('resize', fixReleasePathLine);
  65. });