-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprojet.js
74 lines (63 loc) · 2.14 KB
/
projet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
$(document).ready(function() {
$(".menu-icon").on("click", function() {
$("nav ul").toggleClass("showing");
});
});
// Scrolling Effect
$(window).on("scroll", function() {
if($(window).scrollTop()) {
$('nav').addClass('black');
}
else {
$('nav').removeClass('black');
}
})
/*scroll_text*/
(function($){
$.fn.typer = function(text, options){
options = $.extend({}, {
char: '',
delay: 2000,
duration: 600,
endless: true,
onType: $.noop,
afterAll: $.noop,
afterPhrase: $.noop
}, options || text);
text = $.isPlainObject(text) ? options.text : text;
text = $.isArray(text) ? text : text.split(" ");
return this.each(function(){
var elem = $(this),
isVal = {input:1, textarea:1}[this.tagName.toLowerCase()],
isTag = false,
timer,
c = 0;
(function typetext(i) {
var e = ({string:1, number:1}[typeof text] ? text : text[i]) + '',
char = e.substr(c++, 1);
if( char === '<' ){ isTag = true; }
if( char === '>' ){ isTag = false; }
elem[isVal ? "val" : "html"](e.substr(0, c) + ($.isFunction(options.char) ? options.char() : options.char || ' '));
if(c <= e.length){
if( isTag ){
typetext(i);
} else {
timer = setTimeout(typetext, options.duration/10, i);
}
options.onType(timer);
} else {
c = 0;
i++;
if (i === text.length && !options.endless) {
return;
} else if (i === text.length) {
i = 0;
}
timer = setTimeout(typetext, options.delay, i);
if(i === text.length - 1) options.afterAll(timer);
options.afterPhrase(timer);
}
})(0);
});
};
}(jQuery));