Skip to content

Commit

Permalink
Typing speed and Blink Cursor update
Browse files Browse the repository at this point in the history
  • Loading branch information
mrunal77 committed Oct 22, 2024
1 parent 96f223d commit 62392d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h1 style="color:white; font-size:44px; font-family:Georgia, 'Times New Roman',
</div>
<div class="text-center">
<h3>
<a href="" style="color: white;" class="typewrite" data-period="2000"
<a href="" style="color: white; text-decoration: none;" class="typewrite" data-period="2000"
data-type='[ "Hi, Im Mrunal.", "I am Creative.", "I Love to Design.", "I Love to Develop.", "I love to Code." ]'>
<span class="wrap"></span>
</a>
Expand Down
27 changes: 17 additions & 10 deletions js/animatesite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Type writer Effect Code
var TxtType = function (el, toRotate, period) {
this.toRotate = toRotate;
this.el = el;
Expand All @@ -8,6 +7,7 @@ var TxtType = function (el, toRotate, period) {
this.tick();
this.isDeleting = false;
};

TxtType.prototype.tick = function () {
var i = this.loopNum % this.toRotate.length;
var fullTxt = this.toRotate[i];
Expand All @@ -21,10 +21,10 @@ TxtType.prototype.tick = function () {
this.el.innerHTML = '<span class="wrap">' + this.txt + '</span>';

var that = this;
var delta = 200 - Math.random() * 100;
var delta = 100 - Math.random() * 50; // Faster typing speed

if (this.isDeleting) {
delta /= 2;
delta /= 2; // Faster deletion speed
}

if (!this.isDeleting && this.txt === fullTxt) {
Expand All @@ -33,8 +33,9 @@ TxtType.prototype.tick = function () {
} else if (this.isDeleting && this.txt === '') {
this.isDeleting = false;
this.loopNum++;
delta = 500;
delta = 300; // Short pause after completing a word before typing the next
}

setTimeout(function () {
that.tick();
}, delta);
Expand All @@ -52,20 +53,26 @@ window.onload = function () {
// INJECT CSS
var css = document.createElement("style");
css.type = "text/css";
css.innerHTML = ".typewrite > .wrap { border-right: 0.08em solid #fff}";
css.innerHTML = `
.typewrite > .wrap {
border-right: 0.08em solid #fff;
animation: blink-cursor 1s step-end infinite;
}
@keyframes blink-cursor {
0%, 100% { border-color: transparent; }
50% { border-color: #fff; }
}
`;
document.body.appendChild(css);
};
//typewriter end

// Scroll effect Navbar setting class on on scroll
// Scroll effect Navbar setting class on scroll
(function ($) {
//jQuery to collapse the navbar on scroll
$(window).scroll(function () {
if ($(".navbar-default").offset().top > 50) {
$(".fixed-top").addClass("top-nav-collapse");
} else {
$(".fixed-top").removeClass("top-nav-collapse");
}
});

})(jQuery);
})(jQuery);

0 comments on commit 62392d3

Please sign in to comment.