PageSourceSearch

https://ffbillard.com/global/scripts/jicarousel/jquery.infinite-carousel.js

js ffbillard.com collected 2026-10-01 12:07:20 UTC 2,913 bytes, 127 lines download raw bytes

1/* Infinite Carousel */
2
3(function($){
4
5	$.fn.carousel = function(previous, next, options) {
6
7		var element = $(this);
8		var sliderList = $(this).children()[0];
9
10		// Var
11		var increment = 0;
12		var sizeParentElmnt = $(this).width();
13		var elmnts = 0;
14		var numElmts = 0;
15		var sizeFirstElmnt = 0;
16		var shownInViewport = 1;
17		var firstElementOnViewPort = 1;
18		var isAnimating = false;
19
20		this.initialize = function() {
21
22			if (sliderList) {
23
24				// Position
25				jQuery(sliderList).css('left', "0px");
26
27				// Increment et liste
28				increment = jQuery(sliderList).children().outerWidth(true),
29					elmnts = jQuery(sliderList).children(),
30					numElmts = elmnts.length,
31					sizeFirstElmnt = increment,
32					shownInViewport = Math.round(jQuery(this).width() / sizeFirstElmnt),
33					firstElementOnViewPort = 1,
34					isAnimating = false;
35
36				// Largeur
37				adaptWidth();
38
39				for (i = 0; i < shownInViewport; i++) {
40					if(numElmts > shownInViewport) jQuery(sliderList).append(jQuery(elmnts[i]).clone());
41					else {
42						jQuery(previous).css("display", "none");
43						jQuery(next).css("display", "none");
44					}
45				}
46
47				// Précédent
48				jQuery(previous).click(function(event){
49					if (!isAnimating) {
50						if (firstElementOnViewPort == 1) {
51							jQuery(sliderList).css('left', "-" + numElmts * sizeFirstElmnt + "px");
52							firstElementOnViewPort = numElmts;
53						}
54						else {
55							firstElementOnViewPort--;
56						}
57
58						jQuery(sliderList).animate({
59							left: "+=" + increment,
60							y: 0,
61							queue: true
62						}, "swing", function(){isAnimating = false;});
63						isAnimating = true;
64					}
65
66				});
67
68				// Suivant
69				jQuery(next).click(function(event){
70					if (!isAnimating) {
71						if (firstElementOnViewPort > numElmts) {
72							firstElementOnViewPort = 2;
73							jQuery(sliderList).css('left', "0px");
74						}
75						else {
76							firstElementOnViewPort++;
77						}
78						jQuery(sliderList).animate({
79							left: "-=" + increment,
80							y: 0,
81							queue: true
82						}, "swing", function(){isAnimating = false;});
83						isAnimating = true;
84					}
85				});
86
87			}
88
89			return this;
90
91		};
92
93		// Suppression
94		this.remove = function() {
95
96			jQuery(previous).off('click');
97			jQuery(next).off('click');
98
99		}
100
101		// Adaptation de la largeur
102		function adaptWidth() {
103
104			// Init
105			jQuery(sliderList).css('left', "0px");
106			sizeParentElmnt = jQuery(element).width();
107
108			// Elements
109			jQuery(sliderList).children('li').css("width", sizeParentElmnt + "px");
110			increment = jQuery(sliderList).children().outerWidth(true);
111
112			// Largeur du parent
113			jQuery(sliderList).css('width',(numElmts+shownInViewport)*increment + increment + "px");
114
115		}
116
117		// RWD
118		$(window).resize(function(){
119			adaptWidth();
120		});
121
122		// Objet
123		return this.initialize();
124
125	}
126
127})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.