vvo / in-viewport

Get a callback when any element becomes visible in a viewport (body or custom viewport)
MIT License
276 stars 24 forks source link

Getting some sort of infinite loop/error with compareDocumentPosition #17

Closed adamgins closed 8 years ago

adamgins commented 8 years ago

Any ideas pls?

screen shot 2016-08-23 at 10 15 26 pm
tzi commented 8 years ago

Do you have any code to share?

adamgins commented 8 years ago

This is inside a Meteor onRendered which is equivalent to a document.onReady:

   var self = this;
    var inViewport = require('in-viewport');
    var intialRender = true;

    self.autorun(function () {
        if (!Template.currentData()){
            return;
        }

        var elem = document.getElementById(self.data._id);

        inViewport(elem, visible);

        function visible(elt) {
            // elt === elem
            if (intialRender){
              //do something
                intialRender = false;
            }

        }

    })

I don't getthis error on my local server, only on the test server on the net

adamgins commented 8 years ago

I think I have this sorted. It was related to Meteor

thanks for the quick response