1(function($){ 2 $.fn.parallaxSlider=function(o) 3 { 4 5 var options = { 6 prevButton: $('.prevButton') 7 , nextButton: $('.nextButton') 8 , duration: 1000 9 , autoSwitcher: true 10 , autoSwitcherDelay: 7000 11 , slider_navs: true 12 , scrolling_description: false 13 , slider_pagination: 'buttons_pagination' 14 , animateLayout: 'zoom-fade-eff' //simple-fade-eff, zoom-fade-eff, slide-top-eff 15 , parallaxEffect: 'parallax_effect_normal' 16 , parallaxInvert: false 17 , liteMode: false 18 } 19 $.extend(options, o); 20 21 var 22 _this = $(this) 23 , _window = $(window) 24 , _document = $(document) 25 , sliderData = new Array() 26 , itemLength = 0 27 , currIndex 28 , prevIndex 29 , isPreviewLoading = false 30 , isPreviewAnimate = false 31 , intervalSwitcher 32 33 , obj_inner 34 , mainImageHolder 35 , primaryImageHolder 36 , secondarImageHolder 37 , mainCaptionHolder 38 , primaryCaption 39 , secondaryCaption 40 , mainCaptionHolderContainer 41 , previewSpinner 42 , parallaxPrevBtn 43 , parallaxNextBtn 44 , slidesCounterList 45 , paralaxSliderPagination 46 , progressBar 47 , youtubeApiLoad = false 48 , vimeoApiLoad = false 49 50 , parallax = true 51 , parallaxType = 'parallax_normal' 52 , _baseHeight 53 , _thisOffsetTop = _this.offset().top 54 , _thisHeight = _this.height() 55 , _windowWidth = _window.width() 56 , _windowHeight = _window.height() 57 , originalWidth = 0 58 , originalHeight = 0 59 , bufferRatio 60 ; 61 62 63 // parse slider data 64 $('ul li', _this).each( 65 function() 66 { 67 var this_slide = $(this), 68 slideData = new Object(), 69 slide_type = 'image', 70 image = this_slide.attr('data-preview'), 71 thumb = this_slide.attr('data-thumb-url'), 72 caption = this_slide.html(), 73 link = this_slide.attr('data-ulr-link'), 74 mp4_src = this_slide.attr('data-video-src-mp4'), 75 webm_src = this_slide.attr('data-video-src-webm'), 76 ogv_src = this_slide.attr('data-video-src-ogv'), 77 video_loader = this_slide.attr('data-video-preloader'), 78 video_mute = this_slide.attr('data-video-mute'), 79 youtube_id = this_slide.attr('data-video-youtube-id'), 80 vimeo_id = this_slide.attr('data-video-vimeo-id'); 81 82 if (mp4_src || webm_src || ogv_src) slide_type = 'library_video'; 83 if (youtube_id) { 84 slide_type = 'youtube_video'; 85 youtubeApiLoad = true 86 } 87 if (vimeo_id) { 88 slide_type = 'vimeo_video'; 89 vimeoApiLoad = true 90 } 91 if (options.liteMode) slide_type = 'image'; 92 93 slideData = 94 { 95 slide_type: slide_type, 96 image: image, 97 thumb: thumb, 98 caption: caption, 99 link: link, 100 library_video: 101 { 102 mp4_src: mp4_src, 103 webm_src: webm_src, 104 ogv_src: ogv_src, 105 video_mute: video_mute, 106 video_loader: video_loader, 107 video_loaded: false, 108 }, 109 youtube_video: 110 { 111 youtube_id: youtube_id, 112 video_mute: video_mute, 113 }, 114 vimeo_video: 115 { 116 vimeo_id: vimeo_id, 117 video_mute: video_mute, 118 } 119 }; 120 121 sliderData.push(slideData); 122 } 123 ) 124 125 // if necessary, load the youtube and vimeo API 126 if(youtubeApiLoad) 127 $.getScript( 'https://www.youtube.com/iframe_api', function( ) { 128 if(sliderData[0].slide_type == 'youtube_video') 129 window.onYouTubeIframeAPIReady = function() { 130 init(); 131 } 132 }); 133 if(vimeoApiLoad) 134 $.getScript( '//f.vimeocdn.com/js/froogaloop2.min.js', function( ) { 135 if(sliderData[0].slide_type == 'vimeo_video') init(
135); 136 }); 137 138 139 if(sliderData[0].slide_type != 'youtube_video' && sliderData[0].slide_type != 'vimeo_video') init(); 140 141 142 function init() 143 { 144 // holder erase 145 _this.html(''); 146 _this.addClass(options.animateLayout); 147 148 // preview holder build 149 _this.append("<div id='mainImageHolder'></div>"); 150 mainImageHolder = $('#mainImageHolder'); 151 152 // caption holder build 153 _this.append("<div id='mainCaptionHolder'><div class='container'></div></div>"); 154 mainCaptionHolder = $('#mainCaptionHolder'); 155 mainCaptionHolderContainer = $('>.container', mainCaptionHolder); 156 157 // controls build 158 _this.append("<div class='controlBtn parallaxPrevBtn'><div class='innerBtn flaticon-keyboard54'></div></div><div class='controlBtn parallaxNextBtn'><div class='innerBtn flaticon-keyboard53'></div></div>"); 159 parallaxPrevBtn = $('.parallaxPrevBtn', _this); 160 parallaxNextBtn = $('.parallaxNextBtn', _this); 161 162 // fullpreview pagination build 163 _this.append("<div id='paralaxSliderPagination'><ul></ul></div>"); 164 paralaxSliderPagination = $('#paralaxSliderPagination'); 165 166 slidesCounterList = $('.slidesCounter', _this); 167 168 // preview loader build 169 _this.append("<div id='previewSpinner'><span></span></div>"); 170 previewSpinner = $('#previewSpinner'); 171 172 _this.on("reBuild", 173 function(e,d){ 174 setBuilder(d); 175 } 176 ) 177 178 _this.on("switchNext", 179 function(e){ 180 nextSwither(); 181 } 182 ) 183 184 _this.on("switchPrev", 185 function(e){ 186 prevSwither(); 187 } 188 ) 189 190 if(options.liteMode) options.parallaxEffect = 'parallax_none'; 191 192 switch (options.parallaxEffect) { 193 case 'parallax_effect_low': 194 if(!options.parallaxInvert){ 195 parallaxType = 'parallax_normal'; 196 } else { 197 parallaxType = 'parallax_invert'; 198 } 199 200 bufferRatio = 3; 201 202 break 203 204 case 'parallax_effect_normal': 205 if(!options.parallaxInvert){ 206 parallaxType = 'parallax_normal'; 207 } else { 208 parallaxType = 'parallax_invert'; 209 } 210 211 bufferRatio = 2.25; 212 213 break 214 215 case 'parallax_effect_high': 216 if(!options.parallaxInvert){ 217 parallaxType = 'parallax_normal'; 218 } else { 219 parallaxType = 'parallax_invert'; 220 } 221 222 bufferRatio = 1.5; 223 224 break 225 226 case 'parallax_effect_fixed': 227 if(isIE()){ 228 parallax = false; 229 } else { 230 parallaxType = 'parallax_fixes'; 231 } 232 233 bufferRatio = 1; 234 235 break 236 237 default: 238 parallax = false; 239 parallaxType = 'parallax_none'; 240 241 break 242 } 243 244 _baseHeight = getBaseHeight(); 245 246 247 setBuilder(); 248 249 if(!options.slider_navs){ 250 parallaxPrevBtn.remove(); 251 parallaxNextBtn.remove(); 252 } 253 if(options.slider_pagination == 'none_pagination'){ 254 paralaxSliderPagination.remove(); 255 } 256 257 258 addEventsFunction(); 259 autoSwitcher(); 260 } 261 262 //------------------------- set Builder -----------------------------//
263 function setBuilder() 264 { 265 currIndex = 0; 266 itemLength = sliderData.length; 267 268 $(">ul", paralaxSliderPagination).empty(); 269 270 switch (options.slider_pagination) { 271 case 'buttons_pagination': 272 paralaxSliderPagination.addClass('buttons_pagination'); 273 for (var i = 0; i < itemLength; i++) { 274 $(">ul", paralaxSliderPagination).append("<li></li>"); 275 }; 276 277 break 278 279 case 'images_pagination': 280 paralaxSliderPagination.addClass('images_pagination'); 281 for (var i = 0; i < itemLength; i++) { 282 $(">ul", paralaxSliderPagination).append("<li><img src='"+sliderData[i].thumb+"'></li>"); 283 }; 284 285 break 286 } 287 288 if(itemLength==1){ 289 paralaxSliderPagination.remove(); 290 parallaxPrevBtn.remove(); 291 parallaxNextBtn.remove(); 292 } 293 294 imageSwitcher(0); 295 addEventsPagination(); 296 } 297 298 function autoSwitcher() 299 { 300 if(options.autoSwitcher){ 301 if(itemLength>1){ 302 intervalSwitcher = setInterval(function(){ 303 nextSwither(); 304 }, options.autoSwitcherDelay); 305 } 306 } 307 } 308 309 //--------------- addEvents ----------------------// 310 function addEventsPagination() 311 { 312 $(">ul >li", paralaxSliderPagination).on("click", 313 function() 314 { 315 if((!isPreviewLoading) && (!isPreviewAnimate) && ($(this).index() !== currIndex)){ 316 clearInterval(intervalSwitcher); 317 prevIndex = currIndex; 318 currIndex = $(this).index(); 319 imageSwitcher(currIndex); 320 } 321 } 322 ) 323 } 324 325 function addEventsFunction() 326 { 327 //--------------- controls events ----------------------// 328 options.prevButton.on("click", 329 function() 330 { 331 clearInterval(intervalSwitcher); 332 prevSwither(); 333 } 334 ) 335 options.nextButton.on("click", 336 function() 337 { 338 clearInterval(intervalSwitcher); 339 nextSwither(); 340 } 341 ) 342 parallaxPrevBtn.on("click", 343 function() 344 { 345 clearInterval(intervalSwitcher); 346 prevSwither(); 347 } 348 ) 349 parallaxNextBtn.on("click", 350 function() 351 { 352 clearInterval(intervalSwitcher); 353 nextSwither(); 354 } 355 ) 356 357 //--------------- keyboard events ----------------------// 358 _window.on("keydown", 359 function(eventObject) 360 { 361 switch (eventObject.keyCode){ 362 case 37: 363 clearInterval(intervalSwitcher); 364 prevSwither(); 365 break 366 case 39: 367 clearInterval(intervalSwitcher); 368 nextSwither(); 369 break 370 } 371 } 372 ) 373 374 //------------------ window scroll event -------------// 375 $(window).on('scroll', 376 function() 377 { 378 mainScrollFunction(); 379 } 380 ).trigger('scroll'); 381 382 //------------------ window resize event -------------// 383 $(window).on("resize", 384 function() 385 { 386 mainResizeFunction(); 387 } 388 ) 389 } 390 391 //----------------------------------------------------------------- 392 function prevSwither() 393 { 394 if(!isPreviewLoading && !isPreviewAnimate){ 395 prevIndex = currIndex; 396 if(currIndex > 0){ 397 currIndex--; 398 }else{ 399 currIndex = itemLength-1; 400 } 401 imageSwitcher(currIndex); 402 } 403 } 404 function nextSwither() 405 { 406 if(!isPreviewLoading && !isPreviewAnimate){ 407 prevIndex = currIndex; 408 if(currIndex < itemLength-1){ 409 currIndex++; 410 }else{ 411 currIndex = 0; 412 } 413 imageSwitcher(currIndex); 414 } 415 } 416 417 //------------------------- main Swither ----------------------------// 418 function imageSwitcher(currIndex) 419 { 420 // add next ImageHolder 421 if(primaryImageHolder){ 422 secondarImageHolder = primaryImageHolder; 423 secondarImageHolder.toggleClass('primaryHolder').toggleClass('secondaryHolder'); 424 } 425 426 mainImageHolder.append('<div class="primaryHolder"></div>'); 427 primaryImageHolder = $('> .primaryHolder', mainImageHolder); 428 objectCssTransition(primaryImageHolder, 0, 'ease'); 429 primaryImageHolder.addClass('animateState'); 430 431 432 // add next CaptionHolder 433 mainCaptionHolder.find('>a').remove(); 434 435 if(primaryCaption){ 436 secondaryCaption = primaryCaption; 437 secondaryCaption.toggleClass('primaryCaption').toggleClass('secondaryCaption'); 438 } 439
440 if(sliderData[currIndex].caption != ''){ 441 mainCaptionHolderContainer.append('<div class="primaryCaption"></div>'); 442 primaryCaption = $('> .primaryCaption', mainCaptionHolderContainer); 443 primaryCaption.html(sliderData[currIndex].caption); 444 objectCssTransition(primaryCaption, 0, 'ease'); 445 primaryCaption.addClass('animateState'); 446 } 447 if(sliderData[currIndex].link != '') mainCaptionHolder.append('<a href="'+sliderData[currIndex].link+'"></a>'); 448 449 slidesCounterList.text((currIndex+1) + '/'+itemLength); 450 $(">ul >li", paralaxSliderPagination).removeClass('active').eq(currIndex).addClass('active'); 451 452 isPreviewLoading = true; 453 isPreviewAnimate = true; 454 previewSpinner.css({display:'block'}).stop().fadeTo(300, 1); 455 456 if(progressBar) progressBar.remove(); 457 458 //------------------------- image slide type ----------------------------// 459 if(sliderData[currIndex].slide_type == 'image') 460 { 461 var img = new Image(); 462 img.src = sliderData[currIndex].image; 463 464 img.onload = function () 465 { 466 if(!options.liteMode){ 467 primaryImageHolder.html('<div class="parallax-slider-img obj-inner"></div>'); 468 obj_inner = $('.parallax-slider-img', primaryImageHolder); 469 obj_inner.css('background-image', 'url(' + img.src + ')'); 470 } else { 471 primaryImageHolder.html('<img class="parallax-slider-img obj-inner" src="'+img.src+'" alt=""/>'); 472 obj_inner = $('.parallax-slider-img', primaryImageHolder); 473 } 474 475 if(isIE()) obj_inner.css({backgroundAttachment:'fixed'}); 476 477 originalWidth = img.width; 478 originalHeight = img.height; 479 objectResize(obj_inner, primaryImageHolder.width(), _baseHeight); 480 481 onSlideLoaded(); 482 } 483 484 } 485 //------------------------- library video slide type ----------------------------// 486 if(sliderData[currIndex].slide_type == 'library_video') 487 { 488 if(sliderData[currIndex].library_video.player){ 489 490 var videoElement = sliderData[currIndex].library_video.player; 491 492 } else { 493 494 var videoElement = document.createElement('video'); 495 496 videoElement.className = 'parallax-slider-video obj-inner'; 497 videoElement.setAttribute('loop','loop'); 498 videoElement.setAttribute('poster', sliderData[currIndex].image); 499 if(sliderData[currIndex].library_video.video_mute) videoElement.muted = true; 500 501 function addSourceToVideo(element, src, type) 502 { 503 if(src) 504 { 505 var source = document.createElement('source'); 506 507 source.src = src; 508 source.type = type; 509 510 element.appendChild(source); 511 } 512 } 513 514 addSourceToVideo(videoElement, sliderData[currIndex].library_video.mp4_src, 'video/mp4'); 515 addSourceToVideo(videoElement, sliderData[currIndex].library_video.webm_src, 'video/webm'); 516 addSourceToVideo(videoElement, sliderData[currIndex].library_video.ogv_src, 'video/ogv'); 517 518 videoElement.load(); 519 520 sliderData[currIndex].library_video.player = videoElement; 521 } 522 523 primaryImageHolder.get(0).appendChild(videoElement); 524 obj_inner = $('.parallax-slider-video', primaryImageHolder); 525 526 videoElement.play(); 527 528 originalWidth = 0; 529 originalHeight = 0; 530 originalWidth = videoElement.videoWidth; 531 originalHeight = videoElement.videoHeight; 532 533 var img = new Image(); 534 img.src = sliderData[currIndex].image; 535 536 img.onload = function () 537 { 538 originalWidth = originalWidth==0 ? img.width : originalWidth; 539 originalHeight = originalHeight==0 ? img.height : originalHeight; 540 objectResize(obj_inner, primaryImageHolder.width(), _baseHeight); 541 542 onSlideLoaded(); 543 } 544 545 videoElement.onloadedmetadata = function() 546 { 547 originalWidth = videoElement.videoWidth; 548 originalHeight = videoElement.videoHeight; 549 objectResize(obj_inner, primaryImageHolder.width(), _baseHeight); 550 } 551 552 videoLoaded = sliderData[currIndex].library_video.video_loaded; 553 554 if(sliderData[currIndex].library_video.video_loader && !videoLoaded) 555 { 556 _this.append('<div class="parallax-slider-video-progress-bar"><div class="parallax-slider-video-progress"></div></div>'); 557 progressBar = $('.parallax-slider-video-progress-bar', _this); 558 progressLine = $('.parallax-slider-video-progress', progressBar); 559 560 var updateProgressBar = function() 561 { 562 if(videoElement.buffered.length > 0) { 563 if(videoElement.played.length > 0) progressBar.css({background:'#000'}); 564 if(videoElement.buffered.end(0) == videoElement.duration){ 565 clearTimeout(watchBuffer); 566 sliderData[currIndex].library_video.video_loaded = true; 567 progressLine.width('100%'); 568 progressBar.stop().delay(1000).animate({top:'-15px'}, 1000, function(){ 569 progressBar.remove(); 570 }); 571 }else{ 572 progressLine.width(((videoElement.buffered.end(0) / videoElement.duration) * 100) + '%'); 573 } 574 } 575 }; 576 var watchBuffer = setInterval(updateProgressBar, 500); 577 } 578 } 579 //------------------------- youtube video slide type ----------------------------// 580 if(sliderData[currIndex].slide_type == 'youtube_video') 581 { 582 var youtube_id = sliderData[currIndex].youtube_video.youtube_id; 583 584 primaryImageHolder.html('<div id="parallax-slider-youtube-video'+currIndex+'" class="parallax-slider-youtube-video obj-inner"></div>'); 585 586 function onPlayerReady(event) 587 { 588 event.target.playVideo(); 589 590 var intervalID; 591 intervalID = setInterval(function(){ 592 if(youtubePlayer.getPlayerState() == 1){ 593 clearInterval(intervalID); 594 onSlideLoaded(); 595 } 596 }, 100); 597 598 if(sliderData[currIndex].youtube_video.video_mute) youtubePlayer.mute(); 599 } 600 601 originalWidth = 16; 602 originalHeight = 9; 603 604 var youtubePlayer = new YT.Player('parallax-slider-youtube-video'+currIndex+'', { 605 height: '0px',
606 width: '0px', 607 playerVars : { 608 'autoplay' : 1, 609 'showinfo' : 0, 610 'controls' : 0, 611 'loop' : 1, 612 'iv_load_policy' : 3, 613 'modestbranding ' : 1, 614 'disablekb' : 1, 615 'enablejsapi' : 1, 616 'html5' : isIE() ? 1 : 0, 617 'playlist': youtube_id 618 }, 619 videoId: youtube_id, 620 events: { 621 'onReady': onPlayerReady 622 } 623 }); 624 625 obj_inner = $('#parallax-slider-youtube-video'+currIndex+'', primaryImageHolder); 626 objectResize(obj_inner, primaryImageHolder.width(), _baseHeight); 627 628 sliderData[currIndex].youtube_video.player = youtubePlayer; 629 630 } 631 //------------------------- vimeo video slide type ----------------------------// 632 if(sliderData[currIndex].slide_type == 'vimeo_video') 633 { 634 var vimeo_id = sliderData[currIndex].vimeo_video.vimeo_id, 635 vimeo_iframe, 636 vimeo_player, 637 vimeo_player_playstarted = false; 638 639 primaryImageHolder.html('<div class="parallax-slider-vimeo-video obj-inner"><iframe id="vimeo-player-'+currIndex+'" class="parallax-slider-vimeo-iframe" src="http://player.vimeo.com/video/'+vimeo_id+'?api=1&player_id=vimeo-player-'+currIndex+';autoplay=1&loop=1" frameborder="0"></iframe></div>'); 640 641 vimeo_iframe = $('#vimeo-player-'+currIndex+'')[0]; 642 vimeo_player = $f(vimeo_iframe); 643 644 sliderData[currIndex].vimeo_video.player = vimeo_player; 645 646 vimeo_player.addEvent('ready', function() { 647 if(sliderData[currIndex].vimeo_video.video_mute) vimeo_player.api('setVolume', 0); 648 vimeo_player.addEvent('play', function(){ 649 if(!vimeo_player_playstarted) 650 { 651 vimeo_player_playstarted = true; 652 653 originalWidth = 16; 654 originalHeight = 9; 655 656 obj_inner = $('.obj-inner', primaryImageHolder); 657 objectResize(obj_inner, primaryImageHolder.width(), _baseHeight); 658 659 setTimeout(onSlideLoaded, 500); 660 } 661 }); 662 }) 663 } 664 665 function onSlideLoaded() 666 { 667 isPreviewLoading = false; 668 previewSpinner.stop().fadeTo(300, 0, function(){ $(this).css({display:'none'}); }); 669 670 objectCssTransition(primaryImageHolder, options.duration, 'outCubic'); 671 primaryImageHolder.removeClass('animateState'); 672 673 if(secondarImageHolder){ 674 if(sliderData[prevIndex].slide_type == 'youtube_video' || sliderData[prevIndex].slide_type == 'vimeo_video'){ 675 setTimeout(function(){ 676 if(sliderData[prevIndex].slide_type == 'youtube_video') sliderData[prevIndex].youtube_video.player.stopVideo(); 677 if(sliderData[prevIndex].slide_type == 'vimeo_video') sliderData[prevIndex].vimeo_video.player.api('unload'); 678 }, options.duration/1.25) 679 } 680 681 objectCssTransition(secondarImageHolder, options.duration, 'outCubic'); 682 secondarImageHolder.addClass('animateState'); 683 } 684 685 objectCssTransition(primaryCaption, options.duration, 'outCubic'); 686 if(primaryCaption){ 687 688 primaryCaption.removeClass('animateState'); 689 } 690 691 if(secondaryCaption){ 692 objectCssTransition(secondaryCaption, options.duration, 'outCubic'); 693 secondaryCaption.addClass('animateState'); 694 } 695 696 setTimeout(function() 697 { 698 if(secondarImageHolder) secondarImageHolder.remove(); 699 if(secondaryCaption) secondaryCaption.remove(); 700 701 isPreviewAnimate = false;
702 703 }, options.duration ) 704 } 705 } 706 707 //----------------------------------------------------// 708 function objectCssTransition(obj, duration, ease) 709 { 710 if(objectExists(obj)) 711 { 712 var durationValue; 713 714 if(duration !== 0){ 715 durationValue = duration/1000; 716 }else{ 717 durationValue = 0 718 } 719 720 switch(ease){ 721 case 'ease': 722 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"}); 723 break; 724 case 'outSine': 725 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)"}); 726 break; 727 case 'outCubic': 728 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)"}); 729 break; 730 case 'outExpo': 731 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)"}); 732 break; 733 case 'outBack': 734 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)"}); 735 break; 736 } 737 } 738 } 739 740 //------------------------ Object resize ----------------------------// 741 function objectResize(obj, baseWidth, baseHeight) 742 { 743 if(objectExists(obj)) 744 { 745 var imageRatio, 746 newImgWidth, 747 newImgHeight, 748 newImgTop, 749 newImgLeft; 750 751 imageRatio = originalHeight/originalWidth; 752 containerRatio = baseHeight/baseWidth; 753 754 if(containerRatio > imageRatio){ 755 newImgHeight = baseHeight; 756 newImgWidth = Math.round( (newImgHeight*originalWidth) / originalHeight ); 757 }else{ 758 newImgWidth = baseWidth; 759 newImgHeight = Math.round( (newImgWidth*originalHeight) / originalWidth ); 760 } 761 762 newImgLeft=-(newImgWidth-baseWidth)*.5; 763 newImgTop= -(newImgHeight-baseHeight)*.5; 764 765 if(obj.prop('tagName').toLowerCase() == 'div'){ obj.css({width: '100%', height: newImgHeight, marginTop: newImgTop}); } else { obj.css({width: newImgWidth, height: newImgHeight, marginTop: newImgTop, marginLeft: newImgLeft}); } 766 767 if(sliderData[currIndex].slide_type == 'vimeo_video'){ 768 obj.find('.parallax-slider-vimeo-iframe').css({width: newImgWidth, height: newImgHeight+200, marginLeft: newImgLeft}); 769 } 770 } 771 } 772 773 function objectExists(object){ 774 if(object){ 775 if(object.length > 0) return true; 776 } 777 } 778 779 //------------------- main window scroll function -------------------// 780 function mainScrollFunction(){ 781 if(parallax || options.scrolling_description && !options.liteMode){ 782 783 var _documentScrollTop 784 , startScrollTop 785 , endScrollTop 786 ; 787 788 _documentScrollTop = _document.scrollTop(); 789 _thisOffsetTop = _this.offset().top; 790 791 startScrollTop = _documentScrollTop + _windowHeight; 792 endScrollTop = _documentScrollTop - _thisHeight; 793 794 if((startScrollTop > _thisOffsetTop) && (endScrollTop < _thisOffsetTop)){ 795 796 y = _documentScrollTop - _thisOffsetTop; 797 798 if(parallax){ 799 if(!options.parallaxInvert) { 800 newPositionTop = parseInt(y / bufferRatio); 801 } else { 802 if(_thisOffsetTop < Math.abs(_windowHeight-_thisHeight)){ 803 newPositionTop = -parseInt(y / bufferRatio) - parseInt(_thisOffsetTop / bufferRatio); 804 } else{ 805 newPositionTop = -parseInt(y / bufferRatio) - parseInt(_windowHeight / bufferRatio) 806 } 807 } 808 809 mainImageHolder.css({"transform": "translate3d(0px, " + newPositionTop + "px, 0px)"}); 810 } 811 812 if(options.scrolling_description){ 813 description_opacity = (1-(y / _thisHeight)).toFixed(2); 814 if(description_opacity < 1) mainCaptionHolder.css('opacity', description_opacity); 815 816 description_offset = parseInt(y/2.5); 817 if(description_offset > 0) { 818 mainCaptionHolder.css({"transform": "translate3d(0px, " + description_offset + "px, 0px)"}); 819 } else { 820 mainCaptionHolder.css({"transform": "translate3d(0px, 0px, 0px)"}); 821 } 822 } 823 } 824 } 825 } 826 827 //------------------- main window resize function -------------------// 828 function mainResizeFunction(){ 829 _windowWidth = _window.width(); 830 _windowHeight = _window.height(); 831 _thisWidth = _this.width(); 832 _thisHeight = _this.height(); 833 _thisOffsetTop = _this.offset().top; 834 835 _baseHeight = getBaseHeight(); 836 objectResize(obj_inner, _thisWidth, _baseHeight); 837 mainScrollFunction(); 838 } 839 840 //------------------- get heigth function -------------------// 841 function getBaseHeight(){ 842 843 switch (parallaxType) { 844 case 'parallax_normal': 845 if(_thisOffsetTop < (_windowHeight-_thisHeight)){ 846 baseHeight = _thisHeight + parseInt(_thisOffsetTop/bufferRatio); 847 } else { 848 baseHeight = _thisHeight + parseInt((_windowHeight - _thisHeight)/bufferRatio); 849 } 850 break 851 852 case 'parallax_invert': 853 if(_thisOffsetTop < Math.abs(_windowHeight-_thisHeight)){ 854 baseHeight = _thisHeight + parseInt((_thisOffsetTop + _thisHeight)/bufferRatio); 855 } else { 856 baseHeight = _thisHeight + parseInt((_windowHeight + _thisHeight)/bufferRatio); 857 } 858 break 859 860 case 'parallax_fixes': 861 if((_thisOffsetTop + _thisHeight) < _windowHeight){ 862 baseHeight = _thisOffsetTop + _thisHeight; 863 } else { 864 baseHeight = _windowHeight; 865 } 866 break 867 868 case 'parallax_none': 869 baseHeight = _thisHeight; 870 break 871 } 872 873 return baseHeight; 874 } 875 876 function toRadians (angle) { 877 return angle * (Math.PI / 180); 878 } 879 880 function isIE() { 881 if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) { 882 return true; 883 }else{ 884 return false;
885 } 886 } 887 888 function loadScript(url, callback){ 889 $.ajax({ 890 url: url, 891 dataType: 'script', 892 success: callback, 893 async: true 894 }); 895 } 896 } 897})(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.