section1.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div class="section section1">
  3. <canvas class="canvas" id="canvas-section-1" v-show="isShowCanvas"></canvas>
  4. <process-bar :process="process" />
  5. <div
  6. class="can-scroll scroll-bar-1"
  7. style=""
  8. @scroll.capture="onPlayerScroll($event, 1)"
  9. >
  10. <div
  11. style="width: 100%; height: 14000px"
  12. class="scroll-bar-1-placeholder"
  13. ></div>
  14. </div>
  15. </div>
  16. </template>
  17. <script setup>
  18. import { onMounted, onUnmounted, ref, inject, watchEffect, 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 fullpage = inject("fullpage");
  24. const isShowCanvas = ref(false);
  25. const handler = ({ index: currentIndex, nextIndex }) => {
  26. const { index } = nextIndex;
  27. const { index: pre } = currentIndex;
  28. const player = usePlayer();
  29. if (index === 0) {
  30. fullpage.value.api.setAllowScrolling(false);
  31. player.enableScroll(1);
  32. if (pre === 1) {
  33. console.log("autoplay");
  34. // player.autoPlay(0, 60);
  35. }
  36. isShowCanvas.value = true;
  37. } else {
  38. player.unEnableScroll();
  39. isShowCanvas.value = false;
  40. fullpage.value.api.setAllowScrolling(true);
  41. }
  42. };
  43. const process = ref(0);
  44. onMounted(() => {
  45. if (isMobile()) {
  46. var vcon = new window.VConsole();
  47. }
  48. emitter.on("onLeave", handler);
  49. emitter.on("loaded", () => {
  50. const player = usePlayer();
  51. if (isMobile()) {
  52. console.log("fitToSection1");
  53. fullpage.value.api.fitToSection();
  54. }
  55. setTimeout(() => {
  56. isShowCanvas.value = true;
  57. fullpage.value.api.setAllowScrolling(false);
  58. player.enableScroll(1);
  59. // player.autoPlay(0, 16);
  60. }, 500);
  61. player.on("process", (p) => {
  62. process.value = p.process;
  63. });
  64. player.on("scroll-prev", (type) => {
  65. if (type === 2) {
  66. fullpage.value.api.moveSectionUp();
  67. }
  68. });
  69. player.on("scroll-next", (type) => {
  70. if (type === 2) {
  71. fullpage.value.api.moveSectionDown();
  72. }
  73. });
  74. });
  75. // player.on("loaded", () => {
  76. // console.log("所有图片完成");
  77. // });
  78. // player.on("loadPress", (p) => {
  79. // // console.log(`加载`, p);
  80. // emitter.emit("updatePress", p);
  81. // });
  82. });
  83. onUnmounted(() => {
  84. emitter.off("onLeave", handler);
  85. });
  86. const onPlayerScroll = (event, type) => {
  87. // console.log("onPlayerScroll");
  88. const player = usePlayer();
  89. player.manualScroll(event, type);
  90. };
  91. </script>
  92. <style lang="scss" scoped>
  93. @import "/src/assets/style/index.scss";
  94. .canvas {
  95. position: absolute;
  96. top: 0;
  97. z-index: 0;
  98. }
  99. .can-scroll {
  100. // background: white;
  101. width: 100%;
  102. overflow-y: scroll;
  103. position: relative;
  104. overflow-x: hidden;
  105. z-index: 10;
  106. }
  107. .section {
  108. position: relative;
  109. }
  110. .section1 {
  111. display: flex;
  112. flex-flow: column;
  113. align-items: center;
  114. line-height: 2;
  115. color: #997946;
  116. justify-content: center;
  117. background: url(/img/canvas/hua-3/0000.webp) no-repeat center/cover;
  118. -webkit-box-pack: center;
  119. -ms-flex-pack: center;
  120. -webkit-box-align: center;
  121. -ms-flex-align: center;
  122. .wwmap {
  123. position: absolute;
  124. top: 5vh !important;
  125. right: 5vw;
  126. left: auto;
  127. width: auto !important;
  128. text-align: right;
  129. }
  130. }
  131. </style>