script.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. function divisionnav() {
  2. $('.navigation li:nth-child(n+4)').wrapAll("<div class='cc' />")
  3. }
  4. function activenav() {
  5. // Cache selectors
  6. var lastId,
  7. topMenu = $(".navigation"),
  8. topMenuHeight = topMenu.outerHeight()+500,
  9. // All list items
  10. menuItems = topMenu.find("a"),
  11. // Anchors corresponding to menu items
  12. scrollItems = menuItems.map(function(){
  13. var item = $($(this).attr("href"));
  14. if (item.length) { return item; }
  15. });
  16. // Bind click handler to menu items
  17. // so we can get a fancy scroll animation
  18. // Bind to scroll
  19. $(window).scroll(function(){
  20. // Get container scroll position
  21. var fromTop = $(this).scrollTop()+topMenuHeight;
  22. // Get id of current scroll item
  23. var cur = scrollItems.map(function(){
  24. if ($(this).offset().top < fromTop)
  25. return this;
  26. });
  27. // Get the id of the current element
  28. cur = cur[cur.length-1];
  29. var id = cur && cur.length ? cur[0].id : "";
  30. if (lastId !== id) {
  31. lastId = id;
  32. // Set/remove active class
  33. menuItems
  34. .parent().removeClass("active")
  35. .end().filter("[href='#"+id+"']").parent().addClass("active");
  36. }
  37. });
  38. };
  39. function fullpage() {
  40. $('#start').fullpage({
  41. anchors: ['home', 'fullvideo', 'vidéos', 'biographie', 'photographie', 'presse', 'prochaines_dates', 'contact'],
  42. scrollOverflow: true
  43. });
  44. };
  45. $(document).ready(function() {
  46. fullpage();
  47. activenav();
  48. });