Sarah igem (Talk | contribs) (Created page with "$(document).ready(function() { $('.discover').click(function() { console.log('entra'); $('#intro').toggle(); $('#maindesc').toggle(); }); }); $(window).sc...") |
Sarah igem (Talk | contribs) |
||
Line 1: | Line 1: | ||
+ | function myFunction() { | ||
+ | var element = document.getElementById("intro"); | ||
+ | |||
+ | if (element.classList) { | ||
+ | element.classList.toggle("hidden"); | ||
+ | } else { | ||
+ | var classes = element.className.split(" "); | ||
+ | var i = classes.indexOf("hidden"); | ||
+ | |||
+ | if (i >= 0) | ||
+ | classes.splice(i, 1); | ||
+ | else | ||
+ | classes.push("hidden"); | ||
+ | element.className = classes.join(" "); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function appear() { | ||
+ | var element = document.getElementById("maindesc"); | ||
+ | |||
+ | if (element.classList) { | ||
+ | element.classList.toggle("visible"); | ||
+ | } else { | ||
+ | var classes = element.className.split(" "); | ||
+ | var i = classes.indexOf("visible"); | ||
+ | |||
+ | if (i >= 0) | ||
+ | classes.splice(i, 1); | ||
+ | else | ||
+ | classes.push("visible"); | ||
+ | element.className = classes.join(" "); | ||
+ | } | ||
+ | } | ||
+ | |||
$(document).ready(function() { | $(document).ready(function() { | ||
− | + | $('.discover').click(function() { | |
− | + | myFunction(); | |
− | + | appear(); | |
− | + | ||
− | + | ||
}); | }); | ||
+ | }); | ||
− | + | $(window).scroll(function() { | |
− | + | var hT = $('#scroll-to').offset().top, | |
− | + | hH = $('#scroll-to').outerHeight(), | |
− | + | wH = $(window).height(), | |
− | + | wS = $(this).scrollTop(); | |
− | + | if (wS > (hT+hH-wH) && (hT > wS) && (wS+wH > hT+hH)){ | |
− | + | $('h1').addClass('view') | |
− | + | } else { | |
− | + | $('h1').removeClass('view') | |
− | + | } | |
− | + | }); |
Revision as of 13:47, 26 September 2018
function myFunction() {
var element = document.getElementById("intro");
if (element.classList) { element.classList.toggle("hidden"); } else { var classes = element.className.split(" "); var i = classes.indexOf("hidden");
if (i >= 0) classes.splice(i, 1); else classes.push("hidden"); element.className = classes.join(" "); }
}
function appear() {
var element = document.getElementById("maindesc");
if (element.classList) { element.classList.toggle("visible"); } else { var classes = element.className.split(" "); var i = classes.indexOf("visible");
if (i >= 0) classes.splice(i, 1); else classes.push("visible"); element.className = classes.join(" "); }
}
$(document).ready(function() { $('.discover').click(function() { myFunction(); appear(); }); });
$(window).scroll(function() {
var hT = $('#scroll-to').offset().top,
hH = $('#scroll-to').outerHeight(), wH = $(window).height(), wS = $(this).scrollTop();
if (wS > (hT+hH-wH) && (hT > wS) && (wS+wH > hT+hH)){
$('h1').addClass('view')
} else {
$('h1').removeClass('view')
}
});