Discover the secret to revealing hidden text as it seamlessly transitions through other text

I am working on a simple transition animation where I need to hide text (A href) initially using "display: none" and then make it visible with "display: block" after an image passes through it, triggered by a click event in JavaScript. Check out my code snippet here: http://jsfiddle.net/ofy4t5a8/

#facebook_text a {
    position: absolute;
    font-size: 15px;
    color: #000;
    text-decoration: none;
    margin-left: 50px;
    margin-top: -10px;
    z-index: 1;
    display: none;
}
#facebook_image.fly {
    position: absolute;
    margin-left: 125px;
    margin-top: 0px;
    transition: all 5s ease-out;
}
#facebook_image img {
    position: absolute;
    z-index: 10;    
    height: 35px;
    width: 35px;
    margin-top: -15px;
}
                            <div id="facebook_text">
                                <a href="google.com" alt="facebook" target="_blank">Facebook</a>
                            </div>
                            <div id="facebook_image">
                                <img class="image_animation" src="facebook.jpg"></img>
                            </div>
                            <script>
                                document.querySelector('.image_animation').onmouseover=function()    {
                                var d = document.getElementById("facebook_image");
                                d.className = d.className + " fly";    
                                }
                            </script>

Answer №1

To detect when an event ends, follow these steps:

 eventEnd = (function eventEndName() {
        var x,
            element = document.createElement('div'),
            events = {
                'transition':'transitionend',
                'MozTransition':'transitionend',
                'WebkitTransition':'webkitTransitionEnd'
            };

        for (x in events) {
            if (events.hasOwnProperty(x) && element.style[x] != undefined) {
                return events[x];
            }
        }
    })();
var elemA = document.querySelector('elementA');
var elemB = document.querySelector('.facebook_image');
elemB.addEventListener(eventEnd, function(){
     elemA.style.display = "visible";
}

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

What is the best method for inserting CSS into a webpage using a Chrome extension?

I am seeking guidance on how to incorporate CSS into a webpage using a Chrome extension. The CSS code I am attempting to inject is as follows: body { background: #000 !important; } a { color: #777 !important; } Here is the content of my manifest.j ...

Unable to load connected modules from npm/yarn link within the WSL environment

Trying to import a local dependency into my project is proving to be quite challenging. The situation at hand involves a project named 'test_project' and another one called 'test_module'. Linking test module to the global node_modules ...

The asp.net masterpage is not utilizing the stylesheet

I have the code snippet below in the MasterPage.master file of my project: <%= ConfigurationManager.AppSettings("System").ToString() %> <asp:ContentPlaceHolder ID="Stylesheets" runat="server"> <link rel="Stylesheet" href="/App_Dat ...

What's preventing me from changing module.exports? Why is my browser suddenly giving me errors after `npm run build` ran smoothly?

How come the browser is preventing me from executing the following code: Getters.js let Getters = {} Getters.foo = function(){ return 1; } Getters.bar = function(){ return 2; } module.exports = Getters; However, after running npm run build and serve -s ...

Converting JSON data into an HTML table

I'm struggling to convert a JSON object into an HTML table, but I can't seem to nail the format. DESIRED TABLE FORMAT: Last Year This Year Future Years 45423 36721 873409 CURRENT TABLE FORMAT: Last Year 45423 This ...

React Calculator: Display issue with input tag showing decimals and symbols incorrectly

Currently, I am developing a calculator in React where I have set up the buttons to trigger a function numberDisplay(). This function appends the corresponding value of the button pressed to a string (the state). However, I've encountered an issue whe ...

Unable to access image from JSON within Mobile Angular Ui utilizing Angular Js

Currently, I am able to retrieve various data from JSON such as Price and Display Order, but I am facing difficulty in fetching the image. HTML: <div ng-controller="chooseProductDescription"> <div ng-repeat="cat in productDescrip ...

Troubleshooting JavaScript Integration in PHP Scripts

I'm currently working on creating an advertisement switcher that can display different ads based on whether the user is on mobile or desktop. I've tried inserting PHP includes directly into the code, and while it works fine, I'm struggling t ...

Differentiating Angular HTML and script code is a fundamental practice in Angular development

I am working on an angular frontend project that includes a dashboard component with a sidebar. The code currently has both the script tag and HTML code in the same file, making it difficult to manage. I am looking for a way to separate them to make the co ...

Tips for positioning the button directly beside the search box

I'm having trouble getting the search button to align properly next to the search box. Currently, the button appears below it. Here is my current code: <form action="{linkto page="search.php"}" method="get" id="searchFormTest"> ...

Incrementing a variable based on a condition in JavaScript

Currently, I am working on a project where I have a variable called "total" that needs to be assigned a number (or price) and then incremented when certain options are selected or checked. Below is the code that I have developed up to this point. This sni ...

Burger menu sidebar - Conceal on click outside

Is there a way to hide the left sidebar when a user clicks outside of it? Jsfiddle I attempted using the following code: $('.nav').click(function(event){ event.stopPropagation(); }); I also tried adding .stopPropagation(); to the body cli ...

Issue with Ionic ng-click not triggering

I am currently experimenting with an Ionic application that utilizes a Firebase backend. The issue I'm facing is that the ng-click="loginUser(user)" function does not seem to be triggering. When checking the console, it only displays Signed Out from ...

NetBeans is unable to analyze javascript files that are considered "large" (over 350 KB)

I have a significant JavaScript file (approximately 6 MB) that includes library API and documentation as shown below: /** * Function doc */ library.class.func=function(something){}; /** * Function 2 doc */ library.class.func2=function(something){}; ...

"Uncovering the dangers of XMLHttpRequest: How automatic web-page refresh can lead

Hello, I have been developing a web interface for some hardware that utilizes an 8-bit microcontroller. The webpage includes HTML, JavaScript, JSON, and XHR (XMLHttpRequest) for communication purposes. My goal is to create a page that updates every 250 ...

Utilizing Flot, JSON, and MySQL for creating a unique date format for the X axis

After hours of struggling to solve a problem using the vast knowledge of the internet, I find myself at a dead end. Can anyone pinpoint the mistake I've been overlooking in my efforts? I'm currently working on generating a graph with Flotr using ...

VueJS - Input Image Display Issue Causing Browser Slowdown

I'm experiencing some issues with my VueJS component that includes a file input and displays an image afterwards. Strangely, this is causing my web browsers (both Firefox and Chromium) to freeze up and use massive amounts of CPU. I tried switching to ...

Dealing with transformed data in AngularJS: Best practices

Scenario I have a dataset structured like: [{ xRatio: 0.2, yRatio: 0.1, value: 15 }, { xRatio: 0.6, yRatio: -0.3, value: 8 }] I need to convert this data into absolute values for display in a ng-repeat. However, when I attempt to do so usin ...

What is the method for implementing absolute paths rather than relative paths in a React or Next.js project?

In my React project, I frequently use multiple components within various higher-order components. This often leads to long import paths like import MyComponent from '../../../../components/MyComponent'. I am aware that there is a more efficient w ...

Parsing JSON data using PHP and AJAX decoding

I have been searching for a way to pass parameters between the server and client, but I am struggling to find a solution that works. Despite reading extensively online, I have not been able to come up with a functioning solution. Client Side function sen ...