thenikso / angular-inview

AngularJS directive to check if a DOM element is in the browser viewport.
http://thenikso.github.io/angular-inview/
MIT License
480 stars 112 forks source link

Callback not called when the element become invisible due a dynamic ng-repeat on top of it #101

Closed GMaxera closed 8 years ago

GMaxera commented 8 years ago

Hello, thanks for your directive. I'm using on my website and I found that the callback is not triggered in the case the element change it's visibility because has been moved down by a dynamic ng-repeat.

This is the code of my website:

    <div class="stream-items-container" in-view-container>
        <div ng-repeat="item in streamResults" class="stream-item" flex>
        Content of one element of the ng-repeat
        </div>
        <div class="stream-item" in-view="inViewChange($inview)" flex>
            <div class="ui active indeterminate loader" ng-show="loadingResults"></div>
        </div>
    </div>

The streamResults array change due to ajax request and increase of its size gradually. So, suppose the following scenario:

At this moment, if I scroll the browser windows even of 1 pixel then the inViewChange will be called with $inview == false

Is it a bug ... or I'm doing something wrong on using in-view ?

GMaxera commented 8 years ago

Sorry, I can't find a way to properly format the html snippet :-(

GMaxera commented 8 years ago

I found a solution by myself. I saw that the in-view is update if I trigger the 'checkInView' event. So, everytime I update the streamResults I'll fire the 'checkInView' event ... and I get my expceted results.

thenikso commented 8 years ago

great! good job