3
I’m needing to create an effect on my slideshow that for each image, the background of div
color change according to the predominant color of the same. I searched the internet for a plugin that does this, and found the Adaptive.Background.js
.
Overall it works perfectly, the only problem is that the background color does not update according to the passing of the slides, it changes in the first act and does not exchange more. For the slider, I’m using the plugin bxslider
.
::::: HTML by Slider
<div class="banner" id="tween-banner">
<div class="wrapp">
<ul class="bxslider">
<li><img src="image1.jpg" alt="Nome 1" /></li>
<li><img src="image2.jpg" alt="Nome 2" /></li>
</ul>
</div>
</div>
:::: jQuery
SC('.bxslider').bxSlider({
auto:true,
easing:'easeInOutCubic',
useCSS:false,
speed: 1000
})
Does anyone have any suggestions?
An alternative that I thought is to insert the color manually for each image. Example:
<img src="imagem1.jpg" setcolor="#666333" />
<img src="imagem2.jpg" setcolor="#FF0033" />
In that, I would perform one jQuery
that took the value setcolor
and applied as background in div
. But I don’t have much knowledge of how I can create this variable within the <img>
.
Ricardo, can you put the code you already have? So we can help you with what is failing. In HTML you can use
data-color="#666333"
and in jQuery use the.data()
, ie$(img).data('color')
to read, and$(img).data('color', '#123456')
to assign new color.– Sergio
Great! I didn’t know this one
data-color
. Now I need to identify what the current slide is, so he can take this attribute and apply it tobackground
of the div.– Ricardo
I think you need to take a look at the option
onSlideNext
this page: http://bxslider.com/options– Sergio
Stackfiddle is already working (Featuring: JS, CSS and HTML executables!), see the problem live and right here is always cool :)
– brasofilo
They could put visible examples to better understand on the bxSlider website. :\
– Ricardo
I got it, @Sergio :D like you told me.
– Ricardo