grav/themes/quark-open-publishing/js/site.js

73 lines
1.9 KiB
JavaScript
Raw Normal View History

var isTouch = window.DocumentTouch && document instanceof DocumentTouch;
function scrollHeader() {
// Has scrolled class on header
var zvalue = $(document).scrollTop();
if ( zvalue > 75 )
$("#header").addClass("scrolled");
else
$("#header").removeClass("scrolled");
}
function parallaxBackground() {
$('.parallax').css('background-positionY', ($(window).scrollTop() * 0.3) + 'px');
}
jQuery(document).ready(function($){
scrollHeader();
// Scroll Events
if (!isTouch){
$(document).scroll(function() {
scrollHeader();
parallaxBackground();
});
};
// Touch scroll
$(document).on({
'touchmove': function(e) {
scrollHeader(); // Replace this with your code.
}
});
//Smooth scroll to start
$('#to-start').click(function(){
var start_y = $('#start').position().top;
var header_offset = 45;
window.scroll({ top: start_y - header_offset, left: 0, behavior: 'smooth' });
return false;
});
//Smooth scroll to top
$('#to-top').click(function(){
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
return false;
});
// Responsive Menu
$('#toggle').click(function () {
$(this).toggleClass('active');
$('#overlay').toggleClass('open');
$('body').toggleClass('mobile-nav-open');
});
// Tree Menu
$(".tree").treemenu({delay:300});
});
document.querySelectorAll( 'oembed[url]' ).forEach( element => {
// Create the <a href="..." class="embedly-card"></a> element that Embedly uses
// to discover the media.
const anchor = document.createElement( 'a' );
anchor.setAttribute( 'href', element.getAttribute( 'url' ) );
anchor.className = 'embedly-card';
anchor.dataset.cardAlign = 'left';
anchor.dataset.cardControls = 0;
element.appendChild( anchor );
} );