css div background image loading

Solutions on MaxInterview for css div background image loading by the best coders in the world

showing results for - "css div background image loading"
Tommaso
26 Nov 2016
1if (settings.appear) {
2    var elements_left = elements.length;
3    settings.appear.call(self, elements_left, settings);
4}
5var loadImgUri;
6if($self.data("background"))
7    loadImgUri = $self.data("background");
8else
9    loadImgUri  = $self.data(settings.data_attribute);
10
11$("<img />")
12    .bind("load", function() {
13        $self
14            .hide();
15        if($self.data("background")){
16            $self.css('backgroundImage', 'url('+$self.data("background")+')');
17        }else
18            $self.attr("src", $self.data(settings.data_attribute))
19
20        $self[settings.effect](settings.effect_speed);
21
22        self.loaded = true;
23
24        /* Remove image from array so it is not looped next time. */
25        var temp = $.grep(elements, function(element) {
26            return !element.loaded;
27        });
28        elements = $(temp);
29
30        if (settings.load) {
31            var elements_left = elements.length;
32            settings.load.call(self, elements_left, settings);
33        }
34    })
35    .attr("src", loadImgUri );
36}
37