-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
145 lines (132 loc) · 4.23 KB
/
script.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
$(document).ready(function() {
// Utils
(function prepareMenu() {
var menu = document.getElementById("menu");
menu.onclick = function(event) {
styles = getComputedStyle(event.target.parentNode);
transform = styles.getPropertyValue("transform");
var values = transform.split('(')[1].split(')')[0].split(',');
var a = values[0];
var b = values[1];
var c = values[2];
var d = values[3];
var scale = Math.sqrt(a * a + b * b);
var sin = b / scale;
var angle = Math.round(Math.atan2(b, a) * (180 / Math.PI));
log(angle);
var rotateAngle = 60 - angle;
menu.style.transform = "rotate(" + rotateAngle + "deg)";
};
})();
function log(msg) {
console.warn('\n start: ••••• 🔥 •••••');
console.log(msg);
console.warn(' end: ¶¶¶¶¶ 💩 ¶¶¶¶¶ \n');
};
// Application state/models
var state = {
currSection: 'home'
};
Object.defineProperty(state, 'active', {
set: function(val) {
this.currSection = val;
$('#menu li a')
.removeClass('active-menu')
.filter(function(index) {
return $(this).parent().attr('class') === val;
})
.addClass('active-menu');
$('#quick-menu .quick-btn')
.removeClass('active-main')
.filter(function() {
return $(this).attr("for") === val;
})
.addClass('active-main');
},
get: function() {
return this.currSection;
},
enumerable: true,
configurable: true
});
// Vendor initialization (fullpage.js, typed.js)
var emulateTyping = function(options) {
if (typeof options !== "object")
throw new Error('options must be an object');
var typedStrings = "";
if (options.hasOwnProperty('typedStrings'))
typedStrings = options['typedStrings'];
$('#fullpage .description').hide()
$("#fullpage .typed-element").typed({
strings: typedStrings,
typeSpeed: 20,
backSpeed: 20,
startDelay: 0,
backDelay: 500,
shuffle: false, // shuffle the strings
loop: false,
// loopCount: false, // false = infinite
showCursor: true,
cursorChar: "🁢",
contentType: 'html', // or 'text'
callback: function() { // call when done
$('#fullpage .typed-element').hide();
$('#fullpage .typed-cursor').hide();
$('#fullpage .description').show();
}
});
};
$('#fullpage').fullpage({
anchors: [
"objective", "work", "education",
"skills", "projects", "random"
],
onLeave: function(idx, nIdx, direction) {
// log('do some computation on current screen');
},
afterLoad: function(anchorLink, idx) {
log("first loaded!");
state.active = "work";
// rotate circle menu
var menu = document.getElementById('menu'),
angle = idx - 1 <= 3 ? 60*(idx - 1) : (60*(idx - 1) - 360),
rotateAngle = 60 - angle;
menu.style.transform = "rotate(" + rotateAngle + "deg)";
// reset prev/next button state
var currIdx = idx;
$('#main .btn').show();
if (currIdx === 1) {
$('#main .upper').hide();
} else if (currIdx === 6) {
$('#main .lower').hide();
}
$('#main').hover(function mouseIn() {
$('.btn', this).show();
if (currIdx === 1) {
$('#main .upper').hide();
} else if (currIdx === 6) {
$('#main .lower').hide();
}
}, function mouseOut() {
$('.btn', this).hide();
});
}
});
emulateTyping({
typedStrings: [
"To be rather <strong>simple</strong>",
"I promise <strong>NOT</strong> to pull down the <strong>average</strong> <i>IQ</i> of my team",
"Oh, wait, just kidding ヽ(´▽`)/ ............."
],
});
// Event handlers
$('#quick-menu label').on('click', function(e) {
var targetSection = $(this).attr('for').trim();
$.fn.fullpage.moveTo(targetSection);
});
$('#main .upper').on('click', function(e) {
$.fn.fullpage.moveSectionUp();
});
$('#main .lower').on('click', function(e) { $.fn.fullpage.moveSectionDown();
});
});