Things are easier :)
Just use conditional CSS based on the class fullpage.js adds to your body
element. (fp-viewing-section-slide
). If you need more information about it you can check this video where it is explained with more detail.
For example:
.fp-viewing-secondPage-0 #slide2{
background-image:url(produtos/002.jpg)
}
.fp-viewing-3rdPage .section{
background-image:url(produtos/1.jpg)
}
This way the background image will only be loaded when the section enters in the viewport.
Another way of doing it is by using the active
class added to the section or slide you are in:
#slide2.active{
background-image:url(produtos/002.jpg)
}
.section.active{
background-image:url(produtos/1.jpg)
}
Or you can even decide to preload the backgruonds of all the slides within a section when arriving to the section itself (rather than to the specific slide) by doing this:
.section.active #slide2{
background-image:url(produtos/2.jpg)
}
.section.active #slide3{
background-image:url(produtos/3.jpg)
}
.section.active #slide4{
background-image:url(produtos/4.jpg)
}