PageSourceSearch

https://e-masary.com/plugins/loader/js/main.js

js e-masary.com collected 2026-10-07 14:04:59 UTC 2,376 bytes, 88 lines download raw bytes

1/**
2 * main.js
3 * http://www.codrops.com
4 *
5 * Licensed under the MIT license.
6 * http://www.opensource.org/licenses/mit-license.php
7 * 
8 * Copyright 2014, Codrops
9 * http://www.codrops.com
10 */
11(function() {
12
13	var support = { animations : Modernizr.cssanimations },
14		container = document.getElementById( 'ip-container' ),
15		header = container.querySelector( '.ip-header' ),
16		loader = new PathLoader( document.getElementById( 'ip-loader-circle' ) ),
17		animEndEventNames = { 'WebkitAnimation' : 'webkitAnimationEnd', 'OAnimation' : 'oAnimationEnd', 'msAnimation' : 'MSAnimationEnd', 'animation' : 'animationend' },
18		// animation end event name
19		animEndEventName = animEndEventNames[ Modernizr.prefixed( 'animation' ) ];
20
21	function init() {
22		var onEndInitialAnimation = function() {
23			if( support.animations ) {
24				this.removeEventListener( animEndEventName, onEndInitialAnimation );
25			}
26
27			startLoading();
28		};
29
30		// disable scrolling
31		window.addEventListener( 'scroll', noscroll );
32
33		// initial animation
34		classie.add( container, 'loading' );
35
36		if( support.animations ) {
37			container.addEventListener( animEndEventName, onEndInitialAnimation );
38		}
39		else {
40			onEndInitialAnimation();
41		}
42	}
43
44	function startLoading() {
45		// simulate loading something..
46		var simulationFn = function(instance) {
47			var progress = 0,
48				interval = setInterval( function() {
49					progress = Math.min( progress + Math.random() * 0.1, 1 );
50
51					instance.setProgress( progress );
52
53					// reached the end
54					if( progress === 1 ) {
55						classie.remove( container, 'loading' );
56						classie.add( container, 'loaded' );
57						clearInterval( interval );
58
59						var onEndHeaderAnimation = function(ev) {
60							if( support.animations ) {
61								if( ev.target !== header ) return;
62								this.removeEventListener( animEndEventName, onEndHeaderAnimation );
63							}
64
65							classie.add( document.body, 'layout-switch' );
66							window.removeEventListener( 'scroll', noscroll );
67						};
68
69						if( support.animations ) {
70							header.addEventListener( animEndEventName, onEndHeaderAnimation );
71						}
72						else {
73							onEndHeaderAnimation();
74						}
75					}
76				}, 80 );
77		};
78
79		loader.setProgressFn( simulationFn );
80	}
81	
82	function noscroll() {
83		window.scrollTo( 0, 0 );
84	}
85
86	init();
87
88})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.