Difference between revisions of "Template:Navarra BG/js/funciones"

(Created page with "$(document).ready(function() { $('.discover').click(function() { console.log('entra'); $('#intro').toggle(); $('#maindesc').toggle(); }); }); $(window).sc...")
 
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() {
+
$('.discover').click(function() {
console.log('entra');
+
myFunction();  
$('#intro').toggle();
+
appear();
$('#maindesc').toggle();
+
});
+
 
});
 
});
 +
});
  
$(window).scroll(function() {
+
$(window).scroll(function() {
  var hT = $('#scroll-to').offset().top,
+
  var hT = $('#scroll-to').offset().top,
  hH = $('#scroll-to').outerHeight(),
+
  hH = $('#scroll-to').outerHeight(),
  wH = $(window).height(),
+
  wH = $(window).height(),
  wS = $(this).scrollTop();
+
  wS = $(this).scrollTop();
  if (wS > (hT+hH-wH) && (hT > wS) && (wS+wH > hT+hH)){
+
  if (wS > (hT+hH-wH) && (hT > wS) && (wS+wH > hT+hH)){
  $('h1').addClass('view')
+
  $('h1').addClass('view')
  } else {
+
  } else {
  $('h1').removeClass('view')
+
  $('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')

  }

});