klaudiusmarkus

Praktical React part 2

Apr 20th, 2019 (edited)
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. https://github.com/callmecavs/jump.js - Dugme da skaces sa dela na deo sajta, npm instal, ukljucis i biras opcije
  2. https://html5up.net/ - Dobri template sajtovi
  3.  
  4.  
  5. ---------------------------------------------------------------------------------------------------------------------------------------
  6. **************************************************************************************************************************************
  7. 1. Scroll Indicator
  8.  
  9.  
  10. clientHeight: The size of the element client area, which refers to the size of the element and the size of the space occupied by the frame (mostly the viewport size is taken out by practice)
  11. scrollHeight: The scroll size, which refers to the size of the element containing the scrolling content (the total height of the element content)
  12. offsetHeight: The offset containing all the visible space used by the element on the screen (including all padding scroll bars and border sizes, excluding margins)
  13. offsetTop: the distance from the top of the parent element at the top of the current element,
  14.  
  15. const onScroll = () =>{
  16.  
  17.  
  18. const windowScroll = document.documentElement.scrollTop
  19.  
  20. const height= document.documentElement.scrollHeight - document.documentElement.clientHeight (viewport size)
  21.  
  22. const scrolled = (windowScroll / height) * 100
  23.  
  24.  
  25. setScrollTop(scrolled)
  26. }
  27.  
  28.  
  29. useEffect(()=>{
  30.  
  31. window.addEventListener('scroll', onScroll)
  32.  
  33.  
  34. return () => window.removeEventListener('scroll', onScroll)
  35.  
  36.  
  37. },[])
  38. <div className='progress-wrapper'>
  39. <div className='progress-style' style={{width:`${scrollTop}%`}}></div>
  40. </div>
  41.  
  42. progress-wrapper obavezno da bude position:stickey, top:0; left:0; width:100%;
  43. ---------------------------------------------------------------------------------------------------------------------------------------
  44. ***************************************************************************************************************************************
  45. 2. Kretanje po dokumentu do bilo koje pozicije
  46.  
  47. *useRef samo preko ref={elementPositon} postavis bilo gde na ekranu
  48.  
  49. *const goToSection = () => {
  50. window.scrollTo({ top: elementPosition.current.offsetTop, behavior:'smooth' });
  51. };
  52.  
  53. * das dugmetu ili linku gde hoces da ides i kreces se
  54.  
  55. ---------------------------------------------------------------------------------------------------------------------------------------
  56. ***************************************************************************************************************************************
  57. 2. Mapbox veciti problem
  58.  
  59. @solarstar101 what solutions haven't worked? I'm using @zacharyliu's fix with CRA and it works:
  60.  
  61. import mapboxgl from "mapbox-gl/dist/mapbox-gl";
  62. mapboxgl.workerClass = require("worker-loader!mapbox-gl/dist/mapbox-gl-csp-worker").default;
  63. I added this in the very root of my app- one of the first files that loads.
  64.  
  65. This required adding the extra NPM package:
  66.  
  67. "worker-loader": "3.0.8"
  68. ---------------------------------------------------------------------------------------------------------------------------------------
  69. ***************************************************************************************************************************************
Add Comment
Please, Sign In to add comment