File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed
Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change 1- export const getPadding = aspectRatio => {
1+ export const getPadding = ( aspectRatio : string ) => {
22 const config = {
33 '1:1' : `padding-top: 100%;` ,
44 '16:9' : `padding-top: 56.25%;` ,
Original file line number Diff line number Diff line change 11// Thanks Lihau https://www.youtube.com/watch?v=1SKKzdHVvcI&t=182s
22
3- let intersectionObserver
3+ let intersectionObserver : IntersectionObserver
44
55function ensureIntersectionObserver ( ) {
66 if ( intersectionObserver ) return
77
8- intersectionObserver = new IntersectionObserver ( entries => {
9- entries . filter ( ( { isIntersecting} ) => isIntersecting ) . forEach ( entry => {
10- entry . target . dispatchEvent ( new CustomEvent ( 'enterViewport' ) )
11- } )
12- } , {
13- rootMargin : "1000px"
14- } )
8+ intersectionObserver = new IntersectionObserver (
9+ entries => {
10+ entries
11+ . filter ( ( { isIntersecting } ) => isIntersecting )
12+ . forEach ( entry => {
13+ entry . target . dispatchEvent ( new CustomEvent ( 'enterViewport' ) )
14+ } )
15+ } ,
16+ {
17+ rootMargin : '1000px' ,
18+ }
19+ )
1520}
1621
17- export default function viewport ( element ) {
22+ export default function viewport ( element : Element ) {
1823 ensureIntersectionObserver ( )
1924
2025 intersectionObserver . observe ( element )
You can’t perform that action at this time.
0 commit comments