antimatter.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. var isTouch = window.DocumentTouch && document instanceof DocumentTouch;
  2. function scrollHeader() {
  3. // Has scrolled class on header
  4. var zvalue = $(document).scrollTop();
  5. if ( zvalue > 75 )
  6. $("#header").addClass("scrolled");
  7. else
  8. $("#header").removeClass("scrolled");
  9. }
  10. jQuery(document).ready(function($){
  11. //bouton "voir plus de ressources"
  12. // $("a.bouton-ouverture").removeAttr("href"); // On supprime le lien de notre bouton
  13. $('.bouton-ouverture').on('click', function(){ // lorsqu'on clique sur le bouton
  14. $('.texte-cache').toggleClass('ouvert'); // On ajoute ou retire la classe CSS "ouvert"
  15. if ($('.texte-cache').hasClass('ouvert')) { // Si le module texte a la classe "ouvert"
  16. $('.bouton-ouverture').html('Voir MOINS'); // On affiche LIRE MOINS sur le bouton
  17. } else {
  18. $('.bouton-ouverture').html('Voir PLUS'); // Sinon on affiche LIRE PLUS
  19. }
  20. // definir une règle si .texte-cache {max-height}<=.texte-cache.ouvert {max-height}, alors .bouton-ouverture { visible: hidden}
  21. });
  22. // parallax slideshow
  23. $(document).ready(function() {
  24. var imgSrc = ["/user/themes/epau-antimatter/images/Thizy_Les_Bourgs_copyright_Communaute_de_l_Ouest_Rhodanien.jpg", "/user/themes/epau-antimatter/images/ARM161205-001.jpg", "/user/themes/epau-antimatter/images/copyright_Grenoble-Alpes_Metropole-Lucas_Frangella_1.jpg", "/user/themes/epau-antimatter/images/04_photo_ AE_PlanDAou_21.jpg", "/user/themes/epau-antimatter/images/Solideo_041120_Fauchon_Web_copyright_Sennse-cbadet_012.jpg", "/user/themes/epau-antimatter/images/04_photo_ AE_PlanDAou_36.jpg",];
  25. var counter = 1;
  26. var duration = 4000;
  27. var tTime = 0;
  28. var v = setInterval(function() {
  29. $('.parallax-mirror').animate({
  30. 'opacity': 0
  31. }, {
  32. duration: tTime,
  33. complete: function() {
  34. $(this).find('img').attr('src', imgSrc[counter]).end().animate({
  35. 'opacity': 1
  36. }, tTime);
  37. }
  38. });
  39. if (counter > imgSrc.length - 1) {
  40. counter = 0
  41. } else {
  42. counter++
  43. };
  44. },
  45. duration);
  46. });
  47. // ON SCROLL EVENTS
  48. if (!isTouch){
  49. $(document).scroll(function() {
  50. scrollHeader();
  51. });
  52. };
  53. // TOUCH SCROLL
  54. $(document).on({
  55. 'touchmove': function(e) {
  56. scrollHeader(); // Replace this with your code.
  57. }
  58. });
  59. //Smooth scroll to top
  60. $('#toTop').click(function(){
  61. $("html, body").animate({ scrollTop: 0 }, 500);
  62. return false;
  63. });
  64. // Responsive Menu
  65. // POPIN Biographies
  66. $(".bouton").click(function(event){
  67. console.log(event);
  68. //
  69. var mods = document.querySelectorAll('.modal');
  70. mods.forEach((m, i) => {
  71. m.classList.remove('open')
  72. });
  73. //
  74. var btn = event.currentTarget;
  75. console.log('btn', btn);
  76. var mod = btn.parentNode.querySelector('.modal');
  77. mod.classList.add('open')
  78. });
  79. $(".modal .mask, .modal a.close").click(function(event){
  80. $ (".modal").removeClass("open");
  81. return false;
  82. });
  83. });
  84. // Animation souligné if inView
  85. function isScrolledIntoView(elem) {
  86. var docViewTop = $(window).scrollTop();
  87. var docViewBottom = docViewTop + $(window).height();
  88. var elemTop = $(elem).offset().top;
  89. var elemBottom = elemTop + $(elem).height();
  90. return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
  91. }
  92. $(window).scroll(function () {
  93. $('.souligne.toleft').each(function () {
  94. if (isScrolledIntoView(this) === true) {
  95. $(this).addClass('in-view')
  96. } else {
  97. $(this).removeClass('in-view')
  98. }
  99. });
  100. $('.souligne.toright').each(function () {
  101. if (isScrolledIntoView(this) === true) {
  102. $(this).addClass('in-view-right')
  103. } else {
  104. $(this).removeClass('in-view-right')
  105. }
  106. });
  107. });