Diminish four characters from a word and keep only the letter "H"

Is it possible to remove the letters "ello" from the word "Hello" as it zooms out?

I want the letters "e," "l," "l," and "o" to fade out when steps 6 and 7 of my code are reached, while only the letter "H" moves towards the top left corner. // 6. Zoom out to 200% heading towards the top left corner, // 7. Fade out upon reaching the logo

JavaScript:

 // 3. Page load completes - the text "hello",
    // has come to center with zoom 800%
    $("#hello").animate({
      zoom: "800%",
      left: window.innerWidth / 2
    }, 3000, function() {
      // 4. Pause for 3 seconds
      $(this).delay(3000)
      // 6. Zoom out to 200% heading towards the top left corner,
      // (logo position) 
      // 7. Fade out upon reaching the logo 8. Logo appears
      .animate({
        zoom: "200%",
        left:0
      }, 3000, function() {
        $(this).fadeOut()
      })
    })

HTML:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="hello">
  <h1 style="zoom: 200%; transition: zoom 1s ease-in-out;">hello </h1>
</div>

Answer №1

Take a look at the fiddle link provided: http://jsfiddle.net/cgLLhyyu/1/

<div id="hello">
    <h1 style="zoom: 200%; transition: zoom 1s ease-in-out;">h<span>ello</span> </h1>
</div>

To achieve the desired effect of fading out certain elements, make sure to wrap those elements inside a span element. The rest of the code seems accurate.

$("#hello").animate({
      zoom: "800%",
      left: window.innerWidth / 2
    }, 3000, function() {
      // Pause for 3 seconds
      $(this).delay(3000)
      // Zoom out to 200% heading towards top left corner (logo position) 
      // Fade out when reaching the logo and then make the logo reappear
      .animate({
        zoom: "200%",
        left:0
      }, 3000, function() {
        $(this).find('span').fadeOut(); // Update made here
      })
    })

Answer №2

Here's a solution that should do the trick:

$("#hello").animate({
  zoom: "800%",
  left: window.innerWidth / 2
}, 3000, function() {
     $(this).find('span').fadeOut()
  // 4. Wait for 3 seconds
  $(this).delay(3000)
  // 6. Zoom out to 200% moving towards top left corner,
  // (logo position) 
  // 7. Fade out when it reaches the logo, and then the logo appears
      .animate({
    zoom: "200%",
    left:0
  }, 3000, function() {
    $(this).fadeOut();
  })
})

});

Check out this JsFiddle link

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

Tips for making content vanish or remain concealed behind a see-through header during page scrolling

I made a JavaScript fiddle http://jsfiddle.net/claireC/8SUmn/ showcasing a fixed transparent header. As I scroll, the text scrolls up behind it. How can I make the text disappear or be hidden behind the transparent div when scrolling? Edit: I should also ...

Using C# to send pictures to a WhatsApp contact

Is it possible to send an image along with a text message to a WhatsApp number through the API? https://api.whatsapp.com/send?phone=15551234567&text=I'm%20interested%20in%20your%20car%20for%20sale I have successfully sent text messages using thi ...

If the checkbox is selected, the textbox will receive the class "form-input validate required" upon Jquery validation

I am using Jquery Validation plugin to validate a form on my website. Below is the HTML form code: <form id="caller"> <label>Phone:</label> <input type="text" name="phone" id="phonen" class="form-input" value="" /> <di ...

Trying to showcase information received from a server using an API

For a school project, I am developing a website that can retrieve weather data (currently just temperature) based on a city or zip code from openweathermap.org using an asynchronous call. I have successfully retrieved the data from the API, but I am strug ...

Issues with ordering directives in Bootstrap 4 are preventing proper functionality on various mobile platforms and devices

When I resize the browser window to mobile width, the order column directive in the code snippet above works fine. However, when I test it on a mobile emulator or an actual mobile device, the order columns do not function properly. This issue seems to be r ...

Issues with Bootstrap carousel functionality in Rails

After trying to integrate bootstrap's carousel in my Ruby on Rails application, I created this view: <head> </head> <body> <div id="carousel" class="carousel slide" data-ride="carousel"> <!-- Indicators --> &l ...

Tips for sending and showcasing a multi-dimensional array using ajax

Currently, I am implementing my project with an Object-Oriented Programming approach. One of the tasks involves passing all database values in the form of a multidimensional array through AJAX, displaying the array using 'text' datatype in consol ...

Exploring the complete meaning of React controlled and uncontrolled components

I have been using React for several months and I thought I understood the distinction between controlled and uncontrolled components, thanks to sources like this: Controlled form inputs Uncontrolled components However, my understanding was thrown into ...

What is the most effective method for incorporating personalized React components in the midst of strings or paragraph tags

Summary: Exploring the frontend world for the first time. Attempting to integrate custom components within p-tags for a website, but facing challenges in making them dynamically changeable based on user interaction. Greetings all! As a newbie in front-end ...

Whenever I attempt to import the "Highway" package, I encounter an error stating "Unexpected identifier."

After installing Highway through the terminal, I encountered an issue when running the script below: import Highway from '@dogstudio/highway'; import Fade from './transition'; const H = new Highway.core({ transition: { default: ...

What is the best way to prioritize loading a specific div on a website before anything else?

On my website, I have two div panels: left_panel and right_panel. The left panel contains hundreds of food items, while the right panel displays a small box for orders where users can see how many items they have added from the left panel. The issue aris ...

When the onclick event is triggered, the form is displayed, but I want another element

Recently, I encountered this issue.. <button class="movebutton" onclick="jQuery('.moon-form').show();"></button> This code snippet is meant to display a form when the button is clicked. However, I also want another element with the ...

Parent window login portal

I have just started learning how to program web applications, so I am not familiar with all the technical terms yet. I want to create a login window that behaves like this: When a user clicks on the Login button, a window should pop up on the same page t ...

What is the best way to attach a jQuery event to both existing and forthcoming elements?

After discovering that live() is now deprecated in jQuery, I have a quick inquiry regarding the most efficient, fastest, and up-to-date method to use. I have a function called myfunction() that I'd like to bind to all current and future elements with ...

Mastering the art of using the async pipe in conjunction with rxjs

I require assistance as the loading component of my async pipe does not activate, despite the data loading correctly. The loading template fails to trigger during subscription even though I am using a BehaviorSubject in my service. I have attempted various ...

Utilize JavaScript to import an XML file from a specific directory

I am trying to use JavaScript to load an XML file. Below is the code I am using to load the XML file when it is in the same folder: if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHtt ...

Automating testing with JavaScript and Selenium WebDriver

Can testing be automated using the combination of JavaScript and Selenium? I am not familiar with Java, Python, or C#, but I do have expertise in Front-End development. Has anyone attempted this before? Is it challenging to implement? Are there any recom ...

Achieving success seems to be out of reach

Can you help me achieve a successful data transmission conclusion? I have tried different methods, but none seem to work. When clicking the "Send" button, the data gets sent, but instead of the message saying "Data sent successfully," I need the form to di ...

In this JavaScript code, learn how to organize an array based on its numerical property

What is the best way to organize an array based on the 'num' property in this JavaScript array? var data = [{ 005: { `num`: 1360487}, 047: { `num`: 2519472}, 061: { `num`: 1559115}, 081: { `num`: 2232710}, 085: { `num`: 54956 ...

What is the best method for retrieving environment variables within a React JS web application?

Within my render method, I am trying to access a specific environment variable. However, because it is a custom ENV variable, I cannot utilize (process.env.NODE_ENV). According to this source, React filters all process.env access. What would be the best w ...