oracle-samples / xfc

A javascript library for Cross Frame Communication
Apache License 2.0
17 stars 24 forks source link

Slow loading images not accounted for in resize calculation #35

Closed mhemesath closed 5 years ago

mhemesath commented 5 years ago

Description of Issue

Slow loading images mess up the resize logic. If an image takes longer to load than than it takes for the Provider to trigger resize, the image won't be accounted for in the resize calculation. When the image does finally load, the iframe will be too small.

I think the Provider needs to add an event handler to trigger resize logic whenever an image loads

document.body.addEventListener(
    'load',
    function(event){
        var tgt = event.target;
        if( tgt.tagName == 'IMG'){
            this.requestResize()
        }
    },
    true
)

usecapture is required because image load events don't bubble.