-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimate.js
More file actions
139 lines (115 loc) · 4.85 KB
/
animate.js
File metadata and controls
139 lines (115 loc) · 4.85 KB
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
$(document).ready(function () {
function getRows(selector) {
var height = $(selector).height();
var line_height = $(selector).css('line-height');
line_height = parseFloat(line_height)
var rows = height / line_height;
return Math.round(rows);
}
// Add smooth scrolling to all links
$("a").on('click', function (event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// Prevent default anchor click behavior
event.preventDefault();
// Store hash
var hash = this.hash;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 2000, function () {
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash = hash;
});
} // End if
});
function typeWriter(text, n, loc) {
if (n < (text.length)) {
$(loc).html(text.substring(0, n + 1) + " _");
n++;
setTimeout(function () {
typeWriter(text, n, loc)
}, 50);
}
else {
$(loc).html(text);
return true;
}
}
// $(".jumbotron.quote").css("transition","all .5s linear");
$(function () {
var bgimage = new Image();
bgimage.src = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Mount_Everest_as_seen_from_Drukair2_PLW_edit.jpg/1280px-Mount_Everest_as_seen_from_Drukair2_PLW_edit.jpg";
$(bgimage).on('load', function () {
var text = '"Throw me into the wolves and I will return leading the pack."';
var text2 = "- Seneca"
// $(".twr").html(text);
// var countlines = getRows(".twr")
// $(".tw2").html(text2);
// var countlines2 = getRows(".twr")
$(".twr").html('<br>');
$(".tw2").html('<br>');
var text = '"Throw me into the wolves and I will return leading the pack."';
var text2 = "- Seneca"
$(".jumbotron.quote").slideDown(1500);
// $(".jumbotron.quote").show();
// $(".jumbotron.quote").css("height","0px");
// $(".jumbotron.quote").animate({height: "500px"});
setTimeout(function () {
// $(".jumbotron.quote").css("transition","all .5s linear");
typeWriter(text, 0, ".twr");
setTimeout(function () {
typeWriter(text2, 0, ".tw2")
}, 5000);
}, 1500);
});
});
//TODO: ANCHORS ARE GOING TO BLANK SCREEN
var isMobile = window.matchMedia("(max-width: 760px)");
if (!isMobile.matches) {
var controller = new ScrollMagic.Controller();
// create a scene
// Create Animation for 0.5s
var tween = TweenMax.staggerFrom('.recent-shapes', 1, {
y: "-50%",
ease: Power1.easeInOut,
opacity: 0,
repeat: 0,
scale: 1
}, 0.3);
var scene = new ScrollMagic.Scene({
duration: $('#profile-card').outerHeight()/2, // the scene should last for a scroll distance of 100px
triggerElement: '#profile-card', // starting scene, when reaching this element
triggerHook: "onEnter",
}) .offset($('#profile-card').outerHeight()/2)
.setTween(tween)
// .addIndicators()
.addTo(controller); // assign the scene to the controller
var triggerHook = scene.triggerHook();
// set a new triggerHook using a string
scene.triggerHook($(".navbar").height() / $(window).height());
var controller = new ScrollMagic.Controller();
// create a scene
// Create Animation for 0.5s
var tween = TweenMax.staggerFrom('.work-e-shapes', 1, {
y: "-50%",
ease: Power1.easeInOut,
opacity: 0,
repeat: 0,
scale: 0.5
}, 0.3);
var scene = new ScrollMagic.Scene({
duration: $('#recent-projects-jumbotron').outerHeight()/1, // the scene should last for a scroll distance of 100px
triggerElement: '#recent-projects-jumbotron', // starting scene, when reaching this element
triggerHook: "onEnter",
})
.offset($('#recent-projects-jumbotron').outerHeight()/2)
.setTween(tween)
// .addIndicators()
.addTo(controller); // assign the scene to the controller
var triggerHook = scene.triggerHook();
// set a new triggerHook using a string
scene.triggerHook($(".navbar").height() / $(window).height());
}
});