Difference between revisions of "Template:Team:TU Darmstadt/Js"

Line 1: Line 1:
 +
// START ScrollBox
 +
 
$(window).scroll(function(e) {
 
$(window).scroll(function(e) {
 
   var $element = $('.scrollbox');
 
   var $element = $('.scrollbox');
Line 23: Line 25:
 
   }, 400);
 
   }, 400);
 
}
 
}
 +
 +
// END ScrollBox
 +
 +
// START Breakpoint Stuff
 +
 +
(function($) {
 +
 +
skel.breakpoints({
 +
wide: '(max-width: 1680px)',
 +
normal: '(max-width: 1280px)',
 +
narrow: '(max-width: 980px)',
 +
narrower: '(max-width: 840px)',
 +
mobile: '(max-width: 736px)',
 +
mobilep: '(max-width: 480px)'
 +
});
 +
 +
$(function() {
 +
 +
var $window = $(window),
 +
$body = $('body');
 +
 +
// Disable animations/transitions until the page has loaded.
 +
$body.addClass('is-loading');
 +
 +
$window.on('load', function() {
 +
$body.removeClass('is-loading');
 +
});
 +
 +
// Fix: Placeholder polyfill.
 +
$('form').placeholder();
 +
 +
// Prioritize "important" elements on narrower.
 +
skel.on('+narrower -narrower', function() {
 +
$.prioritize(
 +
'.important\\28 narrower\\29',
 +
skel.breakpoint('narrower').active
 +
);
 +
});
 +
 +
// Dropdowns.
 +
$('#nav > ul').dropotron({
 +
offsetY: -15,
 +
hoverDelay: 0,
 +
alignment: 'center'
 +
});
 +
 +
// Off-Canvas Navigation.
 +
 +
// Title Bar.
 +
$(
 +
'<div id="titleBar">' +
 +
'<a href="#navPanel" class="toggle"></a>' +
 +
'<span class="title">' + $('#logo').html() + '</span>' +
 +
'</div>'
 +
)
 +
.appendTo($body);
 +
 +
// Navigation Panel.
 +
$(
 +
'<div id="navPanel">' +
 +
'<nav>' +
 +
$('#nav').navList() +
 +
'</nav>' +
 +
'</div>'
 +
)
 +
.appendTo($body)
 +
.panel({
 +
delay: 500,
 +
hideOnClick: true,
 +
hideOnSwipe: true,
 +
resetScroll: true,
 +
resetForms: true,
 +
side: 'left',
 +
target: $body,
 +
visibleClass: 'navPanel-visible'
 +
});
 +
 +
// Fix: Remove navPanel transitions on WP<10 (poor/buggy performance).
 +
if (skel.vars.os == 'wp' && skel.vars.osVersion < 10)
 +
$('#titleBar, #navPanel, #page-wrapper')
 +
.css('transition', 'none');
 +
 +
});
 +
 +
})(jQuery);
 +
 +
// END Breakpoint stuff

Revision as of 13:17, 12 October 2016

// START ScrollBox

$(window).scroll(function(e) {

 var $element = $('.scrollbox');
 var headerHeight = $('#head').outerHeight();
 var isFixed = ($element.css('position') == 'fixed');
 if ($(this).scrollTop() > headerHeight) {
   if(!isFixed) {
       console.log('scroll');
       $element.addClass("scrolled");
   }
 }
 if ($(this).scrollTop() < headerHeight) {
   if(isFixed) {
       console.log('dont scroll');
       $element.removeClass("scrolled");
   }
 }

});

function scrollToTop() {

 $('body,html').animate({
   scrollTop: 0
 }, 400);

}

// END ScrollBox

// START Breakpoint Stuff

(function($) {

skel.breakpoints({ wide: '(max-width: 1680px)', normal: '(max-width: 1280px)', narrow: '(max-width: 980px)', narrower: '(max-width: 840px)', mobile: '(max-width: 736px)', mobilep: '(max-width: 480px)' });

$(function() {

var $window = $(window), $body = $('body');

// Disable animations/transitions until the page has loaded. $body.addClass('is-loading');

$window.on('load', function() { $body.removeClass('is-loading'); });

// Fix: Placeholder polyfill. $('form').placeholder();

// Prioritize "important" elements on narrower. skel.on('+narrower -narrower', function() { $.prioritize( '.important\\28 narrower\\29', skel.breakpoint('narrower').active ); });

// Dropdowns. $('#nav > ul').dropotron({ offsetY: -15, hoverDelay: 0, alignment: 'center' });

// Off-Canvas Navigation.

// Title Bar. $(

'
' +

'<a href="#navPanel" class="toggle"></a>' + '' + $('#logo').html() + '' +

'
'

) .appendTo($body);

// Navigation Panel. $(

''

) .appendTo($body) .panel({ delay: 500, hideOnClick: true, hideOnSwipe: true, resetScroll: true, resetForms: true, side: 'left', target: $body, visibleClass: 'navPanel-visible' });

// Fix: Remove navPanel transitions on WP<10 (poor/buggy performance). if (skel.vars.os == 'wp' && skel.vars.osVersion < 10) $('#titleBar, #navPanel, #page-wrapper') .css('transition', 'none');

});

})(jQuery);

// END Breakpoint stuff