PageSourceSearch

https://loganstampings.com/wp-content/themes/theme52551/parallax-slider/js/parallaxSlider.js?ver=1.0

js loganstampings.com collected 2026-10-09 01:15:14 UTC 22,999 bytes, 550 lines download raw bytes

1(function($){
2     $.fn.parallaxSlider=function(o){ 
3            
4        var options = {
5            prevButton: $('.prevButton')
6        ,   nextButton: $('.nextButton')
7        ,   duration: 1000
8        ,   autoSwitcher: true
9        ,   autoSwitcherDelay: 7000
10        ,   slider_navs: true
11        ,   scrolling_description: false
12        ,   slider_pagination: 'buttons_pagination'
13        ,   animateLayout: 'zoom-fade-eff' //simple-fade-eff, zoom-fade-eff, slide-top-eff
14        ,   parallaxEffect: 'parallax_effect_normal'
15        ,   parallaxInvert: false
16        ,   liteMode: false
17        }
18        $.extend(options, o);
19        
20        var 
21            _this = $(this)
22        ,   _window = $(window)
23        ,   _document = $(document)
24        ,   ImgIdCounter = 0
25        ,   previewArray = []
26        ,   isPreviewLoading = false
27        ,   isPreviewAnimate = false
28        ,   intervalSwitcher
29        ,   parsedArray
30        ,   parallax = true
31        ,   parallaxType = 'parallax_normal'
32        ,   _baseHeight
33        ,   _thisOffsetTop = _this.offset().top
34        ,   _thisHeight = _this.height()
35        ,   _windowWidth = _window.width()
36        ,   _windowHeight = _window.height()
37        ,   itemLength = 0
38        ,   bufferRatio 
39        ;
40    
41        var
42            img
43        ,   imgBlock
44        ,   mainImageHolder
45        ,   primaryImageHolder
46        ,   secondaryHolder
47        ,   mainCaptionHolder
48        ,   primaryCaption
49        ,   secondaryCaption
50        ,   mainCaptionHolderContainer
51        ,   previewSpinner
52        ,   parallaxPrevBtn
53        ,   parallaxNextBtn
54        ,   slidesCounterList
55        ,   paralaxSliderPagination
56        ;
57    
58        //--------------- Init ------------------//
59        init();
60        function init(){
61            parsedArray = [];
62            $('ul li', _this).each(
63                function(){
64                    parsedArray.push([$(this).attr('data-preview'), $(this).attr('data-thumb-url'), $(this).html()]);
65                }
66            )
67                
68            //  holder erase
69            _this.html('');
70            _this.addClass(options.animateLayout);
71    
72            //  preview holder build
73            imgBlocksStructure = !options.liteMode ? "<div id='mainImageHolder'><div class='primaryHolder'><div class='imgBlock'></div></div><div class='secondaryHolder'><div class='imgBlock'></div></div></div>" : "<div id='mainImageHolder'><div class='primaryHolder'><img class='imgBlock' src='' alt=''/></div><div class='secondaryHolder'><img class='imgBlock' src='' alt=''/></div></div>"; 
74            _this.append(imgBlocksStructure);
75            mainImageHolder = $('#mainImageHolder');
76            primaryImageHolder = $('> .primaryHolder', mainImageHolder);
77            secondarImageHolder = $('> .secondaryHolder', mainImageHolder);
78            imgBlock = $('.imgBlock', mainImageHolder);
79    
80             //  caption holder build
81            _this.append("<div id='mainCaptionHolder'><div class='container'><div class='primaryCaption'></div><div class='secondaryCaption'></div></div></div>");
82            mainCaptionHolder = $('#mainCaptionHolder');
83            primaryCaption = $('.primaryCaption', mainCaptionHolder);
84            secondaryCaption = $('.secondaryCaption', mainCaptionHolder);
85            mainCaptionHolderContainer = $('>.container', mainCaptionHolder);
86    
87            //  controls build
88            _this.append("<div class='controlBtn parallaxPrevBtn'><div class='innerBtn icon-angle-left'></div><div class='slidesCounter'></div></div><div class='controlBtn parallaxNextBtn'><div class='innerBtn icon-angle-right'></div><div class='slidesCounter'></div></div>");
89            parallaxPrevBtn = $('.parallaxPrevBtn', _this);
90            parallaxNextBtn = $('.parallaxNextBtn', _this);
91    
92            //  fullpreview pagination build
93            _this.append("<div id='paralaxSliderPagination'><ul></ul></div>");
94            paralaxSliderPagination = $('#paralaxSliderPagination');
95    
96            slidesCounterList = $('.slidesCounter', _this);
97            
98            //  preview loader build
99            _this.append("<div id='previewSpinner'><span></span></div>");
100            previewSpinner = $('#previewSpinner');
101    
102            _this.on("reBuild",
103                function(e,d){
104                    setBuilder(d);
105                }
106            )
107    
108            _this.on("switchNext",
109                function(e){
110                    nextSwither();
111                }
112            )
113    
114            _this.on("switchPrev",
115                function(e){
116                    prevSwither();
117                }
118            )
119    
120            setBuilder({'urlArray':parsedArray});
121    
122            if(!options.slider_navs){
123                parallaxPrevBtn.remove();
124                parallaxNextBtn.remove();
125            }
126            if(options.slider_pagination == 'none_pagination'){
127                paralaxSliderPagination.remove();
128            }
129            
130            if(options.liteMode) options.parallaxEffect = 'parallax_none';
131            
132            switch (options.parallaxEffect) {
133                case 'parallax_effect_low':
134                    if(!options.parallaxInvert){
135                        parallaxType = 'parallax_normal';
136                    } else {
137                        parallaxType = 'parallax_invert';
138                    }
139                    
140                    bufferRatio = 3;
141                    
142                    break
143                    
144                case 'parallax_effect_normal':
145                    if(!options.parallaxInvert){
146                        parallaxType = 'parallax_normal';
147                    } else {
148                        parallaxType = 'parallax_invert';
149                    }
150                    
151                     bufferRatio = 2.25;
152                     
153                    break
154                    
155                case 'parallax_effect_high':
156                    if(!options.parallaxInvert){
157                        parallaxType = 'parallax_normal';
158                    } else {
159                        parallaxType = 'parallax_invert';
160                    }
161                    
162                    bufferRatio = 1.5;
163                    
164                    break
165                    
166                case 'parallax_effect_fixed':
167                    if($.browser.msie){
168                        parallax = false;
169                        imgBlock.css({backgroundAttachment:'fixed'});
170                    } else {
171                        parallaxType = 'parallax_fixes';
172                    }
173                    
174                    bufferRatio = 1;
175                    
176                    break
177                    
178                default:
179                    parallax = false;
180                    parallaxType = 'parallax_none';
181                    
182                    break
183            }
184            
185            _baseHeight = getBaseHeight();
186    
187            addEventsFunction();
188            autoSwitcher();
189        }
190        
191        //------------------------- set Builder -----------------------------//
192        function setBuilder(dataObj){ 
193            currIndex = 0;
194            ImgIdCounter = 0;
195            previewArray = [];
196            previewArray = dataObj.urlArray;
197            itemLength = previewArray.length;
198            
199            $(">ul", paralaxSliderPagination).empty();
200            
201            switch (options.slider_pagination) {
202                case 'buttons_pagination':
203                    paralaxSliderPagination.addClass('buttons_pagination');
204                    for (var i = 0; i < itemLength; i++) {
205                        $(">ul", paralaxSliderPagination).append("<li></li>");
206                    };
207                    
208                    break
209                
210                case 'images_pagination':
211                    paralaxSliderPagination.addClass('images_pagination');
212                    for (var i = 0; i < itemLength; i++) {
213                        $(">ul", paralaxSliderPagination).append("<li><img src='"+previewArray[i][1]+"'></li>");
214                    };
215                    
216                     break
217            }
218    
219            if(itemLength==1){
220                paralaxSliderPagination.remove();
221                parallaxPrevBtn.remove();
222                parallaxNextBtn.remove();
223            }
224    
225            imageSwitcher(0);
226            addEventsPagination();
227        }
228    
229        function autoSwitcher(){
230            if(options.autoSwitcher){
231                if(itemLength>1){
232                    intervalSwitcher = setInterval(function(){
233                        nextSwither();
234                    }, options.autoSwitcherDelay);
235                }
236            }
237        }
238        
239        //---------------  addEvents  ----------------------//
240        function addEventsPagination(){
241            $(">ul >li", paralaxSliderPagination).on("click",
242                function(){
243                    if((!isPreviewLoading) && (!isPreviewAnimate) && ($(this).index() !== ImgIdCounter)){
244                        clearInterval(intervalSwitcher);
245                        ImgIdCounter = $(this).index();
246                        imageSwitcher(ImgIdCounter);
247                    }
248                }
249            )
250        }
251        
252        function addEventsFunction(){
253            //--------------- controls events ----------------------//
254            options.prevButton.on("click",
255                function(){
256                    clearInterval(intervalSwitcher);
257                    prevSwither();
258                }
259            )
260            options.nextButton.on("click",
261                function(){
262                    clearInterval(intervalSwitcher);
263                    nextSwither(); 
264                }
265            )
266            parallaxPrevBtn.on("click",
267                function(){
268                    clearInterval(intervalSwitcher);
269                    prevSwither();
270                }
271            )
272            parallaxNextBtn.on("click",
273                function(){
274                    clearInterval(intervalSwitcher);
275                    nextSwither();
276                }
277            )
278            
279            //--------------- keyboard events ----------------------//
280            _window.on("keydown",
281                function(eventObject){
282                    switch (eventObject.keyCode){
283                        case 37:
284                            clearInterval(intervalSwitcher);
285                            prevSwither();
286                        break
287                        case 39:
288                             clearInterval(intervalSwitcher);
289                            nextSwither();
290                        break
291                    }
292                }
293            )
294            
295            //------------------ window scroll event -------------//
296            $(window).on('scroll',
297                function(){
298                    mainScrollFunction();
299                }
300            ).trigger('scroll');
301            
302            //------------------ window resize event -------------//
303            $(window).on("resize",
304                function(){
305                    mainResizeFunction();
306                }
307            )
308        }
309        
310        //-----------------------------------------------------------------
311        function prevSwither(){
312            if(!isPreviewLoading && !isPreviewAnimate){
313                if(ImgIdCounter > 0){
314                    ImgIdCounter--;
315                }else{
316                    ImgIdCounter = itemLength-1;
317                }
318                    imageSwitcher(ImgIdCounter);
319            }
320        }
321        function nextSwither(){
322            if(!isPreviewLoading && !isPreviewAnimate){
323                if(ImgIdCounter < itemLength-1){
324                    ImgIdCounter++;
325                }else{
326                    ImgIdCounter = 0;
327                }
328                imageSwitcher(ImgIdCounter);
329            }
330        }
331        
332        //------------------------- main Swither ----------------------------//
333        function imageSwitcher(currIndex){ 
334            slidesCounterList.text((currIndex+1) + '/'+itemLength);
335            $(">ul >li", paralaxSliderPagination).removeClass('active').eq(currIndex).addClass('active');
336            
337            objectCssTransition(primaryImageHolder, 0, 'ease');
338            primaryImageHolder.addClass('animateState');
339    
340            primaryCaption.html(previewArray[currIndex][2]);
341            objectCssTransition(primaryCaption, 0, 'ease');
342            primaryCaption.addClass('animateState');
343    
344            isPreviewLoading = true;
345            isPreviewAnimate = true;
346            previewSpinner.css({display:'block'}).stop().fadeTo(300, 1);
347            
348            img = new Image();
349            img.src = previewArray[currIndex][0];
350            
351            img.onload = function () {
352                isPreviewLoading = false;
353                previewSpinner.stop().fadeTo(300, 0, function(){ $(this).css({display:'none'}); })
354                
355                primaryImage = $('>.imgBlock', primaryImageHolder);
356                if(!options.liteMode){ primaryImage.css('background-image', 'url(' + img.src + ')'); } else { primaryImage.attr('src', img.src); }
357                objectResize(primaryImage, _windowWidth, _baseHeight);
358
359                objectCssTransition(primaryImageHolder, options.duration, 'outCubic');
360                primaryImageHolder.removeClass('animateState');
361                objectCssTransition(secondarImageHolder, options.duration, 'outCubic');
362                secondarImageHolder.addClass('animateState');
363    
364                objectCssTransition(primaryCaption, options.duration, 'outCubic');
365                primaryCaption.removeClass('animateState');
366                objectCssTransition(secondaryCaption, options.duration, 'outCubic');
367                secondaryCaption.addClass('animateState');
368    
369                mainCaptionHolderContainer.height(primaryCaption.height());
370    
371                setTimeout(
372                    function(){                        
373                        secondarImage = $('>.imgBlock', secondarImageHolder);
374                        if(!options.liteMode){ secondarImage.css('background-image', 'url(' + img.src + ')'); } else { secondarImage.attr('src', img.src); }      
375                        objectResize(secondarImage, _windowWidth, _baseHeight);
376                        
377                        objectCssTransition(secondarImageHolder, 0, 'ease');
378                        secondarImageHolder.removeClass('animateState');
379                        
380                        secondaryCaption.html(previewArray[currIndex][2]);
381                        objectCssTransition(secondaryCaption, 0, 'ease');
382                        secondaryCaption.removeClass('animateState');
383    
384                        isPreviewAnimate = false;
385                    }, options.duration
386                )
387            }
388        }
389    
390        //----------------------------------------------------//
391        function objectCssTransition(obj, duration, ease){
392            var durationValue;
393    
394            if(duration !== 0){
395                durationValue = duration/1000;
396            }else{
397                durationValue = 0
398            }
399    
400            switch(ease){
401                case 'ease':
402                        obj.css({"-webkit-transition":"all "+durationValue+"s ease", "-moz-transition":"all "+durationValue+"s ease", "-o-transition":"all "+durationValue+"s ease", "transition":"all "+durationValue+"s ease"});
403                break;
404                case 'outSine':
405                    obj.css({"-webkit-transition":"all "+durationValue+"s cubic-bezier(0.470, 0.000, 0.745, 0.715)", "-moz-transition":"all "+durationValue+"s cubic-bezier(0.470, 0.000, 0.745, 0.715)", "-o-transition":"all "+durationValue+"s cubic-bezier(0.470, 0.000, 0.745, 0.715)", "transition":"all "+durationValue+"s cubic-bezier(0.470, 0.000, 0.745, 0.715)"});
406                break;
407                case 'outCubic':
408                    obj.css({"-webkit-transition":"all "+durationValue+"s cubic-bezier(0.215, 0.610, 0.355, 1.000)", "-moz-transition":"all "+durationValue+"s cubic-bezier(0.215, 0.610, 0.355, 1.000)", "-o-transition":"all "+durationValue+"s cubic-bezier(0.215, 0.610, 0.355, 1.000)", "transition":"all "+durationValue+"s cubic-bezier(0.215, 0.610, 0.355, 1.000)"});
409                break;
410                case 'outExpo':
411                    obj.css({"-webkit-transition":"all "+durationValue+"s cubic-bezier(0.190, 1.000, 0.220, 1.000)", "-moz-transition":"all "+durationValue+"s cubic-bezier(0.190, 1.000, 0.220, 1.000)", "-o-transition":"all "+durationValue+"s cubic-bezier(0.190, 1.000, 0.220, 1.000)", "transition":"all "+durationValue+"s cubic-bezier(0.190, 1.000, 0.220, 1.000)"});
412                break;
413                case 'outBack':
414                    obj.css({"-webkit-transition":"all "+durationValue+"s cubic-bezier(0.175, 0.885, 0.320, 1.275)", "-moz-transition":"all "+durationValue+"s cubic-bezier(0.175, 0.885, 0.320, 1.275)", "-o-transition":"all "+durationValue+"s cubic-bezier(0.175, 0.885, 0.320, 1.275)", "transition":"all "+durationValue+"s cubic-bezier(0.175, 0.885, 0.320, 1.275)"});
415                break;
416            }
417        }
418        
419        //------------------------ Object resize ----------------------------//
420        function objectResize(obj, baseWidth, baseHeight )
421        {
422            var imageRatio,
423                originalImgWidth,
424                originalImgHeight,
425                newImgWidth,
426                newImgHeight,
427                newImgTop,
428                newImgLeft;
429            
430            originalImgWidth = img.width;
431            originalImgHeight = img.height;
432    
433            imageRatio = originalImgHeight/originalImgWidth;
434            containerRatio = baseHeight/baseWidth;
435    
436            if(containerRatio > imageRatio){
437                newImgHeight = baseHeight;
438                newImgWidth = Math.round( (newImgHeight*originalImgWidth) / originalImgHeight );   
439            }else{
440                newImgWidth = baseWidth;
441                newImgHeight = Math.round( (newImgWidth*originalImgHeight) / originalImgWidth );
442            }
443    
444            newImgLeft=-(newImgWidth-baseWidth)*.5;
445            newImgTop= -(newImgHeight-baseHeight)*.5;
446            
447            if(!options.liteMode){ obj.css({width: '100%', height: newImgHeight, marginTop: newImgTop}); } else { obj.css({width: newImgWidth, height: newImgHeight, marginTop: newImgTop, marginLeft: newImgLeft}); }
448        }
449        
450        //------------------- main window scroll function -------------------//
451        function mainScrollFunction(){
452             if(parallax || options.scrolling_description && !options.liteMode){
453                
454                 var _documentScrollTop
455                 ,   startScrollTop
456                 ,   endScrollTop
457                 ;
458     
459                 _documentScrollTop = _document.scrollTop();
460                 _thisOffsetTop = _this.offset().top;
461     
462                 startScrollTop = _documentScrollTop + _windowHeight;
463                 endScrollTop = _documentScrollTop - _thisHeight;
464     
465                 if((startScrollTop > _thisOffsetTop) && (endScrollTop < _thisOffsetTop)){  
466                     
467                     y = _documentScrollTop - _thisOffsetTop;
468                     
469                     if(parallax){
470                         if(!options.parallaxInvert) {
471                             newPositionTop =  parseInt(y / bufferRatio);
472                         } else {
473                             if(_thisOffsetTop < Math.abs(_windowHeight-_thisHeight)){
474                                 newPositionTop = -parseInt(y / bufferRatio) - parseInt(_thisOffsetTop / bufferRatio);
475                             } else{
476                                 newPositionTop = -parseInt(y / bufferRatio) - parseInt(_windowHeight / bufferRatio)
477                             }
478                         }
479                         
480                         mainImageHolder.css({ top: newPositionTop + 'px' });   
481                     }
482                     
483                     if(options.scrolling_description){
484                         description_opacity = (1-(y / _thisHeight)).toFixed(2); 
485                         if(description_opacity < 1) mainCaptionHolder.css('opacity', description_opacity);
486                         
487                         description_offset = parseInt(y/2.5);
488                         if(description_offset > 0) {
489                             mainCaptionHolder.css('top', description_offset);
490                         } else {
491                             mainCaptionHolder.css('top', '0px');   
492                         }
493                     }
494                 }
495             }
496        }
497        
498        //------------------- main window resize function -------------------//
499        function mainResizeFunction(){
500            _windowWidth = _window.width();
501            _windowHeight = _window.height();
502            _thisWidth = _this.width();
503            _thisHeight = _this.height();
504            _thisOffsetTop = _this.offset().top;
505            
506            _baseHeight = getBaseHeight();
507            objectResize(imgBlock, _thisWidth, _baseHeight);
508            mainScrollFunction();
509        }
510
511        //------------------- get heigth function -------------------//
512        function getBaseHeight(){
513            switch (parallaxType) {
514                case 'parallax_normal':
515                    if(_thisOffsetTop < (_windowHeight-_thisHeight)){
516                       baseHeight = _thisHeight + parseInt(_thisOffsetTop/bufferRatio); 
517                    } else {
518                       baseHeight = _thisHeight + parseInt((_windowHeight - _thisHeight)/bufferRatio);
519                    }                   
520                    break
521                    
522                case 'parallax_invert':
523                    if(_thisOffsetTop < Math.abs(_windowHeight-_thisHeight)){
524                       baseHeight = _thisHeight + parseInt((_thisOffsetTop + _thisHeight)/bufferRatio); 
525                    } else {
526                       baseHeight = _thisHeight + parseInt((_windowHeight + _thisHeight)/bufferRatio);
527                    }
528                    break
529                    
530                case 'parallax_fixes':
531                    if((_thisOffsetTop + _thisHeight) < _windowHeight){
532                        baseHeight = _thisOffsetTop + _thisHeight;
533                    } else {
534                        baseHeight = _windowHeight;
535                    }
536                    break
537                    
538                case 'parallax_none':
539                    baseHeight = _thisHeight;
540                    break
541            }
542            
543            return baseHeight;
544        }
545        
546        function toRadians (angle) {
547            return angle * (Math.PI / 180);
548        }        
549    }
550})(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.