mirror of
https://github.com/felixfoertsch/wordpress-dev-env.git
synced 2026-04-18 07:18:43 +02:00
70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
/*
|
|
|--------------------------------------------------------------------------
|
|
| UItoTop jQuery Plugin 1.2 by Matt Varone
|
|
| http://www.mattvarone.com/web-design/uitotop-jquery-plugin/
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
(function($){
|
|
$.fn.UItoTop = function(options) {
|
|
|
|
var defaults = {
|
|
text: 'To Top',
|
|
min: 200,
|
|
inDelay:600,
|
|
outDelay:400,
|
|
containerID: 'toTop',
|
|
containerHoverID: 'toTopHover',
|
|
scrollSpeed: 1200,
|
|
easingType: 'linear'
|
|
},
|
|
settings = $.extend(defaults, options),
|
|
containerIDhash = '#' + settings.containerID,
|
|
containerHoverIDHash = '#'+settings.containerHoverID;
|
|
|
|
$('body').append('<a href="#" id="'+settings.containerID+'">'+settings.text+'</a>');
|
|
$(containerIDhash).hide().on('click.UItoTop',function(){
|
|
$('#debug-menu-targets').animate({scrollTop:0}, settings.scrollSpeed, settings.easingType);
|
|
$('#'+settings.containerHoverID, this).stop().animate({'opacity': 0 }, settings.inDelay, settings.easingType);
|
|
return false;
|
|
})
|
|
.prepend('<span id="'+settings.containerHoverID+'"></span>')
|
|
.hover(function() {
|
|
$(containerHoverIDHash, this).stop().animate({
|
|
'opacity': 1
|
|
}, 600, 'linear');
|
|
}, function() {
|
|
$(containerHoverIDHash, this).stop().animate({
|
|
'opacity': 0
|
|
}, 700, 'linear');
|
|
});
|
|
|
|
$('#debug-menu-targets').scroll(function() {
|
|
var sd = $('#debug-menu-targets').scrollTop();
|
|
if(typeof document.body.style.maxHeight === "undefined") {
|
|
$(containerIDhash).css({
|
|
'position': 'absolute',
|
|
'top': sd + $(window).height() - 50
|
|
});
|
|
}
|
|
if ( sd > settings.min ) {
|
|
$(containerIDhash).fadeIn(settings.inDelay);
|
|
}
|
|
else {
|
|
$(containerIDhash).fadeOut(settings.Outdelay);
|
|
}
|
|
});
|
|
};
|
|
})(jQuery);
|
|
|
|
|
|
jQuery(document).ready(function() {
|
|
/*
|
|
var defaults = {
|
|
containerID: 'toTop', // fading element id
|
|
containerHoverID: 'toTopHover', // fading element hover id
|
|
scrollSpeed: 1200,
|
|
easingType: 'linear'
|
|
};
|
|
*/
|
|
jQuery('#debug-menu-target-Debug_Bar_PHP_Constants').UItoTop({ easingType: 'swing', scrollSpeed: 300 });
|
|
}); |