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 281 forks source link

BackgroundCheck.refresh() refreshing but not updating class #61

Open cgrant992 opened 9 years ago

cgrant992 commented 9 years ago

I'm using this plugin with the jQuery Revolution slider and am having problems getting the refresh to work correctly on new slides. It seems that it is refreshing, but it's not adding the correct background class. Here's the code I have:

document.addEventListener('DOMContentLoaded', function() {
  var img = document.querySelector('.tp-bgimg');
  img.setAttribute('crossorigin', '');
  img.src = img.getAttribute('src');

  // Prepare BackgroundCheck
  BackgroundCheck.init({
    targets: '#navigation ul li a',
    images: img
  });

  revapi1.bind("revolution.slide.onchange", function(e) {
    BackgroundCheck.refresh();
  });
});

Any idea why it's not working correctly? Seems it's only finding the first slide. When I view the developer tool in Chrome it shows it's not affecting the other slides, so it's only refreshing for the first slide. Could that be because RevSlider adds that code through JS instead of HTML?

zigmasdirigeant commented 8 years ago

I'm having the same tragedy with revolution slider... And I can't find a way to achive it.

¿Did you found it in the end?

krembo99 commented 8 years ago

Same problem here without any slider ... Just a normal dynamic div ( hamburger menu ) . Can not refresh when menu appears .