Add project files.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
let thresholds = [];
|
||||
for (let i = 0; i <= 1.0; i += 0.01) {
|
||||
thresholds.push(i);
|
||||
}
|
||||
|
||||
const percentThresholdsOptions = {
|
||||
root: null,
|
||||
threshold: thresholds,
|
||||
};
|
||||
|
||||
const updateOpacityCallback = (entries) => {
|
||||
entries.forEach(entry => {
|
||||
entry.target.style.opacity = entry.intersectionRatio;
|
||||
});
|
||||
};
|
||||
|
||||
const opacityObserver = new IntersectionObserver(updateOpacityCallback, percentThresholdsOptions);
|
||||
|
||||
window.addEventListener('load', createObserver);
|
||||
|
||||
function createObserver() {
|
||||
const targetImages = document.querySelectorAll(".projectImage");
|
||||
|
||||
targetImages.forEach(targetImage => {
|
||||
opacityObserver.observe(targetImage);
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
window.onload = function () {
|
||||
typeText("#WelcomeMessage", "Hey! You found me! Since I have your attention, why don't I tell you about myself?");
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
function typeText(selector, content) {
|
||||
const element = document.querySelector(selector);
|
||||
|
||||
if (!element) {
|
||||
console.log("Element not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
simulateTyping(element, content);
|
||||
}
|
||||
|
||||
function simulateTyping(element, text) {
|
||||
let index = 0;
|
||||
let speed = 50;
|
||||
let currentText = "";
|
||||
|
||||
const interval = setInterval(() => {
|
||||
if (index < text.length) {
|
||||
currentText += text.charAt(index);
|
||||
index++;
|
||||
element.textContent = currentText;
|
||||
} else {
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, speed);
|
||||
}
|
||||
Reference in New Issue
Block a user