section14-frame.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div class="section section14">
  3. <canvas
  4. class="canvas"
  5. id="canvas-section-14"
  6. v-show="isShowCanvas"
  7. ></canvas>
  8. <process-bar :process="process" />
  9. <div class="can-scroll scroll-bar-14" @scroll="onPlayerScroll($event, 14)">
  10. <div
  11. style="width: 100%; height: 14000px"
  12. class="scroll-bar-14-placeholder"
  13. ></div>
  14. </div>
  15. </div>
  16. </template>
  17. <script setup>
  18. import { onMounted, onUnmounted, ref, unref } from "vue";
  19. import processBar from "../components/processBar.vue";
  20. import { emitter } from "../emitter.js";
  21. import { usePlayer } from "../hooks/usecanvasPlayer.js";
  22. import { isMobile } from "../utils/isMoblie";
  23. const props = defineProps({
  24. fullpage: Object,
  25. });
  26. const isShowCanvas = ref(false);
  27. const handler = ({ index: currentIndex, nextIndex }) => {
  28. const { index } = nextIndex;
  29. const { index: pre } = currentIndex;
  30. const player = usePlayer();
  31. if (index === 13) {
  32. props.fullpage.api.setAllowScrolling(false);
  33. player.enableScroll(14);
  34. if (pre === 12) {
  35. console.log("autoplay");
  36. player.autoPlay(0, 60);
  37. }
  38. isShowCanvas.value = true;
  39. } else {
  40. player.unEnableScroll();
  41. isShowCanvas.value = false;
  42. props.fullpage.api.setAllowScrolling(true);
  43. }
  44. };
  45. const process = ref(0);
  46. onMounted(() => {
  47. emitter.on("onLeave", handler);
  48. emitter.on("loaded", () => {
  49. const player = usePlayer();
  50. player.on("process", (p) => {
  51. process.value = p.process;
  52. });
  53. player.on("scroll-prev", (type) => {
  54. if (type === 14) {
  55. props.fullpage.api.moveSectionUp();
  56. }
  57. });
  58. player.on("scroll-next", (type) => {
  59. if (type === 14) {
  60. props.fullpage.api.moveSectionDown();
  61. }
  62. });
  63. });
  64. });
  65. onUnmounted(() => {
  66. emitter.off("onLeave", handler);
  67. });
  68. const onPlayerScroll = (event, type) => {
  69. const player = usePlayer();
  70. player.manualScroll(event, type);
  71. };
  72. </script>
  73. <style lang="scss" scoped>
  74. @import "/src/assets/style/index.scss";
  75. .canvas {
  76. position: absolute;
  77. top: 0;
  78. z-index: 0;
  79. }
  80. .can-scroll {
  81. // background: white;
  82. width: 100%;
  83. overflow-y: scroll;
  84. position: relative;
  85. overflow-x: hidden;
  86. z-index: 10;
  87. }
  88. .section {
  89. position: relative;
  90. }
  91. .section14 {
  92. display: flex;
  93. flex-flow: column;
  94. align-items: center;
  95. line-height: 2;
  96. color: #997946;
  97. justify-content: center;
  98. background: url(/img/section2/bg.webp) no-repeat center/cover;
  99. }
  100. </style>