Version 2 of the Microsoft Logo Animation

I made some changes to my Microsoft logo animation project. You can view the updated version on CodePen. Overall, I'm pretty happy with how it turned out except for one issue.

I'm struggling to determine the right timing to end the animation so the logo appears correct. I attempted to set the delay to 6000ms, which is the length of the animation, but it didn't look right. Right now, it's set to 5900ms. Any suggestions on how to address this?

Additionally, I'm curious about how to make a YouTube video start playing after a specific time, like when the text is displayed. Any advice on this?

var playState = '-webkit-animation-play-state';

$(".boxes").css(playState, "running");
setTimeout(function() {
  $(".boxes").css(playState, "paused");
}, 5900);
body {
  background: hsl(30, 20%, 20%);
  color: #fff;
  font-family: 'Open Sans', sans-serif;
}

.boxes {
  -webkit-animation: logo 6s 1 forwards;
  animation: logo 6s 1 forwards;
  position: absolute;
}

.box {
  -webkit-animation: scaling 1.5s cubic-bezier(.1,.95,.7,.8) 4;
  animation: scaling 1.5s cubic-bezier(.1,.95,.7,.8) 4;
  height: 50px;
  width: 50px;
}

.brand {
  -webkit-animation: fadein 2s ease 4.5s forwards;
  animation: fadein 2s ease 4.5s forwards;
  display: inline;
  font-size: 36px;
  margin: 24px 0 0 0;
  opacity: 0;
  position: relative;
  top: -36px;
  text-align: center;
  z-index: 0;
}

.flex {
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  min-height: 100vh;
  -webkit-flex-direction: column;
  flex-direction: column;
  justify-content: center;
}

.intro {
  text-align: center;
}

.logo {
  -webkit-animation: moveLeft .5s linear 4.5s forwards;
  animation: moveLeft .5s linear 4.5s forwards;
  display: inline-block;
  height: 100px;
  left: 100px;
  margin: 0 auto;
  position: relative;
  width: 100px;
  z-index: 1;
}

.player {
  display:none;
}

#green {background: #7cbb00;}
#yellow {background: #ffbb00;}
#blue {background: #00a1f1;}
#red {background: #f65314;}

#animateGreen {animation-delay: 4.5s;}
#animateYellow {animation-delay: 3s;}
#animateBlue {animation-delay: 1.5s;}
#animateRed {animation-delay: 0s;}

@keyframes fadein {
  from {opacity: 0;}
  to {opacity: 1;}
}

@keyframes logo {
  0% {left: 0px; top: 0px; transform: rotate(0deg)}
  25% {left: 50px; top: 0px; transform: rotate(-180deg)}
  50% {left: 50px; top: 50px; transform: rotate(-360deg)}
  75% {left: 0px; top: 50px; transform: rotate(-540deg)}
  100% {left: 0px; top: 0px; transform: rotate(-720deg)}
}

@keyframes moveLeft {
  from {padding-right: 0; left: 100px;}
  to {padding-right: 50px; left: 0;}
}

@keyframes scaling {
  0%, 100% {transform: scale(1)}
  50% {transform: scale(.5)}
}
<head><script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script></head>

<div class="flex">
  <div class="intro">
    <div class="logo">
      <div class="boxes" id="animateGreen">
        <div class="box" id="green">
        </div>
      </div>
      <div class="boxes" id="animateYellow">
        <div class="box" id="yellow">
        </div>
      </div>
      <div class="boxes" id="animateBlue">
        <div class="box" id="blue">
        </div>
      </div>
      <div class="boxes" id="animateRed">
        <div class="box" id="red">
        </div>
      </div>
    </div>
    <div class="brand">
      Microsoft
    </div>
  </div>
</div>

<iframe width="560" height="315" src="https://www.youtube.com/embed/I3Ak5VgyEoc?autoplay=1" class="player"></iframe>

Answer №1

A more effective way to halt the animation is to assign a unique animation to each box, positioning them as desired, rather than relying on jQuery or JavaScript.

Take a look at this CodePen example.

If you want to play a YouTube video when text appears, you can refer to the YouTube API Documentation for guidance. In jQuery, the code would look something like this:

setTimeout(function(){
    //play the YouTube video
    $('#playerId').get(0).playVideo();
} , 4500); //4500 ms delay

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

Angular Material: div not being filled by layout-fill

<!-- Container Div --> <div layout-fill> <!-- Image Div --> <div layout="column" layout-align="center center" class="coverImage" layout-fill> <md-content class="md-padding"> Sample Text Here ...

Do not open iframe links in a new window

Is it possible to manipulate the iframe so that links open inside the iframe window? I want the links clicked within the iframe to stay within the same window instead of opening in a new one. However, I have too many links to individually edit their code ...

Exploring the use of arrays in Vue JS

Currently, I am working on a small project using VueJS 2.0, and it involves handling data that looks like this: {"data": [ { "id":8, "salutation":"Mr", "first_name":"Madhu", "last_name":"Kela", ...

Displaying an error in Ajax caused by PHP

I've been attempting to send a POST request to a URL using Ajax. Here's what my JS/JQuery code looks like: var params = { 'username' : '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="781d1c1c190a1c ...

JavaFX WebEngine pauses until ajax is finished

Currently, I am working on a JavaFX data mining application that heavily relies on WebView and WebEngine. The entire mining process involves two main steps. Firstly, the user navigates to a specific website using the UI in WebView to configure the search f ...

Removing hyperlink with jQuery confirmation in an Asp.Net MVC 2 web application

I recently implemented a feature in my MVC project where I have a table with records and delete links. Following the NerdDinner tutorial, I initially used a confirm view for deletion. However, I decided to switch to using a confirm dialog instead, allowing ...

Unable to toggle Bootstrap 5 tabs in a Nunjucks template - the issue persists

I have been following the bootstrap documentation for tabs which can be found at this link After referencing the documentation, I replicated the sample implementation in my code as shown below: --- title: Portfolio description: Portfolio --- {% exten ...

Create a request for an update by utilizing Axios within a React and Material UI environment

I am completely new to React, and my experience with CRUD functionality is limited to ASP.NET MVC. I'm feeling a bit lost as none of the tutorials I've come across seem to cater to my specific situation. The tips I received previously were helpfu ...

enigmatic margin surrounding navigation dots

I have added a straightforward dot navigation to the banner of my website. You can check it out HERE. The HTML code I used is shown below: <ul class="carousel-dots"> <li> <a href=""></a> </li> <li> ...

Issues with the functionality of minimized AngularJS JavaScript files

I combined all JS files into one and minified them, but now none of the site features are working. There were too many separate JS files to include individually, so I decided to merge them together. Is there a better method to reduce the number of HTTP r ...

Use JavaScript to switch the h1 title when selecting an option from the dropdown menu

As a beginner in coding, I am struggling to find a solution using an if statement for this particular problem. Although I can achieve the desired result with HTML code and options, this time I need to use arrays and an if function. My goal is to create a ...

Error: The function imgPreload cannot be executed because $ is not recognized as a function

I'm encountering an issue with calling a JavaScript function. Here's the code snippet I'm using: <script type="text/javascript" src="<?php echo base_url().'assets/'?>js/jquery-1.9.0.min.js"></script> <script t ...

What are the different kinds of properties that can be used in Vue.js

When working with Javascript, I can create arrays that hold different types of data elements like: var ex = ['name', 12, true]; console.log(ex); In Vue JS, when defining props for a component within a single file template, I have the option to ...

When integrating external HTML into an Angular 2 component, relative references may become invalid and fail to

My server hosts basic HTML content that includes an image with a relative file location. While this displays correctly in a browser, loading the content using Angular causes issues with resolving the relative path locally. I have tried following suggestio ...

How can I ensure a div expands over another element when hovering the mouse?

I have a development div in the footer with a hover effect that expands it. However, it is currently growing underneath the top element on the site. I want it to expand on top or push the element above. Website: I've tried using position, float, and ...

Is there a way to send a Python list to Django?

I'm in the process of setting up a website where I can retrieve a JSON list from my PRTG. Currently, I have successfully implemented code in the console that filters out sensors with a status of DOWN. However, I am facing difficulties in posting this ...

Mastering the art of integrating a multi-step form in React

While developing a multi-step form in my React 17.0.1 application using Typescript version 4.1.2, I came across this helpful guide: https://dev.to/sametweb/how-to-create-multi-step-forms-in-react-3km4 The guide was clear up to step 6, which I decided to s ...

The div is repositioned without the use of padding or margin properties

I am facing an issue with my Next.JS application where a div is not aligning properly at the top of the page. Despite setting padding and margin to 0 for body, HTML, and the div itself, it seems to be slightly off. I have checked all components thoroughly ...

Struggling to make jeditbale ajax call function properly

Currently, I am attempting to modify text directly on the webpage using the jeditable plugin. Unfortunately, I have encountered a challenge when it comes to saving the updated data properly through an ajax call. Although I can successfully edit the text, i ...

The asynchronous JavaScript function is successfully printing data, however it is encountering an error where it returns 'undefined'

Struggling with asynchronous calls, I've realized this question has been answered many times before. Despite trying numerous suggested approaches without success, I would truly appreciate any help. Progress has been made recently, but I still consider ...