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.

97 lines
3.0 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
  1. export const handleScreenAuto = (showEmpty, id) => {
  2. const clientWidth = document.documentElement.clientWidth
  3. const clientHeight = document.documentElement.clientHeight
  4. if (clientWidth > 1600) {
  5. if (clientHeight < 1080) {
  6. const scale = clientHeight / 1080
  7. document.querySelector(id).style.transform = `scale(${scale})`
  8. handleBottomFont(id, scale)
  9. handleImgScale(id, scale)
  10. handleCooperation(id, scale)
  11. handleSwiper(id, scale)
  12. showEmpty.value = false
  13. } else {
  14. if (clientHeight >= 1764) {
  15. const scale = 1323 / clientHeight
  16. document.querySelector(id).style.transform = `scale(${scale})`
  17. handleBottomFont(id, scale)
  18. handleImgScale(id, scale)
  19. handleCooperation(id, scale)
  20. handleSwiper(id, scale)
  21. showEmpty.value = false
  22. } else {
  23. if (clientHeight >= 1323) {
  24. const scale = 1176 / clientHeight
  25. document.querySelector(id).style.transform = `scale(${scale})`
  26. handleBottomFont(id, scale)
  27. handleImgScale(id, scale)
  28. handleCooperation(id, scale)
  29. handleSwiper(id, scale)
  30. showEmpty.value = false
  31. } else {
  32. const scale = 1080 / clientHeight
  33. document.querySelector(id).style.transform = `scale(${scale})`
  34. handleBottomFont(id, scale)
  35. handleImgScale(id, scale)
  36. handleCooperation(id, scale)
  37. handleSwiper(id, scale)
  38. showEmpty.value = false
  39. }
  40. }
  41. }
  42. } else {
  43. showEmpty.value = true
  44. }
  45. }
  46. const handleBottomFont = (id, scale) => {
  47. if (id == '#service_container') {
  48. document.getElementById('bottom_container').style.transform = `scaleX(${
  49. 1 / scale
  50. })`
  51. document.getElementById(
  52. 'bottom_font_save',
  53. ).style.transform = `scale(${scale})`
  54. }
  55. }
  56. const handleImgScale = (id, scale) => {
  57. if (id == '#culture_container') {
  58. document.getElementById('bg_img_scale').style.transform = `scale(${
  59. 1 / scale
  60. })`
  61. }
  62. }
  63. const handleCooperation = (id, scale) => {
  64. if (id == '#cooperation_container') {
  65. document.getElementById('contract_bg_coop').style.transform = `scale(${
  66. 1 / scale
  67. })`
  68. document.getElementById(
  69. 'contract_real_coop',
  70. ).style.transform = `scale(${scale})`
  71. }
  72. }
  73. export const animateCSS = (element, animation, prefix = 'animate__') =>
  74. // We create a Promise and return it
  75. new Promise((resolve, reject) => {
  76. const animationName = `${prefix}${animation}`
  77. const node = document.querySelector(element)
  78. node?.classList.add(`${prefix}animated`, animationName)
  79. // When the animation ends, we clean the classes and resolve the Promise
  80. function handleAnimationEnd(event) {
  81. event.stopPropagation()
  82. node?.classList.remove(`${prefix}animated`, animationName)
  83. resolve('Animation ended')
  84. }
  85. node?.addEventListener('animationend', handleAnimationEnd, {
  86. once: true,
  87. })
  88. })
  89. // 根据 activeIndex 判断激活哪个元素的动画
  90. export const totalPageAni = () => {
  91. animateCSS('#a', 'bounce')
  92. }