From d2887597d103f492ef4c31b0dc7053dd40fafce3 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sun, 7 Mar 2021 10:19:02 +0100 Subject: [PATCH] Implemented basic endless scroll carousel slide show --- api.php | 4 ++++ index.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ script.js | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 api.php create mode 100644 index.php create mode 100644 script.js diff --git a/api.php b/api.php new file mode 100644 index 0000000..80b6e95 --- /dev/null +++ b/api.php @@ -0,0 +1,4 @@ + + + + + + + + + + + + Hello, world! + + + + +
+ +
+ + + + + + diff --git a/script.js b/script.js new file mode 100644 index 0000000..e1b6c54 --- /dev/null +++ b/script.js @@ -0,0 +1,54 @@ +jQuery(document).ready(function($){ + $('#mainCarousel').on('slide.bs.carousel', function (e) { + console.log(e.to); + if (e.to == 0) { + $('#mainCarousel .carousel-inner .carousel-item:last') + .remove(); + $.get('api.php', function(data) { + $('#mainCarousel .carousel-inner') + .prepend( + $('
') + .addClass('carousel-item') + .append($('') + .attr('src', data) + ) + ); + }); + } else if (e.to == 2) { + $('#mainCarousel .carousel-inner .carousel-item:first') + .remove(); + $.get('api.php', function(data) { + $('#mainCarousel .carousel-inner') + .append( + $('
') + .addClass('carousel-item') + .append($('') + .attr('src', data) + ) + ); + }); + } + }); + + $.get('api.php', function(data) { + $('#mainCarousel .carousel-inner') + .prepend( + $('
') + .addClass('carousel-item') + .append($('') + .attr('src', data) + ) + ); + }); + + $.get('api.php', function(data) { + $('#mainCarousel .carousel-inner') + .append( + $('
') + .addClass('carousel-item') + .append($('') + .attr('src', data) + ) + ); + }); +})