Are you wanting the tabs to go back to the default tab when you scroll away from the section so that when the user scrolls back into the section the tabs have reset?
function lt_isInView(sectionname) {
var howFarFromTopWeAre = $(window).scrollTop();
var andWhatsTheBottom = howFarFromTopWeAre + $(window).height();
var sectionPosition = $(sectionname).offset().top;
var sectionBottomPos = sectionPosition + $(sectionname).height();
return ((sectionBottomPos <= andWhatsTheBottom) && (sectionPosition >= howFarFromTopWeAre));
}
$(document).ready(function() {
if(lt_isInView('#New-Look')) {
$('#default-tab').trigger('tap');
console.log('switching to default tab');
}
$(window).scroll(function() {
if(lt_isInView('#New-Look')) {
$('#default-tab').trigger('tap');
console.log('switching to default tab');
}
});
});
I have absolutely no idea if that will work as I didn’t test that. If not, please contact me over Skype and we’ll find the issue and post the solution here later.
I think it worked, but I have multiple sections with tabs and it won’t let me use default-tab on the other sections since it was already used. Thoughts?
Uhm…I’m a total noob when it come to Javascript…but what if you duplicate the entire code you just put into Custom Code, change the ID’s of #New-Look and #default-tab to the corresponding ID’s of the other tab you want to affect?
Take a look at this portion of the code and change the ID’s I talked about above:
$(document).ready(function() {
if(lt_isInView('#New-Look')) {
$('#default-tab').trigger('tap');
console.log('switching to default tab');
}
$(window).scroll(function() {
if(lt_isInView('#New-Look')) {
$('#default-tab').trigger('tap');
console.log('switching to default tab');