Experience a slick sliding animation upon hovering with the mouse

One interesting feature I've added to my video list is a div called "infobox" that slides from the bottom when the mouse hovers over a thumbnail.

This is the script:


<script>
$(document).ready(function(){
    $('ul.vlist li').mouseenter(function(){
        $('.infobox').animate({bottom : "20px"},300);
        $('.attachment-post-thumbnail').css("opacity" , "0.4");
    });

    $('ul.vlist li').mouseleave(function(){
        $('.infobox').animate({bottom : "-60px"},300);
        $('.attachment-post-thumbnail').css("opacity" , "1");
    });

});

The issue arises when hovering over a thumbnail activates all the infoboxes of other videos in the video list too.

This is the HTML:


<ul class="vlist">

 <?php if(have_posts()) { ?>
<?php while (have_posts()) : the_post(); ?>
<?php if ( get_option('amn_group') == 'checked') {?>
<?php the_date('', '
<h2 class="title_bar">
    <span>', '</span>
</h2>'); ?>
<?php } ?>
<li class="video" id="video_
    <?php the_ID(); ?>">
    <a href="
        <?php the_permalink() ?>" title="
        <?php the_title(); ?>">
        <?php if ( has_post_thumbnail() ) { echo the_post_thumbnail();}else{ ?>
        <img src="
            <?php echo get_post_meta($post->ID, get_option('amn_thumbs'), true); ?>" width="320" height="160" alt="
            <?php the_title(); ?>" />
            <?php } ?>
            <i></i>
            <div class="infobox">
                <div class="videotitle">
                    <strong>
                        <?php short_title('...', '34'); ?>
                    </strong>
                </a>
            </div>
            <div class="infoboxborder">
                <div>
                    <div class="sponsor">By: 
                        <?php echo get_post_meta($post->ID, 'sponsered', true); ?>
                    </div>
                    <div class="videoTime">
                        <?php echo get_post_meta($post->ID, 'videolength', true); ?>
                    </div>
                </div>
            </div>
        </li>
        <?php endwhile; ?>
    </ul>

Answer №1

assuming that the .infobox element is a descendant of li

$(document).ready(function(){
    $('ul.vlist li').mouseenter(function(){
        $('.infobox', this).animate({bottom : "20px"},300);
        $('.attachment-post-thumbnail').css("opacity" , "0.4");
    });

    $('ul.vlist li').mouseleave(function(){
        $('.infobox', this).animate({bottom : "-60px"},300);
        $('.attachment-post-thumbnail').css("opacity" , "1");
    });

});

Answer №2

It appears that this issue may have already been addressed in a previous thread discussing this similar problem.

One potential solution involves utilizing the following code:

<script>
$(document).ready(function(){
    $('ul.vlist li').mouseenter(function(){
        $('.infobox', this).animate({bottom : "20px"},300);
        $('.attachment-post-thumbnail').css("opacity" , "0.4");
    });

    $('ul.vlist li').mouseleave(function(){
        $('.infobox', this).animate({bottom : "-60px"},300);
        $('.attachment-post-thumbnail').css("opacity" , "1");
    });
});
</script>

If implemented correctly, this should produce the desired outcome. For a practical demonstration, you can refer to the provided jsfiddle link shared by user Dawson in the aforementioned thread.

Answer №3

Sliding in is the primary animation effect when using the show/hide feature with a specified duration attribute. Alternatively, you have the option to designate a different animation type. Here are the necessary steps:

<script>

$(document).ready(function(){
    $('ul.vlist li').mouseenter(function(){
        $('.infobox').show(3000);
        $('.attachment-post-thumbnail').css("opacity" , "0.4");
    });

    $('ul.vlist li').mouseleave(function(){
        $('.infobox').hide(2000);
        $('.attachment-post-thumbnail').css("opacity" , "1");
    });
});

</script>

I adjusted the value from 300 to 3000 to reflect milliseconds (1000ms = 1s). Additionally, remember to include 'bottom:60px;' in your stylesheet.

Answer №4

Give this a try:

$(document).ready(function(){
    $('ul.list li').mouseover(function(){
       $(this).closest('.info-container').animate({bottom : "20px"},300);
       $(this).closest('.post-img'').css("opacity" , "0.4");
    });

    $('ul.list li').mouseout(function(){
        $(this).closest('.info-container').animate({bottom : "-60px"},300);
        $(this).closest('.post-img'').css("opacity" , "1");
    });

});

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

Fill a CSS grid with pictures

I have a collection of 100 images in the same size that I would like to arrange within a CSS grid. The folder contains: seperate-0.png seperate-1.png seperate-2.png seperate-3.png and so on... The CSS code below shows the grid struct ...

What is the process for embedding a script into a Vue component?

I have an HTML template that contains src links to JavaScript scripts. How do I add them to a Vue component? <script type='text/javascript' src='js/library/jquery.min.js'></script> <!-- Main Js Plugin --> <s ...

Adding a Header to the jPlayer Function Using AngularJS

I attempted to include headers within jPlayer but it did not function as expected. const httpHeader = { 'authorization' : '123445'}; if (audioUrl) { $(this).jPlayer('setMedia', { mp3: audioUrl, duration: parseInt(duration ...

The error occurred when trying to hydrate my custom stroke text component after the 14th attempt

I recently embarked on developing an app using Next 14, and I came across the need for text with a stroke. However, the CSS stroke feature was not behaving as expected, creating an inner stroke effect instead of an outer stroke. To address this, I devised ...

Tips on updating the outer ripple color of radio buttons in Angular 6 Material

I was trying to customize the default color of Angular Material Radio buttons. I managed to change the radio button color successfully. <mat-radio-group> <mat-radio-button value="1">Option 1</mat-radio-button> <mat-radio-button va ...

What is the method for inserting a new <p> tag whenever a user sends a new message in ReactJS?

Whenever I press the Enter key, the content is updated in the same tag. First I sent Hello World! The second time I tried to send Hello as a new message, it was updated within the same tag. I have shared code snippets related to the messaging function ...

Visible images remain unloaded by Lazy Load

Currently, I am implementing lazyload functionality on my website to only load images that are visible. This is necessary because some content is hidden when viewed on smaller screens using display:none. The issue I am facing is that lazyload only starts ...

The content on my HTML webpage exceeds the width of the screen on mobile devices and certain PCs

I've exhausted most of the solutions available online, yet I haven't been able to resolve the issue. The content on my webpage is appearing wider than the screen size on mobile devices and some PCs URL: html, body,{ max-width: 100%; ...

Removing an item from a Firebase array: A step-by-step guide

I'm currently facing a challenge with removing a specific object/field within a document in Firebase. While I can delete entire collections or documents, I'm struggling to delete the name and tag fields associated with a particular ID. Is there a ...

Starting over fresh after clearing the interval

Visit the test site Is there a way to reset the animation back to the beginning once it reaches the last image? I've attempted the code below, but it doesn't seem to bring it back to the first image. $(document).ready(function () { window. ...

Skipping validation while navigating back on SmartWizardIf you need to bypass validation during backward

Looking for assistance with Jquery smartwizard? Check out the link. I want to disable validation when a user clicks on the "Previous" button in any step, except for the first step where the Previous button is disabled by default. Below is my JavaScript co ...

Is there a way to modify page URLs without causing a refresh, regardless of browser?

Despite my extensive searches on various online platforms, including stackoverflow, I have yet to come across a satisfactory answer to my question. While I find the window.history.pushState() and window.history.replaceState() methods quite user-friendly, ...

Automatically displaying the navigation bar upon initial loading of the HTML page

Is there a way to adjust this code so that the side nav bar remains open when the page loads for the first time? I would like the side nav to be open by default. function openNav() { document.getElementById("mySidenav").style.width = "250px"; docum ...

What is preventing me from using jQuery to dynamically insert HTML onto the page?

Below is the HTML code for a Bootstrap Modal dialog box: <div class="modal fade" id="rebateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> ...

Vue - receiving the output of a synchronous function

I'm having difficulty displaying the synchronous results of the method provided below. I am invoking the method from another method: var result = this.getVendor(id) console.log(result) Below is the fetch method code: methods: { async getData(i ...

Encountering a VueJS error with Google Cloud Logging Winston: "TypeError: The 'original' argument must be a Function."

I have been attempting to integrate @google-cloud/logging-winston into my VueJS project by closely following the guidelines provided in both the npm package and Google Cloud docs. However, I am encountering an error message stating "TypeError: The &q ...

Issues regarding innerHTML

I have a collapsed table with a link that collapses its content. My goal is to change the link (such as from "+" to "-" and vice versa) using JavaScript. I was able to achieve this, but now my table no longer collapses. Here is the code snippet: <div c ...

Is it possible to modify an element within a list based on the identifier of its containing div?

I have created some additional software for my project, which includes a large div with smaller divs inside. Here is an example of how it is structured: <div class="scroll-area" id="lista"> <div class="box" id="item1"> < ...

Is it possible to use an SVG mask with multiple video sources?

Wondering if it's feasible to use an SVG circle mask for various fixed video DOM elements. https://i.sstatic.net/JzdnU.png The goal is to have each SVG circle mask a separate video on different layers, then scale up to fit the browser height and wid ...

The functionality of setValue() is not available in nightwatch.js

I am currently trying to create a basic script using nightwatch.js that will launch Google and input text into the search bar. However, I am encountering difficulties when using both setValue() methods to enter text into the element. Below is my script: ...