完成签约之后直接添加人员,录入下发凭证
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.4 KiB

  1. const TIME_TO_FILL_FPRINT = 2000; //ms
  2. const $fprintPaths = document.querySelectorAll('.demo__fprint-path');
  3. const $endingPaths = document.querySelectorAll('.demo__ending-path');
  4. const fprintPathSelector = '.demo__fprint-path';
  5. let fprintPaths = [];
  6. let lastRafCallTimestamp = 0;
  7. let curFprintPathsOffset = -1;
  8. let fprintProgressionDirection = 1;
  9. let isFprintAnimationInProgress = false;
  10. let isFprintAnimationOver = false;
  11. let fprintTick = 0;
  12. let currentFprintProgresss = 0;
  13. function offsetAllFprintPaths(ratio) {
  14. fprintPaths.forEach(path => path.offset(ratio));
  15. }
  16. function fprintFrame(timestamp) {
  17. if (!lastRafCallTimestamp) {
  18. lastRafCallTimestamp = timestamp;
  19. window.requestAnimationFrame(fprintFrame);
  20. return;
  21. }
  22. let diff = timestamp - lastRafCallTimestamp;
  23. fprintTick = (diff / TIME_TO_FILL_FPRINT) * 2;
  24. lastRafCallTimestamp = timestamp;
  25. curFprintPathsOffset += fprintTick * fprintProgressionDirection;
  26. offsetAllFprintPaths(curFprintPathsOffset);
  27. if (curFprintPathsOffset >= -1 && curFprintPathsOffset <= 1) {
  28. window.requestAnimationFrame(fprintFrame);
  29. }
  30. else if (curFprintPathsOffset > 1) {
  31. curFprintPathsOffset = curFprintPathsOffset - 2;
  32. offsetAllFprintPaths(curFprintPathsOffset);
  33. window.requestAnimationFrame(fprintFrame);
  34. }
  35. else if (curFprintPathsOffset < -1) {
  36. curFprintPathsOffset = curFprintPathsOffset + 2;
  37. offsetAllFprintPaths(curFprintPathsOffset);
  38. window.requestAnimationFrame(fprintFrame);
  39. }
  40. }
  41. function fprintFrameToProcess(timestamp) {
  42. if (!lastRafCallTimestamp) {
  43. lastRafCallTimestamp = timestamp;
  44. window.requestAnimationFrame(fprintFrameToProcess);
  45. return;
  46. }
  47. let diff = timestamp - lastRafCallTimestamp;
  48. fprintTick = (diff / TIME_TO_FILL_FPRINT) * 2;
  49. lastRafCallTimestamp = timestamp;
  50. curFprintPathsOffset += fprintTick * fprintProgressionDirection;
  51. offsetAllFprintPaths(curFprintPathsOffset);
  52. if (curFprintPathsOffset >= -1 && curFprintPathsOffset <= currentFprintProgresss - 1) {
  53. window.requestAnimationFrame(fprintFrameToProcess);
  54. }
  55. else if (curFprintPathsOffset > currentFprintProgresss - 1) {
  56. curFprintPathsOffset = currentFprintProgresss - 1;
  57. offsetAllFprintPaths(curFprintPathsOffset);
  58. lastRafCallTimestamp = 0;
  59. }
  60. }
  61. function setFprintProgress(progress) {
  62. if (progress == 0) {
  63. curFprintPathsOffset = -1;
  64. offsetAllFprintPaths(curFprintPathsOffset);
  65. }else {
  66. currentFprintProgresss = progress;
  67. window.requestAnimationFrame(fprintFrameToProcess);
  68. }
  69. }
  70. class Path {
  71. constructor(selector, index) {
  72. this.index = index;
  73. this.querySelection = document.querySelectorAll(selector)[index];
  74. this.length = this.querySelection.getTotalLength();
  75. this.$ = $(selector).eq(index);
  76. this.setDasharray();
  77. this.removesForwards = this.$.hasClass('demo__fprint-path--removes-forwards');
  78. }
  79. setDasharray() {
  80. this.$.css('stroke-dasharray', `${this.length} ${this.length + 2}`);
  81. return this;
  82. }
  83. offset(ratio) {
  84. this.$.css('stroke-dashoffset', -this.length * ratio );
  85. return this;
  86. }
  87. makeVisible() {
  88. this.$.css('visibility', 'visible');
  89. return this;
  90. }
  91. }
  92. $(document).ready(() => {
  93. for (let i = 0; i < document.querySelectorAll(fprintPathSelector).length; i++) {
  94. fprintPaths.push(new Path(fprintPathSelector, i));
  95. fprintPaths[i].offset(-1).makeVisible();
  96. }
  97. //window.requestAnimationFrame(fprintFrame);
  98. })