entdecke.wikipedia.de/assets/js/waypoints.js

7 lines
12 KiB
JavaScript
Raw Normal View History

2024-01-12 15:39:06 +00:00
/*
Waypoints - 4.0.1
Copyright © 2011-2016 Caleb Troughton
Licensed under the MIT license.
https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
*/
(function(){var keyCounter=0;var allWaypoints={};function Waypoint(options){if(!options){throw new Error("No options passed to Waypoint constructor")}if(!options.element){throw new Error("No element option passed to Waypoint constructor")}if(!options.handler){throw new Error("No handler option passed to Waypoint constructor")}this.key="waypoint-"+keyCounter;this.options=Waypoint.Adapter.extend({},Waypoint.defaults,options);this.element=this.options.element;this.adapter=new Waypoint.Adapter(this.element);this.callback=options.handler;this.axis=this.options.horizontal?"horizontal":"vertical";this.enabled=this.options.enabled;this.triggerPoint=null;this.group=Waypoint.Group.findOrCreate({name:this.options.group,axis:this.axis});this.context=Waypoint.Context.findOrCreateByElement(this.options.context);if(Waypoint.offsetAliases[this.options.offset]){this.options.offset=Waypoint.offsetAliases[this.options.offset]}this.group.add(this);this.context.add(this);allWaypoints[this.key]=this;keyCounter+=1}Waypoint.prototype.queueTrigger=function(direction){this.group.queueTrigger(this,direction)};Waypoint.prototype.trigger=function(args){if(!this.enabled){return}if(this.callback){this.callback.apply(this,args)}};Waypoint.prototype.destroy=function(){this.context.remove(this);this.group.remove(this);delete allWaypoints[this.key]};Waypoint.prototype.disable=function(){this.enabled=false;return this};Waypoint.prototype.enable=function(){this.context.refresh();this.enabled=true;return this};Waypoint.prototype.next=function(){return this.group.next(this)};Waypoint.prototype.previous=function(){return this.group.previous(this)};Waypoint.invokeAll=function(method){var allWaypointsArray=[];for(var waypointKey in allWaypoints){allWaypointsArray.push(allWaypoints[waypointKey])}for(var i=0,end=allWaypointsArray.length;i<end;i++){allWaypointsArray[i][method]()}};Waypoint.destroyAll=function(){Waypoint.invokeAll("destroy")};Waypoint.disableAll=function(){Waypoint.invokeAll("disable")};Waypoint.enableAll=function(){Waypoint.Context.refreshAll();for(var waypointKey in allWaypoints){allWaypoints[waypointKey].enabled=true}return this};Waypoint.refreshAll=function(){Waypoint.Context.refreshAll()};Waypoint.viewportHeight=function(){return window.innerHeight||document.documentElement.clientHeight};Waypoint.viewportWidth=function(){return document.documentElement.clientWidth};Waypoint.adapters=[];Waypoint.defaults={context:window,continuous:true,enabled:true,group:"default",horizontal:false,offset:0};Waypoint.offsetAliases={"bottom-in-view":function(){return this.context.innerHeight()-this.adapter.outerHeight()},"right-in-view":function(){return this.context.innerWidth()-this.adapter.outerWidth()}};window.Waypoint=Waypoint}());(function(){function requestAnimationFrameShim(callback){window.setTimeout(callback,1000/60)}var keyCounter=0;var contexts={};var Waypoint=window.Waypoint;var oldWindowLoad=window.onload;function Context(element){this.element=element;this.Adapter=Waypoint.Adapter;this.adapter=new this.Adapter(element);this.key="waypoint-context-"+keyCounter;this.didScroll=false;this.didResize=false;this.oldScroll={x:this.adapter.scrollLeft(),y:this.adapter.scrollTop()};this.waypoints={vertical:{},horizontal:{}};element.waypointContextKey=this.key;contexts[element.waypointContextKey]=this;keyCounter+=1;if(!Waypoint.windowContext){Waypoint.windowContext=true;Waypoint.windowContext=new Context(window)}this.createThrottledScrollHandler();this.createThrottledResizeHandler()}Context.prototype.add=function(waypoint){var axis=waypoint.options.horizontal?"horizontal":"vertical";this.waypoints[axis][waypoint.key]=waypoint;this.refresh()};Context.prototype.checkEmpty=function(){var horizontalEmpty=this.Adapter.isEmptyObject(this.waypoints.horizontal);var verticalEmpty=this.Adapter.isEmptyObject(this.waypoints.vertical);var isWindow=this.element==this.element.window;if(horizontalEmpty&&verticalEmpty&&!isWindow){this.adapter.off(".waypoints");delete contexts[this.key]}};Context.prototype.createThrottledResizeHandler=function(){var self=this;function resizeHandl