Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to change styles when element comes into view

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 :: diffrence b/w render and reload 
Javascript :: colors.xml" already exists! 
Javascript :: delete attribute javascript 
Javascript :: how to connect mongoose database with nodejs 
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 
Javascript :: check if character is a letter 
Javascript :: tagname js 
Javascript :: find missing number array javascript 
Javascript :: get value of datalist javascript 
Javascript :: textalign javascript 
Javascript :: @jsonignore unrecognized field 
Javascript :: detect mobile device 
Javascript :: javascript remove dom element 
Javascript :: stopped typing jquery 
Javascript :: usehistory example 
Javascript :: react native go to next text input 
Javascript :: angular int to string 
Javascript :: redirect angular 
Javascript :: javascript function that make a choice 
Javascript :: regex all starting with 
Javascript :: v-select on change 
Javascript :: ReferenceError: window is not defined 
Javascript :: valid phone number regex with country code 
Javascript :: javascript replace string 
Javascript :: javascript get name of element 
Javascript :: regex for yyyy-mm-dd 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =