Incorporate a genre twist in animated films

Is there a way to implement an animated feature where the letters appear one by one in between a sentence, similar to what is seen on this page?

On the linked page, there is a sentence displayed inside a banner that reads:

Create meaningful documents 
Create persuasive documents  
Create impactful documents

Upon observation, it can be noted that the second word changes while the first and third words remain constant. I am curious to know how this dynamic effect can be achieved.

Answer №1

To accomplish this task, javascript can be utilized. You can find a custom plugin created by me for typing letters using the setInterval() function here.

Demo Code:

typer = function(e, s, d, t) {
  var eI = 0;
  var speed = s;
  var delay = d;
  var eLength = t.length;
  var z = 1;

  function loop() {
    var p = $("<div class='azy-typer-container azy-typer-done'></div>");
    var c_t = $("<span class='azy-typer-element'></span>")
    var c_b = $("<span class='azy-typer-blinker'>|</span>");
    $(".azy-typer-blinker").remove();
    p.append(c_t).append(c_b);
    $(e).append(p);
    interval = setInterval(function() {
      c_t.text(t[eI].substring(0, z));
      if (z + 1 > t[eI].length) {
        clearInterval(interval);
        eI = eI + 1;
        if (eI + 1 <= t.length) {
          z = 0;
          setTimeout(loop, d);
        }
      } else {
        z = z + 1;
      }
    }, s)
  }
  loop();
}
new typer(".container", 100, 1000, ["Hi there!", "This is a typer demo ", "What do you think about this ?"]);
body {
  background: black;
}
span {
  font-family: "Courier New";
  font-size: 24px;
  color: #fff;
  font-weight: bold;
}
.azy-typer-blinker {
  animation: blink 1s infinite;
}
@keyframes blink {
  0% {
    color: crimson;
  }
  50% {
    color: transparent;
  }
  100% {
    color: crimson;
  }
}
.azy-typer-done {
  margin-left: 24px;
}
.azy-typer-done:before {
  content: ">>";
  color: lightgreen;
  font-family: "Courier New";
  font-size: 24px;
  margin-left: -24px;
  font-weight: bold;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container"></div>

You have the flexibility to modify the code as per your requirements.

typer = function(e, s, d, t) {
  var eI = 0;
  var speed = s;
  var delay = d;
  var eLength = t.length;
  var z = 1;

  function loop() {
    var p = $("<div class='azy-typer-container'></div>");
    var c_t = $("<span class='azy-typer-element'></span>")
    var c_b = $("<span class='azy-typer-blinker'>|</span>");
    $(".azy-typer-blinker").remove();
    p.append(c_t).append(c_b);
    $(e).append(p);
    interval = setInterval(function() {
      c_t.text(t[eI].substring(0, z));
      if (z + 1 > t[eI].length) {
        p.addClass("azy-typer-done");
        clearInterval(interval);
        eI = eI + 1;
        if (eI + 1 <= t.length) {
          z = 0;
          setTimeout(loop, d);
        } else {
          eI = 0;
          z = 0;
          setTimeout(loop, d);
        }
      } else {
        z = z + 1;
      }
    }, s)
  }
  loop();
}
new typer(".container", 100, 1000, ["Hi there!", "This is a typer demo ", "What do you think about this ?"]);
body {
  background: black;
}
span {
  font-family: "Courier New";
  font-size: 24px;
  color: #fff;
  font-weight: bold;
}
.azy-typer-blinker {
  color: maroon;
}
.azy-typer-container {
  display: inline;
}
.azy-typer-done {
  display: none;
}
.static {
  color: lime;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container">
  <span class="static">Static </span>
</div>

The function requires four arguments:

  1. The target element for text appending
  2. The speed of typing
  3. The delay before displaying the next item
  4. The text as an array

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Prevent the elongation of HTML select elements in Bootstrap

Struggling to set the size of an HTML "select" field in Bootstrap 3 (latest) to normal width instead of 100%? Looking for a cleaner solution than resorting to tables or adding fields within bootstrap columns that might cause indentation issues due to borde ...

Begin an unnumbered hierarchical list commencing at 1.2.1

I am trying to create a nested unordered list with specific numbering. My goal is for the list to start at "1.2.1, 1.2.2, etc." Please refer to the attached fiddle for reference. The desired outcome is shown in the following image: https://i.stack.imgur ...

Issue - The command 'bower install' terminated with Exit Status 1

During my journey through the angular-phonecat tutorial, a frustrating error popped up right after I executed the npm install command: I even checked the log file, but it just echoed the same error message displayed in the console. What's the piece o ...

Assistance Required for Troubleshooting Error in Codeigniter Ajax

Hey there, I'm a newcomer to CI and I've been searching the web for a tutorial that actually works, but so far no luck. Can someone please assist me with this code: How can I modify the code to allow for submitting an entry to the database via a ...

Utilizing Ionic Storage to set default request headers through an HTTP interceptor in an Angular 5 and Ionic 3 application

I'm attempting to assign a token value to all request headers using the new angular 5 HTTP client. Take a look at my code snippet: import {Injectable} from '@angular/core'; import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest} from ...

Changing the background color using jQuery switch case statement

I am attempting to utilize jquery to dynamically change the background image of a webpage based on different cases in a JavaScript switch statement. I have completed three steps: 1) Included this script tag in my HTML document: <script src="http://co ...

Anticipated the presence of a corresponding <tr> in the <table> within the server HTML, but encountered hydration failure due to discrepancies between the initial UI and the server-rendered content

Next.js Version 13.2.3 In Next.js, it is advised not to use the table element. "use client"; export default function index() { return ( <table> <tr> <th>Company</th> ...

Is it possible to modify the CSS injected by an Angular Directive?

Is there a way to override the CSS generated by an Angular directive? Take, for instance, when we apply the sort directive to the material data table. This can result in issues like altering the layout of the column header. Attempting to override the CSS ...

Alternative to Google's translation API

While utilizing the Google translate API, I have noticed that it disrupts the css on my webpage by removing background images. Does anyone have a different suggestion or solution? I attempted to find a JQuery method that translates text inline without ref ...

Choose an option from the dropdown menu using a variable

I've been struggling to get a dropdown's selected value to change based on a query result. No matter what I do, it always defaults to the first option. After searching through numerous similar questions, none of the solutions seem to work for me ...

Update and republish an outdated npm package

After successfully publishing an npm package, I attempted to make an update which unfortunately resulted in some issues. It seems that I made a mistake during the build process. Since it had been a year since my last update, I have forgotten the exact step ...

What is the most effective method for establishing a notification system?

My PHP-based CMS includes internal messaging functionality. While currently I can receive notifications for new messages upon page refresh, I am looking to implement real-time notifications similar to those on Facebook. What would be the most efficient ap ...

I am in need of a customized 'container' template that will display MyComponent based on a specific condition known as 'externalCondition'. MyComponent includes the usage of a Form and formValidation functionalities

container.html <div ngIf="externalCondition"> <!--Initially this is false. Later became true --!> <my-component #MyComponentElem > </my-component> <button [disabled]= "!myComponentElemRef.myDetailsF ...

What is the process of building a service in AngularJS?

I have written this code using a service in angular.js. Upon running the code, I encountered an error Uncaught Error: [ng:areq]. </ons-toolbar> <div ng-controller="testAppController"> Search: <input ng-model="query" type=" ...

Requirements for using Angular JS and Node JS

With upcoming projects involving AngularJS and Node.js, I'm a bit apprehensive as I don't have much experience with JavaScript. Should I start by picking up a book on each technology, or is it essential to learn more about JavaScript first before ...

Retrieving the Vue component object while inside the FullCalendar object initialized within the component

When using Full Calendar with VueJS, I ran into a problem where I needed to open a custom modal when clicking on a time slot in the calendar. The issue was that I couldn't call a function outside of the Full Calendar object to handle this. This is bec ...

Guide on implementing react hook form 7 together with Material-UI switch

When utilizing react-hook-form with MUI switch, there is an issue where the initial value does not display on page load despite being set to true. However, upon form submission without any changes, the switches reflect their correct values (true or false). ...

Instructions on utilizing Tesseract.recognize in Node.js

I am working on developing an OCR program but encountered some issues while declaring the 'Tesseract.recognize' method. Here is the code snippet: const express = require('express'); const fs= require('fs'); const multer = r ...

The content at the center of the page is shifting to the right side when the browser is resized

I am currently working on creating a random quote generator at the following link: http://codepen.io/Kestvir/pen/peqjZZ. During the html/css aspect of the project, I have run into an issue with the content inside a transparent background. Whenever I resi ...

Customize SQL query based on selected checkbox with jQuery autocomplete

Picture this: a scenario where I have a single textbox with autocomplete 1.1 (not the latest UI version) and a checkbox. The textbox triggers an ASP.NET .ashx page that communicates with a SQL Server to execute a stored procedure and return results. Every ...