ProcessFlow.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import React, { useEffect, useState } from 'react';
  2. // import { Flex } from 'antd';
  3. import '../asstes/css/ProcessFlow.css'
  4. import img1 from '../asstes/img/cocopi1.png'
  5. import img2 from '../asstes/img/cocopi2.png'
  6. import img3 from '../asstes/img/cocopi3.png'
  7. import img4 from '../asstes/img/cocopi4.png'
  8. function ProcessFlow() {
  9. const [scrollValue, setscrollValue] = useState(0)
  10. const handleScroll = e => {
  11. let val = parseInt(e.target.scrollTop/700)
  12. setscrollValue(val)
  13. }
  14. useEffect(() => {
  15. document.getElementById("anchor_right").addEventListener('scroll', handleScroll);
  16. return () => {
  17. document.getElementById("anchor_right").removeEventListener('scroll', handleScroll);
  18. };
  19. }, []);
  20. const ScrollVal = (val)=>{
  21. setscrollValue(val)
  22. document.getElementById("anchor_right").scrollTop = val*700
  23. }
  24. return (
  25. <div className='ProcessFlow'>
  26. <h1>產品特點</h1>
  27. <div className='anchor'>
  28. <div className='anchor_flex'>
  29. <div className='anchor_left'>
  30. <div onClick={()=>ScrollVal(0)} className={scrollValue === 0 && "anchor_left_div"}>
  31. <span>高性價比</span><br />
  32. <span>Economical Choice</span>
  33. </div>
  34. <div onClick={()=>ScrollVal(1)} className={scrollValue === 1 && "anchor_left_div"}>
  35. <span>高集成度</span><br />
  36. <span>Highly Integrated</span>
  37. </div>
  38. <div onClick={()=>ScrollVal(2)} className={scrollValue === 2 && "anchor_left_div"}>
  39. <span>易用性</span><br />
  40. <span>Usability</span>
  41. </div>
  42. <div onClick={()=>ScrollVal(3)} className={scrollValue === 3 && "anchor_left_div"}>
  43. <span>開放性</span><br />
  44. <span>Openness</span>
  45. </div>
  46. </div>
  47. <div className='anchor_right' id='anchor_right'>
  48. <div id='aaa' style={{ width: "100%" }}>
  49. <img src={img1} alt='' />
  50. </div>
  51. <div id='bbb' style={{ width: "100%" }}>
  52. <img src={img2} alt='' />
  53. </div>
  54. <div id='ccc' style={{ width: "100%" }}>
  55. <img src={img3} alt='' />
  56. </div>
  57. <div id='ddd' style={{ width: "100%" }}>
  58. <img src={img4} alt='' />
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. )
  65. }
  66. export default ProcessFlow