0

I want it so that either on a slider or scroll down over differently colored backgrounds, the text logo would change to be readable over the background. I imagine this could be done by finding the dominant image color, but this would be slow and seems overkill. Is there an alternative?

Some effects I saw in the wild:

Would the best way to do this (for a slider) just to make an array of colors on each slide?

Ki v2
  • 46
  • 9
rawsh
  • 395
  • 5
  • 21

3 Answers3

1

The way that Google Home work is, change the class of the main div on the slider change event so that it can change the color of the text also. It already pre defined the color of the text according to the color of the image and i think it is the best way for your case. You can reduce a lot of calculation and can adjust the color of the text easily.

Mg Thar
  • 1,084
  • 8
  • 24
0

I don't know exacly what do you mean, but if you want to change anything of html dom when you are scrolled bottom of the page, You must write your javascript code for jquery scoll event if you are using scroll page

$(document).scroll(function(){
if($(window).scrollTop() + $(window).height() >= $(document).height()) { //if user scrolled to bottom of the page
   //type executing statement here
}
});
Sidath
  • 98
  • 10
-1
$(document).ready(function(){       
    var scroll_pos = 0;
    $(document).scroll(function() { 
        scroll_pos = $(this).scrollTop();
        if(scroll_pos > 210) {
            $("body").css('background-color', 'blue');
        } else {
            $("body").css('background-color', 'red');
        }
    });
});

Some resources to animate the background colors( make some transition between then). Here

Community
  • 1
  • 1
Yuri Pereira
  • 1,945
  • 17
  • 24