Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
1
Indexable
Never
<!DOCTYPE html>
<html>
<head>
    <title>Lazy Loading with Flask and JavaScript</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <style>
        .card {
            width: 18rem;
            margin-right: 1rem;
            margin-bottom: 1rem;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="row" id="card-container"></div>
    </div>
    <script>
        $(function() {
            // İlk 10 kartı yükle
            loadCards(0, 10);

            // Sayfa aşağı kaydırıldıkça daha fazla kart yükle
            var isLoading = false;
            $(window).scroll(function() {
                if ($(window).scrollTop() + $(window).height() >= $(document).height() - 100 && !isLoading) {
                    isLoading = true;
                    var startIndex = $('#card-container .card').length;
                    loadCards(startIndex, 10, function() {
                        isLoading = false;
                    });
                }
            });
        });
    </script>
</body>
</html>