We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

How can i get variable from js file?

Home Forums Programming How can i get variable from js file?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #54582
    keith
    Customer

    Trying to enable/disable render with IntersectionObserver.
    How can i get variable (render) from file?

    
    const options = {
        threshold : 0
    }
    
    let render;
    
    const callback = function( entries, observer ) {
    
        entries.forEach( entry => {
    
            const { isIntersecting } = entry;
    
            if( isIntersecting ) {
                render = 1
            } else {
                render = 0
            }
    
        } );
    
    }
    
    const observer = new IntersectionObserver( callback );
    
    const target = document.querySelector( '#target' );
    observer.observe( target );
    
    #54590
    kdv77kdv
    Participant

    where is your code located and from where you want to read render? if your .js is included in .html than you can read this variable from any other .js that is also included in .html…

    #54606
    keith
    Customer

    Done. Thanks for help.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.