PageSourceSearch

https://palmeyayinevi.com/Themes/PalmeYay%C4%B1nevi/Content/js/idangerous.swiper.scrollbar-2.1.js

js palmeyayinevi.com collected 2026-09-24 10:01:53 UTC 6,480 bytes, 247 lines download raw bytes

1/*
2 * Swiper Scrollbar 2.1
3 * Plugin for Swiper 2.0+
4 * http://www.idangero.us/sliders/swiper/
5 *
6 * Copyright 2012-2013, Vladimir Kharlampidi
7 * The iDangero.us
8 * http://www.idangero.us/
9 *
10 * Licensed under GPL & MIT
11 *
12 * Released on: June 9, 2013
13*/
14
15Swiper.prototype.plugins.scrollbar = function(swiper, params){
16	
17	var enabled = params && params.container;
18	if(!enabled) return;
19	
20	/*=========================
21	  Default Parameters
22	  ===========================*/
23	var defaults = {
24		hide : true,
25		draggable : true,
26		snapOnRelease: false
27	}
28	params = params || {};	
29	for (var prop in defaults) {
30		if (! (prop in params)) {
31			params[prop] = defaults[prop]	
32		}
33	}
34
35	/*=========================
36	  Container
37	  ===========================*/
38	if (!document.querySelectorAll) {
39        if (!window.jQuery) return;
40    }
41	function $$(s) {
42        if (document.querySelectorAll)
43            return document.querySelectorAll(s)
44        else
45            return jQuery(s)
46    }
47    if(!(params.container.nodeType)){
48        if ($$(params.container).length==0) return;
49    }   
50    var container = (params.container.nodeType) ? params.container : $$(params.container)[0];
51	
52	/*=========================
53	  Default Vars
54	  ===========================*/
55	var isH = swiper.params.mode=='horizontal',
56		track = container,
57		trackWidth, trackHeight, divider, moveDivider, dragWidth, dragHeight;
58
59	/*=========================
60	  Define Drag
61	  ===========================*/
62	var drag = document.createElement('div')
63	drag.className = 'swiper-scrollbar-drag';
64	if (params.draggable) drag.className += ' swiper-scrollbar-cursor-drag';
65	track.appendChild(drag);
66	if (params.hide) track.style.opacity=0;
67
68	var te = swiper.touchEvents
69	/*=========================
70	  Draggable
71	  ===========================*/
72	if (params.draggable) {
73		var isTouched = false;
74		function dragStart(e){
75			isTouched = true;
76			if(e.preventDefault) e.preventDefault();
77            else e.returnValue = false;
78			setDragPosition(e);
79			clearTimeout(timeout);
80
81			swiper.setTransition(track,0)
82			track.style.opacity = 1;
83			swiper.setWrapperTransition(100);
84			swiper.setTransition(drag,100)
85			
86		}
87		function dragMove(e){
88			if(!isTouched) return;
89			if(e.preventDefault) e.preventDefault();
90            else e.returnValue = false;
91			setDragPosition(e);
92			swiper.setWrapperTransition(0);
93			swiper.setTransition(track,0)
94			swiper.setTransition(drag,0)
95		}
96		function dragEnd(e) {
97			isTouched = false;
98			if (params.hide) {
99				clearTimeout(timeout)
100				timeout = setTimeout(function(){
101					track.style.opacity=0;
102					swiper.setTransition(track,400)
103				},1000)
104				
105			}
106			if (params.snapOnRelease) {
107				swiper.swipeReset()
108			}
109		}
110
111
112		var lestenEl = swiper.support.touch ? track : document
113		swiper.h.addEventListener(track, te.touchStart, dragStart, false)
114		swiper.h.addEventListener(lestenEl, te.touchMove, dragMove, false)
115		swiper.h.addEventListener(lestenEl, te.touchEnd, dragEnd, false)
116
117		function setDragPosition(e){
118			var x = y = 0;
119			var position;
120			if (isH) {
121				x = (e.pageX || e.clientX) - swiper.h.getOffset(track).left - dragWidth/2
122				if (x<0) x = 0;
123				else if ( (x+dragWidth) > trackWidth) {
124					x = trackWidth - dragWidth;
125				}
126			}
127			else {
128				
129				y = (e.pageY||e.clientY) - swiper.h.getOffset(track).top - dragHeight/2;
130				
131				if (y<0) y = 0;
132				else if ( (y+dragHeight) > trackHeight) {
133					y = trackHeight - dragHeight;
134				}
135			}
136			//Set Drag Position
137			swiper.setTranslate(drag,{x:x, y:y})
138
139			//Wrapper Offset
140			var wrapX = -x/moveDivider;
141			var wrapY = -y/moveDivider;
142			
143			swiper.setWrapperTranslate(wrapX ,wrapY)
144			
145		}
146	}
147	
148	function setScrollBars() {
149		drag.style.width = ''
150		drag.style.height = ''
151		if (isH) {
152			trackWidth = swiper.h.getWidth(track, true);
153			divider = swiper.width/swiper.h.getWidth(swiper.wrapper);
154			moveDivider = divider*(trackWidth/swiper.width);
155			dragWidth = trackWidth*divider;
156			drag.style.width = dragWidth+'px';
157		}
158		else {
159			trackHeight = swiper.h.getHeight(track, true);
160			divider = swiper.height/swiper.h.getHeight(swiper.wrapper);
161			moveDivider = divider*(trackHeight/swiper.height);
162			dragHeight = trackHeight*divider;
163			if (dragHeight>trackHeight) dragHeight = trackHeight
164			drag.style.height = dragHeight+'px';
165		}
166	}
167	var timeout;
168
169	var hooks = {
170		onFirstInit : function(args){
171			setScrollBars()
172		},
173		onInit : function(args) {
174			setScrollBars()
175		},
176		
177		onTouchMoveEnd : function(args) {
178			if (params.hide) {
179				clearTimeout(timeout)
180				track.style.opacity=1;
181				swiper.setTransition(track,200)
182			}
183		},
184		
185		onTouchEnd : function(args) {
186			if (params.hide) {
187				clearTimeout(timeout)
188				timeout = setTimeout(function(){
189					track.style.opacity=0;
190					swiper.setTransition(track,400)
191				},1000)
192			}
193		},
194		
195		onSetWrapperTransform: function(pos){
196			
197			if (isH) {
198				var newLeft = pos.x*moveDivider;
199				var newWidth = dragWidth;
200				if (newLeft > 0) {
201					var diff = newLeft;
202					newLeft = 0;
203					newWidth = dragWidth-diff;
204				}
205				else if ( (-newLeft+dragWidth) > trackWidth) {
206					newWidth = trackWidth + newLeft;
207				}
208
209				swiper.setTranslate(drag,{x:-newLeft})
210				drag.style.width  = newWidth+'px';
211			}
212			else {
213				var newTop = pos.y*moveDivider;
214				var newHeight = dragHeight;
215				if (newTop > 0) {
216					var diff = newTop;
217					newTop = 0;
218					newHeight = dragHeight-diff;
219				}
220				else if ( (-newTop+dragHeight) > trackHeight) {
221					newHeight = trackHeight + newTop;
222				}
223				swiper.setTranslate(drag,{y:-newTop})
224				drag.style.height  = newHeight+'px';
225			}
226			if (swiper.params.freeMode && params.hide) {
227				clearTimeout(timeout)
228				track.style.opacity=1;
229				timeout = setTimeout(function(){
230					track.style.opacity=0;
231					swiper.setTransition(track,400)
232				},1000)
233			}
234			
235		},
236		onSetWrapperTransition: function(args){
237			swiper.setTransition(drag,args.duration)
238		},
239		onDestroy: function(){
240			var lestenEl = swiper.support.touch ? track : document
241			swiper.h.removeEventListener(track, te.touchStart, dragStart, false)
242			swiper.h.removeEventListener(lestenEl, te.touchMove, dragMove, false)
243			swiper.h.removeEventListener(lestenEl, te.touchEnd, dragEnd, false)
244		}
245	}
246	return hooks;
247}

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.