Reshuffle dirs
This commit is contained in:
parent
e56ab9d4ab
commit
629e543ef4
73 changed files with 105 additions and 2110 deletions
98
doc/template/resources/javascripts/jquery-scrollspy.js
vendored
Normal file
98
doc/template/resources/javascripts/jquery-scrollspy.js
vendored
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*!
|
||||
* jQuery Scrollspy Plugin
|
||||
* Author: @sxalexander
|
||||
* Licensed under the MIT license
|
||||
*/
|
||||
|
||||
|
||||
;(function ( $, window, document, undefined ) {
|
||||
|
||||
$.fn.extend({
|
||||
scrollspy: function ( options ) {
|
||||
|
||||
var defaults = {
|
||||
min: 0,
|
||||
max: 0,
|
||||
mode: 'vertical',
|
||||
buffer: 0,
|
||||
container: window,
|
||||
onEnter: options.onEnter ? options.onEnter : [],
|
||||
onLeave: options.onLeave ? options.onLeave : [],
|
||||
onTick: options.onTick ? options.onTick : []
|
||||
}
|
||||
|
||||
var options = $.extend( {}, defaults, options );
|
||||
|
||||
return this.each(function (i) {
|
||||
|
||||
var element = this;
|
||||
var o = options;
|
||||
var $container = $(o.container);
|
||||
var mode = o.mode;
|
||||
var buffer = o.buffer;
|
||||
var enters = leaves = 0;
|
||||
var inside = false;
|
||||
|
||||
/* add listener to container */
|
||||
$container.bind('scroll', function(e){
|
||||
var position = {top: $(this).scrollTop(), left: $(this).scrollLeft()};
|
||||
var xy = (mode == 'vertical') ? position.top + buffer : position.left + buffer;
|
||||
var max = o.max;
|
||||
var min = o.min;
|
||||
|
||||
/* fix max */
|
||||
if($.isFunction(o.max)){
|
||||
max = o.max();
|
||||
}
|
||||
|
||||
/* fix max */
|
||||
if($.isFunction(o.min)){
|
||||
min = o.min();
|
||||
}
|
||||
|
||||
if(max == 0){
|
||||
max = (mode == 'vertical') ? $container.height() : $container.outerWidth() + $(element).outerWidth();
|
||||
}
|
||||
|
||||
/* if we have reached the minimum bound but are below the max ... */
|
||||
if(xy >= o.min && xy <= max){
|
||||
/* trigger enter event */
|
||||
if(!inside){
|
||||
inside = true;
|
||||
enters++;
|
||||
|
||||
/* fire enter event */
|
||||
$(element).trigger('scrollEnter', {position: position})
|
||||
if($.isFunction(o.onEnter)){
|
||||
o.onEnter(element, position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* triger tick event */
|
||||
$(element).trigger('scrollTick', {position: position, inside: inside, enters: enters, leaves: leaves})
|
||||
if($.isFunction(o.onTick)){
|
||||
o.onTick(element, position, inside, enters, leaves);
|
||||
}
|
||||
}else{
|
||||
|
||||
if(inside){
|
||||
inside = false;
|
||||
leaves++;
|
||||
/* trigger leave event */
|
||||
$(element).trigger('scrollLeave', {position: position, leaves:leaves})
|
||||
|
||||
if($.isFunction(o.onLeave)){
|
||||
o.onLeave(element, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
})( jQuery, window );
|
||||
Loading…
Add table
Add a link
Reference in a new issue