kennethcachia / background-check

Automatically switch to a darker or a lighter version of an element depending on the brightness of images behind it.
http://kennethcachia.com/background-check/
MIT License
3.27k stars 282 forks source link

Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null #36

Closed sabmah closed 10 years ago

sabmah commented 10 years ago

I have been getting this javascript error. I addition to background check plugin, I also have a backstrech pluging for full background with slides.

   $.backstretch(homeGalleryImgs, {
        fade: 'slow',
        duration:5000
    });
    BackgroundCheck.init({
        threshold:30,
        targets: '.home-title',
        images: '.backstretch >img'
    })

EDIT: FIXED! I put the BackgroundCheck.init() inside the event of backstrech.after. And then backgroundCheck.refresh() after that. It works now.

  $(window).on("backstretch.after", function (e, instance, index) {
        BackgroundCheck.init({
            targets: '.home-title',
            images: '.backstretch >img'
        })
        BackgroundCheck.refresh();
    });
kennethcachia commented 10 years ago

Awesome!