Hold off on scrolling up while hovering over the screen

I've been attempting to implement a scroll-up behavior in WordPress, but I'm facing difficulties in pausing the animation when hovering over it. I've experimented with both jQuery and CSS methods, but have not been successful so far. Any assistance would be greatly appreciated. Below is the CSS code I am working with:

.sliderz {
    position: absolute;
    list-style-type: none;
    text-align: center;
    animation: sliderz linear infinite;
}

.sliderz li { line-height: 50px; width: 100vw; } 

@keyframes sliderz {
    0%   { transform: translateY(100vh) }
    100% { transform: translateY(-100%) }
}

HTML

<div class=sliderz>
  <li>Item</li>
  <li>Item</li>
  <li>Item</li>
</div>

jquery:

window.onload = function() {
var lineHeight = document.querySelector(".sliderz li").clientHeight;
var viewHeight = window.innerHeight;
var sliderz = document.querySelector(".sliderz");
var time = (sliderz.offsetHeight * 2.0 + viewHeight * 2) / 100.0; // 500px / sec

sliderz.style.animationDuration = time + "s";
}

I've been trying to incorporate jQuery functionality like this, but have been unsuccessful:

var sL = 4000;
$('.sliderz').animate({
    scrollup : su
},100000, 'linear');

$(".sliderz").on("click",function(){
        $(this).stop(true,false);
});

$(".sliderz").on("mouseenter",function(){
    $(this).stop(true,false);
});

$(".sliderz").on("mouseleave",function(){
    $(this).animate({
    scrollup : su
    },100000, 'linear');
});

I seem to be at an impasse here. Thank you in advance for any help.

Answer №1

When the animation is paused, it means that it has stopped moving. To implement this feature, you can use the following code:

.sliderz:hover {
animation-play-state: paused;
}

body {
  overflow: hidden;
}

.sections {
  display: block;
  overflow-y: auto;
  height: 100vh;
}

.section1,
.section2 {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center; 
  position: relative;
  background: #fff;
  z-index: 9;
}

.sliderz {
  clear: both;
  height: 100vh;
  list-style-type: none;
  text-align: center;
  animation: sliderz 5s linear infinite;
}

.sliderz li {
  line-height: 50px;
  width: 100vw;
}

@keyframes sliderz {
  0% {
    transform: translateY(100vh)
  }
  100% {
    transform: translateY(-100%)
  }
}

.sliderz:hover {
  animation-play-state: paused;
}
<div class="sections">
  <div class="section1">Section1</div>
  <div class="section2">Section2</div>
  <div class="section3">
    <div class=sliderz>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
    </div>
  </div>

</div>

I have made some adjustments to the code. Please review it and let me know if it meets your requirements.

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

JavaScript triggers page reload upon selection box click

Here is a sample URL for reference: [link removed] The code snippet I am currently using is: $('.jump-submit').on('change', function(e) { var $this = $(this); $this.closest('form').submit(); }); However, when attemp ...

Tips for handling an incorrect date entry when a field loses focus in AngularJS

If I have an <input> field with the type='date' attribute in its untouched state, it displays mm/dd/yyyy as the date format. I am looking to see if there is a way to utilize AngularJS ng-blur directive to reset the field to this original fo ...

" Jquery.ajax, PHP, and the case of the mysteriously missing response

I've been struggling to create my first universal code for handling ajax responses. Unfortunately, I haven't been able to see any output either in PHP or in the ajax response. There must be something missing in the post data. Below is the ajax r ...

angular +webpack application unable to locate Jquery.widget

I recently set up a jhipster generated gateway app. I integrated a jquery plugin into my webpack.dev.js Within the assets folder, there is a scripts.js file which I included by adding its entry in vendor.ts. This script is now bundled in main.bundle.js T ...

Ways to access the scrollTop attribute during active user scrolling

I've been working on a website that utilizes AJAX to keep a chat section updated in real-time. One issue I encountered was ensuring the chat automatically scrolled to the bottom when a user sent a message, but remained scrollable while new messages we ...

I have implemented a validation system that prevents me from advancing to the next tab on my screen if it is left empty

<?php echo $this->Html->script('balaashjquery'); ?> <script type="text/javascript"> jQuery(function(){ $('#name').blur(function(){ $nameval = $('#name').val(); if($nameval ==""){ ...

Viewing the information stored in a text file hosted on a web server

I need help enhancing the functionality of a webpage on my server. Specifically, I want to display the contents of a text file saved on the server. I am struggling with the syntax, but it seems to involve using Flask along with HTML and JavaScript function ...

deleting the current product information during an ajax request

After executing the query provided below, I have $product_list in this code. However, I want to use ajax so that when I click on the button link1, $product_list gets emptied. How can I clear the content within products_list using an ajax call triggered by ...

Implementing a click event to apply an overlay over a div using jquery

When hovering over image1, image2 should appear with a close (X) button in the bottom right corner. Clicking the close button will make image2 disappear and show image1 again. ...

Issue with row-class functionality in Angular template

Everything seems to be working smoothly with my current template. However, I am facing an issue when trying to separate individual courses (or products) into components, as the row class is not functioning properly and causing the items to stack on top of ...

Why does Node.js prompt an error when using document.querySelector? Is there an alternative method to document when utilizing express in my project?

An issue arose when attempting to select the form element using const weatherForm = document.querySelector('form') ^ Unfortunately, a ReferenceError was encountered: document is not defined at Object. (/Users/sheebadola/development/quadacademy/w ...

Utilizing a Custom Validator to Compare Two Values in a Dynamic FormArray in Angular 7

Within the "additionalForm" group, there is a formArray named "validations" that dynamically binds values to the validtionsField array. The validtionsField array contains three objects with two values that need to be compared: Min-length and Max-Length. F ...

Convert the div into a string, including only the visible elements

Within the div #allContent, there are multiple nested divs. My goal is to extract the entire content of #allContent as a string, while excluding any invisible divs contained within it. I believe that this task can be achieved using a combination of filter ...

When the mouse hovers over, the flash content in Firefox 7 will automatically reload

This is the structure I currently have: <div class="feed-item" style="position:relative;" id="feed-611" onmouseover="showDelete()" onmouseout="hideDelete()"> <div class="feed-avatar"> AVATAR </div> <div class="feed-content"> ...

403 error encountered while making an AJAX request to /wp-admin/admin-ajax.php

Recently, I developed a WordPress plugin designed to calculate costs. The form consists of only one input field and a submit button. Upon clicking the submit button, I intended for an AJAX request to be triggered. However, when attempting to call the /wp-a ...

Sending an email using Angular is a straightforward process that involves utilizing the built

I need help figuring out how to code a function in Angular or TypeScript that will open Gmail when a specific email address is clicked. I've tried different methods but haven't been successful so far. ...

Ways to evaluate the amount of traffic on a webpage?

Recently, I encountered an issue while creating a page to showcase blog posts. Each post had the typical social media share buttons like "Facebook like," "tweet this post," and "+1." Additionally, there were some extra JavaScript functions added for variou ...

How can I incorporate Bootstrap/Semantic UI into an Express project without relying on external CDNs

After downloading the minified version of Bootstrap and placing it in the root directory of my project, I added the following code to a HTML file located in /views/: <link rel="stylesheet" href="/bootstrap.min.css"> Despite this, the page remained ...

The bug with map positioning in Internet Explorer can be traced back to having a single Google Maps instance in each jQuery tab

The objective is to incorporate two distinct Google Maps within separate jQuery Tabs, each embedded in an IFrame. Upon triggering the bounds_changed event, the latitude/longitude coordinates and zoom level should be saved in a cookie. If a cookie exists, t ...

How can I clear a form field and immediately give it focus using jQuery?

Submitting a form via AJAX where users input a barcode, hit return, and see success/failure messages can be enhanced by performing the following actions: Fade out the message once submitted Clear the 'barcode' field to prepare for the next entr ...