scrollmonitor icon indicating copy to clipboard operation
scrollmonitor copied to clipboard

IsFullyEntered is triggered on DomContentLoaded for all items regardless of their state

Open Externaluse opened this issue 5 years ago • 0 comments

Initialising a monitor on DomContentLoaded the state is correctly identified in stateChange. However, adding a callback for fullyEnterViewport is also triggered for each item. I would have expected that to fire only for items actually moving into the viewport. Illustrated here, with console output: https://jsfiddle.net/ExternalUse/17wL9pxv/9/

In entryChangeState, this produces correct results: `else if (this.isFullyInViewport):

guid1is correctly considered fully entered here guid2is correctly considered fully entered here for the fullyEnteredCallback function entryFullyEnterViewport() { console.log(this.watchItem.id + " may to be incorrectly considered fully entered, this.isFullyInViewport is " + this.isFullyInViewport); } this is produced: guid1 may to be incorrectly considered fully entered, this.isFullyInViewport is true guid2 may to be incorrectly considered fully entered, this.isFullyInViewport is false guid3 may to be incorrectly considered fully entered, this.isFullyInViewport is false guid4 may to be incorrectly considered fully entered, this.isFullyInViewport is false ` ...

It's also slightly weird that in stateChange, guid1 and 2 are caught by fullyEntered; in the fullyEntered callback only guid1 has isFullyInViewport == true.

Also, for the first element (guid1) the log message is produced twice.

I'm probably missing a trick, could you possibly help, please? Thank you very much.

Externaluse avatar Apr 30 '20 11:04 Externaluse