1// ------------------------------------------------------------------------------------------- 2// Fullscreen Slideshow 3// 4// extends avia slideshow script with a more sophisticated preloader and fixed size for slider 5// ------------------------------------------------------------------------------------------- 6 7(function($) 8{ 9 "use strict"; 10 11 $.AviaFullscreenSlider = function(options, slider) 12 { 13 this.$slider = $( slider ); 14 this.$inner = this.$slider.find('.avia-slideshow-inner'); 15 this.$innerLi = this.$inner.find('>li'); 16 this.$caption = this.$inner.find('.avia-slide-wrap .caption_container'); 17 this.$win = $( window ); 18 this.isMobile = $.avia_utilities.isMobile; 19 this.property = {}; 20 this.scrollPos = "0"; 21 this.transform3d= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false; 22 this.ticking = false; 23 24 25 if($.avia_utilities.supported.transition === undefined) 26 { 27 $.avia_utilities.supported.transition = $.avia_utilities.supports('transition'); 28 } 29 30 this._init( options ); 31 } 32 33 $.AviaFullscreenSlider.defaults = { 34 35 //height of the slider in percent 36 height: 100, 37 38 //subtract elements from the height 39 subtract: '#wpadminbar, #header, #main>.title_container' 40 41 42 }; 43 44 $.AviaFullscreenSlider.prototype = 45 { 46 _init: function( options ) 47 { 48 var _self = this; 49 //set the default options 50 this.options = $.extend( true, {}, $.AviaFullscreenSlider.defaults, options ); 51 52 if(this.$slider.data('slide_height')) this.options.height = this.$slider.data('slide_height'); 53 54 //if background attachment is set to fixed or scroll disable the parallax effect 55 this.options.parallax_enabled = this.$slider.data('image_attachment') == "" ? true : false; 56 57 //elements that get subtracted from the image height 58 this.$subtract = $(this.options.subtract); 59 60 61 // set the slideshow size 62 this._setSize(); 63 64 // set resizing script on window resize 65 this.$win.on( 'debouncedresize', $.proxy( this._setSize, this) ); 66 67 //parallax scroll if element if leaving viewport 68 setTimeout(function() 69 { 70 if(!_self.isMobile && _self.options.parallax_enabled) //disable parallax scrolling on mobile 71 { 72 _self.$win.on( 'scroll', $.proxy( _self._on_scroll, _self) ); 73 } 74 75 },100); 76 /**/ 77 78 //activate the defaule slider 79 this.$slider.aviaSlider({bg_slider:true}); 80 81 82 }, 83 84 _on_scroll: function(e) 85 { 86 var _self = this; 87 88 if(!_self.ticking) { 89 _self.ticking = true; 90 window.requestAnimationFrame( $.proxy( _self._parallax_scroll, _self) ); 91 } 92 }, 93 94 95 _fetch_properties: function(slide_height) 96 { 97 this.property.offset = this.$slider.offset().top; 98 this.property.wh = this.$win.height(); 99 this.property.height = slide_height || this.$slider.outerHeight(); 100 101 //re-position the slider 102 this._parallax_scroll(); 103 }, 104 105 _setSize: function( ) 106 { 107 if(!$.fn.avia_browser_height) 108 { 109 110 var viewport = this.$win.height(), 111 slide_height = Math.ceil( (viewport / 100) * this.options.height ); 112 113 if(this.$subtract.length && this.options.height == 100) 114 { 115 this.$subtract.each(function() 116 { 117 slide_height -= this.offsetHeight - 0.5; 118 }); 119 } 120 else 121 { 122 slide_height -= 1; 123 } 124 this.$slider.height(slide_height).removeClass('av-default-height-applied'); 125 this.$inner.css('padding',0); 126 } 127 128 129 this._fetch_properties(slide_height); 130 }, 131 132 _parallax_scroll: function(e) 133 { 134 if(this.isMobile || ! this.options.parallax_enabled) return; //disable parallax scrolling on mobile 135 136 var winTop = this.$win.scrollTop(), 137 winBottom = winTop + this.property.wh, 138 scrollPos = "0", 139 prop = {}, prop2 = {}; 140 141 if(this.property.offset < winTop && winTop <= this.property.offset + this.property.height) 142 { 143 scrollPos = Math.round( (winTop - this.property.offset) * 0.3 ); 144 } 145 146 if(this.scrollPos != scrollPos) 147 { 148 //slide background parallax 149 this.scrollPos = scrollPos; 150 151 //currently no 3d transform, because of browser quirks 152 //this.transform3d = false;
153 154 if(this.transform3d) 155 { 156 prop[$.avia_utilities.supported.transition+"transform"] = "translate3d(0px,"+ scrollPos +"px,0px)"; 157 } 158 else 159 { 160 prop[$.avia_utilities.supported.transition+"transform"] = "translate(0px,"+ scrollPos +"px)"; 161 } 162 163 164 this.$inner.css(prop); 165 166 167 168 //slider caption parallax 169 170 // prop2[$.avia_utilities.supported.transition+"transform"] = "translate(0px,-"+ ( scrollPos * 1) +"px)"; 171 /* 172 prop2['opacity'] = Math.ceil((this.$slider.height() - (scrollPos * 2)) / 100)/ 10; 173 prop2['opacity'] = prop2['opacity'] < 0 ? 0 : prop2['opacity']; 174 this.$caption.css(prop2); 175 */ 176 } 177 178 this.ticking = false; 179 } 180 }; 181 182 183 184 $.fn.aviaFullscreenSlider = function( options ) 185 { 186 return this.each(function() 187 { 188 var active = $.data( this, 'aviaFullscreenSlider' ); 189 190 if(!active) 191 { 192 //make sure that the function doesnt get aplied a second time 193 $.data( this, 'aviaFullscreenSlider', 1 ); 194 195 //create the preparations for fullscreen slider 196 new $.AviaFullscreenSlider( options, this ); 197 } 198 }); 199 } 200 201})(jQuery); 202
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.