Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

change styles when element enters viewport

const observer = new IntersectionObserver(entries => {
  entries.forEach(entry => {
    const square = entry.target.querySelector('.square');

    if (entry.isIntersecting) {
      square.classList.add('square-animation');
	  return; // if we added the class, exit the function
    }

    // We're not intersecting, so remove the class!
    square.classList.remove('square-animation');
  });
});

observer.observe(document.querySelector('.square-wrapper'));
Comment

PREVIOUS NEXT
Code Example
Javascript :: create text editor with react-redux 
Javascript :: does json only support ascii 
Javascript :: using .indexOf() in jShell 
Javascript :: js last element of array 
Javascript :: json object get field with at symbol 
Javascript :: regex pater for only 4 or 6 digits 
Javascript :: how to send an embed message discord.js 
Javascript :: regex to match empty string 
Javascript :: how to get dynamically generated id in javascript 
:: check if character is a letter 
Javascript :: javascript get element by class name change style 
Javascript :: popup alert in flutter 
Javascript :: create folder by commend line 
Javascript :: @jsonignore unrecognized field 
Javascript :: get all input values by class jquery 
:: javascript generate a random number between two numbers thats not 1 
Javascript :: javascript convert to two decimal places 
Javascript :: react native get route name 
Javascript :: start peerjs server 
Javascript :: js vanilla when i remove one object it removes all of them 
Javascript :: mongoDb Importar json para DataBase 
Javascript :: classlist has class 
Javascript :: js insert string at position 
Javascript :: jquery datepicker re initialize 
Javascript :: how to pass an object directly to formdata in javascript 
Javascript :: javascript loop through object array 
Javascript :: como actualizar node en windows 
Javascript :: getting data from firestore using async await 
Javascript :: unexpected token. did you mean `{'}` or `>`? react 
Javascript :: js character certain count 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =