Sree
Sree

Reputation: 584

ASP.NET Repeater loading image

In my application i used repeater control.For that i have loaded item at a time.But my client wants to display first 6 items then if the user come to end of the page it will display a image named loading image and after a short time display another 6 items and again the user came to end of page it will display loading image at the end of screen and load another 6 items like that and so on. ex:Facebook loading

Upvotes: 1

Views: 1196

Answers (1)

James Johnson
James Johnson

Reputation: 46047

It sounds like you need to use continuous scrolling, to load images as the user scrolls. Here are a couple of articles which demonstrate how to use continuous scrolling:

http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=371

http://www.webresourcesdepot.com/load-content-while-scrolling-with-jquery/

Here's an example of an image gallery that uses continuous scrolling:

<!DOCTYPE html>
<html>
<head>
  <style type="text/css" >
    div { border: solid 1px black; height:200px; }
  </style>
  <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
    <script type="text/javascript">
        var pixelsBetweenImages = 200;
        var imagesArray = {}
        var imagesArray = new Array(); // regular array (add an optional integer argument to control array's size)
        imagesArray[0] = "";
        imagesArray[1] = "";
        imagesArray[2] = "";
        imagesArray[3] = "/images/ImageThree.gif";
        imagesArray[4] = "/images/ImageFour.gif";
        imagesArray[5] = "/images/ImageFive.gif";
        imagesArray[6] = "/images/ImageSix.gif";
        imagesArray[7] = "/images/ImageSeven.gif";
        imagesArray[8] = "/images/ImageEight.gif";

        $(window).scroll(function() {
            var scrollpos = $(window).scrollTop() + $(window).height();
            var imageIndex = Math.floor(scrollpos / pixelsBetweenImages);
            if (imagesArray[imageIndex] != "") {
                var div = $("#" + imageIndex);
                div.html(imagesArray[imageIndex]);
                imagesArray[imageIndex] = "";
            }

        });
    </script>

    <div>Visible on first load</div>
    <div>Visible on first load</div>
    <div>Visible on first load</div>
    <div id="3">3&nbsp;</div>
    <div id="4">4&nbsp;</div>
    <div id="5">5&nbsp;</div>
    <div id="6">6&nbsp;</div>
    <div id="7">7&nbsp;</div>
    <div id="8">8&nbsp;</div>

</body>
</html>

Source: Is there ability to load page images partially when scroll down to it or is it just effect?

As for displaying a loading image, just use an animated gif as the default image, and delay loading of the actual image for effect, using setTimeout or something along those lines.

Upvotes: 1

Related Questions