diff --git a/assets/css/core.css b/assets/css/core.css index d9ba774..4dc1ad7 100644 --- a/assets/css/core.css +++ b/assets/css/core.css @@ -34,6 +34,12 @@ body svg { overflow: visible; } +img { + user-select: none; + -moz-user-select: none; + -webkit-user-select: none; +} + br { display: none; } diff --git a/assets/js/app.js b/assets/js/app.js index 2cc0339..448d282 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,38 +1,44 @@ -$(document).ready(function(){ - $('a').on('click', function(event) { - if (this.hash !== "") { - event.preventDefault(); - var hash = this.hash; - $('html, body').animate({ - scrollTop: $(hash).offset().top - 80 - }, 800, function(){ - window.location.hash = hash; - }); +$('a[href*="#"]') + // Remove links that don't actually link to anything + .not('[href="#"]') + .not('[href="#0"]') + .click(function(event) { + // On-page links + if ( + location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') + && + location.hostname == this.hostname + ) { + // Figure out element to scroll to + var target = $(this.hash); + target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); + // Does a scroll target exist? + if (target.length) { + // Only prevent default if animation is actually gonna happen + event.preventDefault(); + $('html, body').animate({ + scrollTop: target.offset().top - 80 + }, 800, function() { + // Callback after animation + // Must change focus! + var $target = $(target); + $target.focus(); + if ($target.is(":focus")) { // Checking if the target was focused + return false; + } else { + $target.attr('tabindex','-1'); // Adding tabindex for elements not focusable + $target.focus(); // Set focus again + }; + }); + } } }); -}); - -// $(function() { -// $(window).on('resize', function(e) { -// if (screen.width < screen.height){ -// $('.section--preview').addClass('horizontal'); -// }else{ -// $('.section--preview').removeClass('horizontal'); -// } -// }); -// }) init(); function init() { let state = 0; - // if (screen.width < screen.height){ - // $('.section--preview').addClass('horizontal'); - // }else{ - // $('.section--preview').removeClass('horizontal'); - // } - $('.js-prev-slide').click(function() { if(state - 1 == -1){state = 2;}else{state = state - 1;} swiper(state,0);