Created
June 17, 2018 10:06
-
-
Save matt-barker/b695173fbd5939e3def9dd1da37c97b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$(function(){ | |
$('body').addClass('testPage') | |
}) | |
</script> | |
<script> | |
$(document).ready(function(){ | |
$('.header-slideshow').closest('.code-block').next('.sqs-block-gallery').addClass('header-slideshow-block'); | |
$('.Parallax-host .Parallax-item').eq(0).addClass('header-slideshow-host'); | |
$('.header-slideshow-host img').css('display','none'); | |
$('.header-slideshow-block').appendTo('.header-slideshow-host .Index-page-image'); | |
$('.header-slideshow-host').append('<div class="slideshow-buttons"></div>'); | |
for (i=0; i<$('.header-slideshow-block .slide').length; i++) { | |
$('.slideshow-buttons').append('<span class="slideshow-button"></span>'); | |
} | |
var resizeSlideshow = function(){ | |
var containerHeight=$('.header-slideshow-host .Index-page-image').outerHeight(), | |
containerWidth=$('.header-slideshow-host .Index-page-image').outerWidth(), windowWidth=$(window).width(), imageWidth=$('.header-slideshow-host img').eq(0).width(); | |
console.log('Container height: '+containerHeight); | |
console.log('Container width: '+containerWidth); | |
console.log('Window width: '+windowWidth); | |
console.log('Image width: '+imageWidth); | |
if (windowWidth <=1200) { | |
$('.header-slideshow-host .sqs-gallery').css('height',containerHeight); | |
$('.header-slideshow-host .sqs-gallery .slide img').css('height',containerHeight); | |
$('.header-slideshow-host .sqs-gallery .slide img').css('width','auto'); | |
} else { | |
$('.header-slideshow-host .sqs-gallery').css('height',containerHeight); | |
$('.header-slideshow-host .sqs-gallery .slide img').css('width',containerWidth); | |
$('.header-slideshow-host .sqs-gallery .slide img').css('height','auto'); | |
} | |
}; | |
$(window).ready(function(){ | |
resizeSlideshow(); | |
var myVar = setInterval(buttonTimer, 500); | |
function buttonTimer(){ | |
var activeSlide = $('.header-slideshow-host .sqs-gallery .slide.sqs-active-slide'), | |
activeIndex = $('.header-slideshow-host .sqs-gallery .slide').index(activeSlide); | |
$('.header-slideshow-host .slideshow-button').removeClass('active'); | |
$('.header-slideshow-host .slideshow-button').eq(activeIndex).addClass('active'); | |
}//buttonTimer | |
});//window.ready | |
var resizeTimer; | |
$(window).on('resize', function(e) { | |
clearTimeout(resizeTimer); | |
resizeTimer = setTimeout(function() { | |
resizeSlideshow(); | |
}, 250); | |
}); | |
console.log($('.header-slideshow-block .slide').length); | |
}); | |
</script> | |
<style> | |
.header-slideshow-block img { | |
left:50%!important; | |
transform:translateX(-50%); | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment