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 :: generate random date in a range 
Javascript :: jquery datepicker set year range 
Javascript :: clear input from file vue 
Javascript :: jquery loop each tr in table grepper 
Javascript :: javascript regex test number only 
Javascript :: uuid use in express 
Javascript :: getelementbytagname javascript 
Javascript :: gettype js 
Javascript :: confirm before leaving page javascript 
Javascript :: function sytax js 
Javascript :: convert buffer to base64 javascript 
Javascript :: check if mobile view javascript 
Javascript :: javascript separate words by capital letter 
Javascript :: js push into array if item exist 
Javascript :: uselocation hook 
Javascript :: socket io broadcast to room 
Javascript :: jquery to another page 
Javascript :: javascript format date yyyy-mm-dd 
Javascript :: convert string to datetime javascript 
Javascript :: toggle multiple classes jquery 
Javascript :: jquery select element based on for attribute 
Javascript :: vue htmlWebpackPlugin.options.title 
Javascript :: javascript regex vowel 
Javascript :: public class NameOf { public static String nameof<T(Expression<Func<T name) { MemberExpression expressionBody = (MemberExpression)name.Body; return expressionBody.Member.Name; } } 
Javascript :: javascript fetch post form data 
Javascript :: date to seconds js 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =