PageSourceSearch

https://www.durhampress.com/lib/g/2.0/scripts/artlogic_modules/_ve…/plugins/thumbnailScroller.js

js durhampress.com collected 2026-10-02 10:35:15 UTC 7,930 bytes, 210 lines download raw bytes

1/*
2Thumbnail scroller jQuery plugin
3Author: malihu [http://manos.malihu.gr]
4Homepage: manos.malihu.gr/jquery-thumbnail-scroller
5*/
6export default (function(){
7(function($){  
8 $.fn.thumbnailScroller=function(options){  
9	var defaults={ //default options
10		scrollerType:"hoverPrecise", //values: "hoverPrecise", "hoverAccelerate", "clickButtons"
11		scrollerOrientation:"horizontal", //values: "horizontal", "vertical"
12		scrollEasing:"easeOutCirc", //easing type
13		scrollEasingAmount:800, //value: milliseconds
14		acceleration:2, //value: integer
15		scrollSpeed:600, //value: milliseconds
16		noScrollCenterSpace:0, //value: pixels
17		autoScrolling:0, //value: integer
18		autoScrollingSpeed:8000, //value: milliseconds
19		autoScrollingEasing:"easeInOutQuad", //easing type
20		autoScrollingDelay:2500 //value: milliseconds
21	};
22	var options=$.extend(defaults,options);
23    return this.each(function(){ 
24		//cache vars
25		var $this=$(this);
26		var $scrollerContainer=$this.find(".jTscrollerContainer");
27		var $scroller=$this.find(".jTscrollerContainer").children(".jTscroller");
28		var $scrollerNextButton=$this.find(".jTscrollerNextButton");
29		var $scrollerPrevButton=$this.find(".jTscrollerPrevButton");
30		//set scroller width
31		if(options.scrollerOrientation=="horizontal"){
32			$scrollerContainer.css("width",999999); 
33			var totalWidth=$scroller.outerWidth(true);
34			$scrollerContainer.css("width",totalWidth);
35		}else{
36			var totalWidth=$scroller.outerWidth(true);
37		}
38		var totalHeight=$scroller.outerHeight(true); //scroller height
39		//do the scrolling
40		if(totalWidth>$this.width() || totalHeight>$this.height()){ //needs scrolling		
41			var pos;
42			var mouseCoords;
43			var mouseCoordsY;
44			if(options.scrollerType=="hoverAccelerate"){ //type hoverAccelerate
45				var animTimer;
46				var interval=8;
47				$this.hover(function(){ //mouse over
48					$this.mousemove(function(e){
49						pos=findPos(this);
50						mouseCoords=(e.pageX-pos[1]);
51						mouseCoordsY=(e.pageY-pos[0]);
52					});
53					clearInterval(animTimer);
54					animTimer = setInterval(Scrolling,interval);
55				},function(){  //mouse out
56					clearInterval(animTimer);
57					$scroller.stop();
58				});
59				$scrollerPrevButton.add($scrollerNextButton).addClass('disabled'); //hide buttons
60			}else if(options.scrollerType=="clickButtons"){
61				ClickScrolling();
62			}else{ //type hoverPrecise
63				pos=findPos(this);
64				$this.mousemove(function(e){
65					mouseCoords=(e.pageX-pos[1]);
66					mouseCoordsY=(e.pageY-pos[0]);
67					var mousePercentX=mouseCoords/$this.width(); if(mousePercentX>1){mousePercentX=1;}
68					var mousePercentY=mouseCoordsY/$this.height(); if(mousePercentY>1){mousePercentY=1;}
69					var destX=Math.round(-((totalWidth-$this.width())*(mousePercentX)));
70					var destY=Math.round(-((totalHeight-$this.height())*(mousePercentY)));
71					$scroller.stop(true,false).animate({left:destX,top:destY},options.scrollEasingAmount,options.scrollEasing); 
72				});
73				$scrollerPrevButton.add($scrollerNextButton).addClass('disabled'); //hide buttons
74			}
75			//auto scrolling
76			if(options.autoScrolling>0){
77				AutoScrolling();
78			}
79		} else {
80			//no scrolling needed
81			$scrollerPrevButton.add($scrollerNextButton).addClass('disabled'); //hide buttons
82		}
83		//"hoverAccelerate" scrolling fn
84		var scrollerPos;
85		var scrollerPosY;
86		function Scrolling(){
87			if((mouseCoords<$this.width()/2) && ($scroller.position().left>=0)){
88				$scroller.stop(true,true).css("left",0); 
89			}else if((mouseCoords>$this.width()/2) && ($scroller.position().left<=-(totalWidth-$this.width()))){
90				$scroller.stop(true,true).css("left",-(totalWidth-$this.width())); 
91			}else{
92				if((mouseCoords<=($this.width()/2)-options.noScrollCenterSpace) || (mouseCoords>=($this.width()/2)+options.noScrollCenterSpace)){
93					scrollerPos=Math.round(Math.cos((mouseCoords/$this.width())*Math.PI)*(interval+options.acceleration));
94					$scroller.stop(true,true).animate({left:"+="+scrollerPos},interval,"linear"); 
95				}else{
96					$scroller.stop(true,true);
97				}
98			}
99			if((mouseCoordsY<$this.height()/2) && ($scroller.position().top>=0)){
100				$scroller.stop(true,true).css("top",0); 
101			}else if((mouseCoordsY>$this.height()/2) && ($scroller.position().top<=-(totalHeight-$this.height()))){
102				$scroller.stop(true,true).css("top",-(totalHeight-$this.height())); 
103			}else{
104				if((mouseCoordsY<=($this.height()/2)-options.noScrollCenterSpace) || (mouseCoordsY>=($this.height()/2)+options.noScrollCenterSpace)){
105					scrollerPosY=Math.cos((mouseCoordsY/$this.height())*Math.PI)*(interval+options.acceleration);
106					$scroller.stop(true,true).animate({top:"+="+scrollerPosY},interval,"linear"); 
107				}else{
108					$scroller.stop(true,true);
109				}
110			}
111		}
112		//auto scrolling fn
113		var autoScrollingCount=0;
114		function AutoScrolling(){
115			$scroller.delay(options.autoScrollingDelay).animate({left:-(totalWidth-$this.width()),top:-(totalHeight-$this.height())},options.autoScrollingSpeed,options.autoScrollingEasing,function(){
116				$scroller.animate({left:0,top:0},options.autoScrollingSpeed,options.autoScrollingEasing,function(){
117					autoScrollingCount++;
118					if(options.autoScrolling>1 && options.autoScrolling!=autoScrollingCount){
119						AutoScrolling();
120					}
121				});
122			});
123		}
124		//click scrolling fn
125		function ClickScrolling(){
126			$scrollerPrevButton.addClass('disabled');
127			$scrollerNextButton.removeClass('disabled');
128			$scrollerNextButton.click(function(e){ //next button
129				e.preventDefault();
130				var posX=$scroller.position().left;
131				var diffX=totalWidth+(posX-$this.width());
132				var posY=$scroller.position().top;
133				var diffY=totalHeight+(posY-$this.height());
134				$scrollerPrevButton.removeClass('disabled');
135				if(options.scrollerOrientation=="horizontal"){
136					if(diffX>=$this.width()){
137						$scroller.stop().animate({left:"-="+$this.width()},options.scrollSpeed,function(){
138							if(diffX==$this.width()){
139								$scrollerNextButton.addClass('disabled');
140							}
141						});
142					} else {
143						$scrollerNextButton.stop().addClass('disabled');
144						$scroller.stop().animate({left:$this.width()-totalWidth},options.scrollSpeed);
145					}
146				}else{
147					if(diffY>=$this.height()){
148						$scroller.stop().animate({top:"-="+$this.height()},options.scrollSpeed,function(){
149							if(diffY==$this.height()){
150								$scrollerNextButton.addClass('disabled');
151							}
152						});
153					} else {
154						$scrollerNextButton.addClass('disabled');
155						$scroller.stop().animate({top:$this.height()-totalHeight},options.scrollSpeed);
156					}
157				}
158			});
159			$scrollerPrevButton.click(function(e){ //previous button
160				e.preventDefault();
161				var posX=$scroller.position().left;
162				var diffX=totalWidth+(posX-$this.width());
163				var posY=$scroller.position().top;
164				var diffY=totalHeight+(posY-$this.height());
165				$scrollerNextButton.removeClass('disabled');
166				if(options.scrollerOrientation=="horizontal"){
167					if(posX+$this.width()<=0){
168						$scroller.stop().animate({left:"+="+$this.width()},options.scrollSpeed,function(){
169							if(posX+$this.width()==0){
170								$scrollerPrevButton.addClass('disabled');
171							}
172						});
173					} else {
174						$scrollerPrevButton.addClass('disabled');
175						$scroller.stop().animate({left:0},options.scrollSpeed);
176					}
177				}else{
178					if(posY+$this.height()<=0){
179						$scroller.stop().animate({top:"+="+$this.height()},options.scrollSpeed,function(){
180							if(posY+$this.height()==0){
181								$scrollerPrevButton.addClass('disabled');
182							}
183						});
184					} else {
185						$scrollerPrevButton.addClass('disabled');
186						$scroller.stop().animate({top:0},options.scrollSpeed);
187					}
188				}
189			});
190		}
191	});  
192 };  
193})(jQuery); 
194//global js functions
195//find element Position
196window.findPos = function findPos(obj){
197	var curleft = 0;
198    var curtop=0;
199	if (obj.offsetParent){
200		curleft=obj.offsetLeft
201		curtop=obj.offsetTop
202		while(obj=obj.offsetParent){
203			curleft+=obj.offsetLeft
204			curtop+=obj.offsetTop
205		}
206	}
207	return [curtop,curleft];
208}
209})();
210

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.