Nairo05

JS Scalieren

Apr 9th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Per hand geschrieben, garantiere keine 100% tige Richtigkeit
  2. let width = document.getElementById("width");
  3. let hight = document.getElementById("height");
  4. let action = document.getElementById("actions");
  5. let delay = 250;          
  6. let throttled = false;
  7. action = 0;
  8.  
  9. //unnötige scheiße die vorrausgestezt ist .....
  10. function getDimensions() {
  11.   width.innerHTML = window.innerWidth;
  12.   hight.innerHTML = window.innerHeight;
  13.   action += 1;
  14.   actions.innerHTML = action;
  15. }
  16.  
  17. //sobald das fenster die größe ändert, führe aus:
  18. window.addEventListener('resize', function() {
  19.   if (!throttled) {    
  20.     getDimensions();     // muss da ahin
  21.    
  22.     // was du machen willst hier hin
  23.  
  24.     if([width / height] [< / > / <= / ==] [WERT]){
  25.          document.getElementById("wat weg soll").style.width = "0px"; // Zum verschwinden einfach width und hight auf null setzten
  26.          document.getElementById("wat weg soll").style.height = "0px";
  27.     }
  28.  
  29.     //----------------
  30.  
  31.  
  32.     throttled = true;    // must be ... einfach hinschreiben und net fragen
  33.    
  34.     setTimeout(function() {  //falls ein fehler kommt.... muss da hin
  35.       throttled = false;
  36.     }, delay);
  37.   }  
  38. });
Add Comment
Please, Sign In to add comment