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