hjyd
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.

202 lines
6.1 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. const scaleFunc = (id, scale) => {
  2. if (['#case_detail_container', '#hardware_detail_container'].includes(id)) {
  3. document.querySelector(id).style['transform-origin'] = 'center top'
  4. } else {
  5. document.querySelector(id).style['transform-origin'] = 'center center'
  6. }
  7. document.querySelector(id).style.transform = `scale(${scale})`
  8. handleBottomFont(id, scale)
  9. handleImgScale(id, scale)
  10. handleCooperation(id, scale)
  11. handleContactUs(id, scale)
  12. handleSwiper(id, scale)
  13. }
  14. export const handleScreenAuto = id => {
  15. const designDraftWidth = 1920 //设计稿的宽度
  16. const designDraftHeight = 1080 //设计稿的高度
  17. //根据屏幕的变化适配的比例
  18. let scale = 1
  19. if (document.documentElement.clientWidth > designDraftWidth) {
  20. document.documentElement.clientWidth /
  21. document.documentElement.clientHeight <
  22. designDraftWidth / designDraftHeight
  23. ? 1
  24. : document.documentElement.clientHeight / designDraftHeight
  25. } else {
  26. scale =
  27. document.documentElement.clientWidth /
  28. document.documentElement.clientHeight <
  29. designDraftWidth / designDraftHeight
  30. ? document.documentElement.clientWidth / designDraftWidth
  31. : document.documentElement.clientHeight / designDraftHeight
  32. }
  33. // if (document.querySelector(id)) {
  34. // const divWidth = document.querySelector(id).style.width * scale
  35. // const divHeight = document.querySelector(id).style.height * scale
  36. // if (divWidth > document.documentElement.clientWidth) {
  37. // scale = document.documentElement.clientHeight / 1200
  38. // }
  39. // if (divHeight > document.documentElement.clientHeight) {
  40. // scale = document.documentElement.clientWidth / 2020
  41. // }
  42. // if (
  43. // divWidth > document.documentElement.clientWidth &&
  44. // divHeight > document.documentElement.clientHeight
  45. // ) {
  46. // scale = document.documentElement.clientHeight / 1200
  47. // }
  48. // }
  49. scaleFunc(id, scale)
  50. }
  51. const handleBottomFont = (id, scale) => {
  52. if (id == '#service_container') {
  53. document.getElementById('bottom_container').style.transform = `scaleX(${
  54. 1 / scale
  55. })`
  56. document.getElementById(
  57. 'bottom_font_save',
  58. ).style.transform = `scale(${scale})`
  59. }
  60. }
  61. const handleImgScale = (id, scale) => {
  62. if (id == '#culture_container') {
  63. document.getElementById('bg_img_scale').style.transform = `scale(${
  64. 1 / scale
  65. })`
  66. }
  67. }
  68. const handleContactUs = (id, scale) => {
  69. if (id == '#contractus_container') {
  70. document.getElementById('contact_circle').style.transform = `scale(${
  71. 1 / scale
  72. })`
  73. document.getElementById('contact_hand').style.transform = `scale(${
  74. 1 / scale
  75. })`
  76. }
  77. }
  78. const handleSwiper = (id, scale) => {
  79. if (id == '#case_picture') {
  80. document.querySelector('#wrapper_case_picture_id').style[
  81. 'transform-origin'
  82. ] = 'center top'
  83. document.getElementById(
  84. 'wrapper_case_picture_id',
  85. ).style.transform = `scale(${1 / scale})`
  86. }
  87. if (id == '#hardware_picture_list') {
  88. document.querySelector('#hardware_swiper_scale_id').style[
  89. 'transform-origin'
  90. ] = 'center top'
  91. document.getElementById(
  92. 'hardware_swiper_scale_id',
  93. ).style.transform = `scale(${1 / scale})`
  94. }
  95. }
  96. const handleCooperation = (id, scale) => {
  97. if (id == '#cooperation_container') {
  98. document.getElementById('contract_bg_coop').style['transform-origin'] =
  99. 'center 0'
  100. document.getElementById('contract_bg_coop').style.transform = `scale(${
  101. 1 / scale
  102. })`
  103. document.getElementById('contract_real_coop').style['transform-origin'] =
  104. 'center 0'
  105. document.getElementById(
  106. 'contract_real_coop',
  107. ).style.transform = `scale(${0.8})`
  108. }
  109. }
  110. export const animateCSS = (element, animation, prefix = 'animate__') =>
  111. // We create a Promise and return it
  112. new Promise((resolve, reject) => {
  113. const animationName = `${prefix}${animation}`
  114. const node = document.querySelector(element)
  115. node?.classList.add(`${prefix}animated`, animationName)
  116. // When the animation ends, we clean the classes and resolve the Promise
  117. function handleAnimationEnd(event) {
  118. event.stopPropagation()
  119. node?.classList.remove(`${prefix}animated`, animationName)
  120. resolve('Animation ended')
  121. }
  122. node?.addEventListener('animationend', handleAnimationEnd, {
  123. once: true,
  124. })
  125. })
  126. // 根据 activeIndex 判断激活哪个元素的动画
  127. export const totalPageAni = async (activeIndex, previousIndex) => {
  128. const isDown = previousIndex < activeIndex
  129. const aniName = isDown ? 'fadeInUp' : 'fadeInDown'
  130. if (activeIndex == 1) {
  131. animateCSS('#servive_big_title_ani', aniName)
  132. }
  133. if (activeIndex == 2) {
  134. animateCSS('#cooperation_ani', aniName)
  135. }
  136. if (activeIndex == 3) {
  137. animateCSS('#case_picture_list_ani', aniName)
  138. }
  139. if (activeIndex == 5) {
  140. animateCSS('#contract_ani', aniName)
  141. }
  142. if (activeIndex == 7) {
  143. animateCSS('#software_b_ani', aniName)
  144. animateCSS('#software_c_ani', aniName)
  145. }
  146. if (activeIndex == 8) {
  147. animateCSS('#hardware_detail_ani', aniName)
  148. }
  149. if (activeIndex == 9) {
  150. animateCSS('#webofthing_ani', aniName)
  151. animateCSS('#webofthing_img_ani', aniName)
  152. }
  153. if (activeIndex == 10) {
  154. animateCSS('#mechanical_control_ani', aniName)
  155. }
  156. if (activeIndex == 11) {
  157. animateCSS('#mechanical_drive_ani', aniName)
  158. }
  159. if (activeIndex == 12) {
  160. animateCSS('#read_widely_ani', aniName)
  161. }
  162. if (activeIndex == 13) {
  163. animateCSS('#culture_ani', aniName)
  164. }
  165. if (activeIndex == 14) {
  166. animateCSS('#post_page_title_ani', aniName)
  167. }
  168. if (activeIndex == 16) {
  169. animateCSS('#contract_info_ani', aniName)
  170. animateCSS('#contact_hand', aniName)
  171. }
  172. }
  173. // export const totalTitleAni = (activeIndex, previousIndex) => {
  174. // if (activeIndex == 1) {
  175. // animateCSS('#main_img', 'fadeInUp')
  176. // animateCSS('#slide_five_desc_ani', 'fadeInUp')
  177. // }
  178. // if (activeIndex == 2) {
  179. // animateCSS('#slide_two_ani', 'fadeInDown')
  180. // }
  181. // if (activeIndex == 3) {
  182. // animateCSS('#slide_one_ani', 'fadeInDown')
  183. // }
  184. // if (activeIndex == 4) {
  185. // animateCSS('#slide_four_ani', 'fadeInDown')
  186. // }
  187. // if (activeIndex == 5) {
  188. // animateCSS('#slide_three_ani', 'fadeInDown')
  189. // }
  190. // }