PageSourceSearch

https://volyninfo.com/core/wp-content/themes/silver_mag_lite/js/slickcustomscroll.js

js volyninfo.com collected 2026-10-02 18:48:24 UTC 14,955 bytes, 258 lines download raw bytes

1/*
2* Slick Custom Scrollbar Script
3* Created: Oct 3rd, 2011 by PK for DynamicDrive.com. This notice must stay intact for usage 
4* Visit http://www.dynamicdrive.com/ for full source code
5*/
6
7// March 19th, 12': Update to v1.1, which adds mousewheel support, ability to disable "overscroll" behaviour of scrollbar: http://www.dynamicdrive.com/forums/showthread.php?t=67862
8// April 17th, 15': Update to v1.2 for touch scroll support in mobile browsers
9
10jQuery.fn.customscroll = function( d ) {
11    return this.each( function() {
12        var direction = d.direction, bounce = typeof d.bounce === 'number'? d.bounce : 20;
13        var drag = {
14            d: direction,
15            t: $( this ).attr( "rel" ),
16            id: $( this ),
17            setdimensions: function(orientation) { //DD added function
18                if (orientation=="horizontal"){
19                    drag.b.css( { width: drag.id.width(), left: 0, bottom: 0, position: "absolute", "z-index": 10 } );
20                    drag.c.css( { display: "block", position: "absolute", height: drag.id.height() - drag.b.height() - 5, "overflow-y": "hidden" } );
21                    drag.s.css( { width: drag.b.width(), top: 0, width: 70, height: drag.b.height(), position: "absolute", "z-index": 100 } );
22               	    drag.tickB = parseFloat( parseInt( drag.c.width() - drag.s.parent().width() ) / parseInt( drag.s.parent().width() - drag.s.width() ) ); // ratio between scrollable DIV area and scrollbar area
23                    drag.tickC = parseFloat( parseInt( drag.s.parent().width() - drag.s.width() ) / parseInt( drag.c.width() - drag.s.parent().width() ) ); // ratio between scrollable scrollbar area and DIV area
24		    return [drag.b.width() - drag.s.width() + bounce, drag.id.width() - drag.c.width() - bounce * drag.tickB];
25		} else {
26                    drag.b.css( { height: drag.id.height(), right: 0, top: 0, position: "absolute" } );
27                    drag.c.css( { display: "block", position: "absolute", width: drag.id.width() - drag.b.width() - 5 } );
28                    drag.s.css( { width: drag.b.width(), top: 0, height: 70, position: "absolute" } );
29                    drag.tickB = parseFloat( parseInt( drag.c.height() - drag.s.parent().height() ) / parseInt( drag.s.parent().height() - drag.s.height() ) );
30                    drag.tickC = parseFloat( parseInt( drag.s.parent().height() - drag.s.height() ) / parseInt( drag.c.height() - drag.s.parent().height() ) );
31		    return [drag.b.height() - drag.s.height() + bounce, drag.id.height() - drag.c.height() - bounce * drag.tickB];
32		}
33	    },	
34            create: function() {
35                switch ( drag.d ) {
36                    case "horizontal":
37                        drag.elements( "horizontal" );
38                        var maxs=drag.setdimensions( "horizontal" );
39                        drag.s.data( { click: false } );
40                        drag.s.mouseover( function() {
41                            drag.s.data( { click: true } );
42                        });
43                        drag.s.mouseout( function() {
44                            drag.s.data( { click: false } );
45                        });
46                        drag.id.bind('mousewheel', function( f, delta ) {
47                            f.preventDefault();
48                            clearTimeout(drag.wheeltimer);
49                            var initial = drag.s.position().left, moveby;
50                            drag.s.css({left: Math.min(Math.max((moveby = -10 * delta + initial), -bounce), maxs[0])});
51                            drag.c.css({left: Math.max(Math.min(- drag.tickB * moveby, drag.tickB * bounce), maxs[1])});
52                            drag.wheeltimer = setTimeout(drag.redrawH, 100);
53                        });
54                        drag.s.mousedown( function( f ) {
55                            f.preventDefault();
56                            drag.s.data( { hold: false } );
57                            var initial = drag.s.parent().offset().left - ( drag.s.offset().left - f.pageX );
58                            $( document ).mousemove( function( e ) {
59                                e.preventDefault();
60                                if ( drag.s.data( "hold" ) == false )
61                                {
62                                    drag.s.css( { left: Math.min(Math.max(e.pageX - initial, -bounce), maxs[0]) } );
63                                    drag.c.css( { left: Math.max(Math.min(- drag.tickB * ( e.pageX - initial ), drag.tickB * bounce),maxs[1]) } );
64                                }
65                            });
66                        });
67                        $( document ).mouseup( function() {
68                            drag.redrawH();
69                        });
70                        drag.id.bind('touchstart', function( f ) { 
71														var f = (f.type.indexOf('touch') != '-1')? f.originalEvent.changedTouches[0] : f
72														var initial = drag.c.position().left;
73														var initialx = f.pageX
74				                        $(document).bind('touchmove.slickscroll', function( f ) { // cancel scroll action ontouch with single finger
75																		var touches = (f.type.indexOf('touch') != '-1')? f.originalEvent.changedTouches.length : 0
76																		var f = (f.type.indexOf('touch') != '-1')? f.originalEvent.changedTouches[0] : f
77																		var moveby = f.pageX - initialx
78				                            drag.s.css( { left: Math.min(Math.max(-drag.tickC * (initial + moveby), -bounce), maxs[0]) } );
79				                            drag.c.css( { left: Math.max(Math.min( initial + moveby, drag.tickB * bounce), maxs[1]) } );
80																		if (touches == 1) // cancel scroll action ontouch with single finger
81																				return false;
82																})
83												})
84                        drag.id.bind('touchend', function( f ) {
85														$(document).unbind('touchmove.slickscroll')
86														drag.redrawH();
87												})
88                        drag.b.click( function( e ) {
89                            if ( drag.s.data( "click" ) == false )
90                            {
91                                var initial = drag.s.parent().offset().left + ( drag.s.width() / 2 );
92                                drag.s.animate( { left: e.pageX - initial } );
93                                drag.c.animate( { left: - drag.tickB * ( e.pageX - initial ) }, {
94                                    complete: function() {
95                                        drag.redrawH();
96                                    }
97                                });
98                            }
99                        });
100                    break;
101                    case "vertical":
102                        drag.elements( "vertical" );
103                        var maxs=drag.setdimensions( "vertical" );
104                        drag.s.data( { click: false } );
105                        drag.s.mouseover( function() {
106                            drag.s.data( { click: true } );
107                        });
108                        drag.s.mouseout( function() {
109                            drag.s.data( { click: false } );
110                        });
111												drag.id.bind('mousewheel', function( f, delta ) {
112                            f.preventDefault();
113                            clearTimeout(drag.wheeltimer);
114                            var initial = drag.s.position().top, moveby;
115                            drag.s.css({top: Math.min(Math.max((moveby = -10 * delta + initial), -bounce), maxs[0])});
116                            drag.c.css({top: Math.max(Math.min(-drag.tickB * moveby, drag.tickB * bounce), maxs[1])});
117                            drag.wheeltimer = setTimeout(drag.redrawV, 100);
118                        });
119                        drag.s.bind('mousedown', function( f ) {
120                            f.preventDefault();
121                            drag.s.data( { hold: false } );
122                            var initial = drag.s.parent().offset().top - ( drag.s.offset().top - f.pageY );
123                            $( document ).bind('mousemove', function( e ) {
124                                e.preventDefault();
125                                if ( drag.s.data( "hold" ) == false )
126                                {
127                                  drag.s.css( { top: Math.min(Math.max(e.pageY - initial, -bounce), maxs[0]) } );
128                                  drag.c.css( { top: Math.max(Math.min(- drag.tickB * ( e.pageY - initial ), drag.tickB * bounce), maxs[1]) } );
129                                }
130                            });
131                        });
132                        $( document ).bind('mouseup', function() {
133                            drag.redrawV();
134                        });
135                        drag.id.bind('touchstart', function( f ) { 
136														var f = (f.type.indexOf('touch') != '-1')? f.originalEvent.changedTouches[0] : f
137														var initial = drag.c.position().top;
138														var initialy = f.pageY
139				                        $(document).bind('touchmove.slickscroll', function( f ) { // cancel scroll action ontouch with single finger
140																		var touches = (f.type.indexOf('touch') != '-1')? f.originalEvent.changedTouches.length : 0
141																		var f = (f.type.indexOf('touch') != '-1')? f.originalEvent.changedTouches[0] : f
142																		var moveby = f.pageY - initialy
143				                            drag.s.css( { top: Math.min(Math.max(-drag.tickC * (initial + moveby), -bounce), maxs[0]) } );
144				                            drag.c.css( { top: Math.max(Math.min( initial + moveby, drag.tickB * bounce), maxs[1]) } );
145																		if (touches == 1) // cancel scroll action ontouch with single finger
146																				return false;
147																})
148												})
149                        drag.id.bind('touchend', function( f ) {
150														$(document).unbind('touchmove.slickscroll')
151														drag.redrawV();
152												})
153
154                        drag.b.click( function( e ) {
155                            if ( drag.s.data( "click" ) == false )
156                            {
157                                var initial = drag.s.parent().offset().top + ( drag.s.height() / 2 );
158                                drag.s.animate( { top: e.pageY - initial } );
159                                drag.c.animate( { top: - drag.tickB * ( e.pageY - initial ) }, {
160                                    complete: function() {
161                                        drag.redrawV();
162                                    }
163                                });
164                            }
165                        });
166                    break;
167                }
168                $( "a" ).click( function() {
169                    if ( $( this ).attr( "rel" ) )
170                    {
171                        drag.move( "#" + $( this ).attr( "rel" ), $( this ).attr( "parent" ) );
172                    }
173                });
174
175                $( window ).resize( function() { //DD added event
176                    drag.setdimensions(drag.d);
177										var resetpos=( drag.d=="horizontal" )? {left: 0} : {top: 0}
178										drag.c.css( resetpos )
179                });
180
181                $( window ).unload( function() {
182                    drag.destroy();
183                });
184            },
185            redrawV: function() {
186                drag.s.data( { hold: true } );
187                if ( drag.s.parent().height() < drag.s.position().top + drag.s.height() )
188                {
189                    drag.s.animate( { top: drag.s.parent().height() - drag.s.height() }, 250 );
190                    drag.c.animate( { top: drag.s.parent().height() - drag.c.height() }, 250 );
191                }
192                else if ( drag.s.position().top < 0 )
193                {
194                    drag.s.animate( { top: 0 }, 250 );
195                    drag.c.animate( { top: 0 }, 250 );
196                }
197            },
198            redrawH: function() {
199                drag.s.data( { hold: true } );
200                if ( drag.s.parent().width() < drag.s.position().left + drag.s.width() )
201                {
202                    drag.s.animate( { left: drag.s.parent().width() - drag.s.width() }, 250 );
203                    drag.c.animate( { left: drag.s.parent().width() - drag.c.width() }, 250 );
204                }
205                else if ( drag.s.position().left < 0 )
206                {
207                    drag.s.animate( { left: 0 }, 250 );
208                    drag.c.animate( { left: 0 }, 250 );
209                }
210            },
211            move: function( where, par ) {
212                if ( drag.d == "vertical" && drag.t == par )
213                {
214                    if ( drag.tickC * $( where ).position().top > drag.s.parent().height() - drag.s.height() )
215                    {
216                        drag.s.animate( { top: drag.s.parent().height() - drag.s.height() }, { duration: 250 } );
217                        drag.c.animate( { top: drag.s.parent().height() - drag.c.height() }, { duration: 250 } );
218                    }
219                    else
220                    {
221                        drag.s.animate( { top: drag.tickC * $( where ).position().top }, { duration: 250 } );
222                        drag.c.animate( { top: - $( where ).position().top }, { duration: 250 } );
223                    }
224                }
225                else if ( drag.d == "horizontal" && drag.t == par )
226                {
227                    if ( drag.tickC * $( where ).position().left > drag.s.parent().width() - drag.s.width() )
228                    {
229                        drag.s.animate( { left: drag.s.parent().width() - drag.s.width() }, { duration: 250 } );
230                        drag.c.animate( { left: drag.s.parent().width() - drag.c.width() }, { duration: 250 } );
231                    }
232                    else
233                    {
234                        drag.s.animate( { left: drag.tickC * $( where ).position().left }, { duration: 250 } );
235                        drag.c.animate( { left: - $( where ).position().left }, { duration: 250 } );
236                    }
237                }
238            },
239            elements: function( where ) {
240                drag.id.css( { overflow: "hidden", position: "relative" } );
241                drag.id.wrapInner( '<div class="' + drag.t + '-content"></div>' );
242                drag.c = $( '.' + drag.t + '-content' );
243                drag.id.append( '<div class="' + drag.t + '-bar"></div>' );
244                drag.b = $( '.' + drag.t + '-bar' );
245                drag.b.append( '<div class="' + drag.t + '-drag"></div>' );
246                drag.s = $( '.' + drag.t + '-drag' );
247            },
248            destroy: function() {
249                // What happens in DOM, stays in DOM. Unless...
250                $( "*" ).each( function() {
251                    $( this ).remove();
252                });
253            }
254        };
255        drag.create();
256    });
257};
258// And here it ends.

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.