I am in need of a JavaScript event that will take precedence over the CSS pointer

There is an image causing issues with scrolling on a mobile device because it's located in the finger-friendly area where people tend to scroll. I attempted to use pointer-events: null; to allow scrolling, but this also prevented the click event from working since the image is a button.

I tried using JavaScript to override the CSS property, but it didn't work as expected. Is there another way to achieve this?

CSS

.element-id {
    position: fixed;
    pointer-events: none;
}

Function

$('#element-id').click(function(){
    $('#entrevista').toggleClass('ws-visible');
    $('#video').get(0).play();
});

EDIT:

The issue is that a fixed position element is disrupting the normal scrolling behavior of the page.

While researching online, I came across "bubbling" but I'm not sure how it could be relevant here. From my understanding, it allows events to travel down through the DOM hierarchy, but I'm unsure if it can help resolve this particular issue. Can someone clarify how bubbling works in this context?

Answer №1

It may not be the most efficient solution, but it gets the job done...

Step #1:
Delete the pointer-events: none; style.

Step #2:
Utilize the wheel (or for older browsers, mousewheel) event for scrolling on non-scrollable images. While the image itself doesn't provide scrolling functionality, you can calculate it using the wheel event. For this task, I recommend utilizing jQuery and the jQuery Mouse Wheel Plugin, which simplifies the calculation process. You can also refer to this question for further guidance.

Step #3:
Manually pass on the scroll action to the element intended for scrolling by employing JavaScript's native Element#scroll(...) method or jQuery as well.

Edit

To grasp why this answer is distinct from the query Manually trigger a scroll event of DOM element?, please examine the comments section and consider how the solution provided in that other question may offer better assistance.

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

Having trouble getting the "If paused" feature to function properly in videojs

When my video is paused, I want to display an overlay on top of it. I found the following piece of code in the documentation: var isPaused = myPlayer.paused(); var isPlaying = !myPlayer.paused(); So, I tried implementing it like this: var isPaused = m ...

Create unique identifiers for the TD elements of Viz.js that will be displayed within the SVG elements

Below is the DOT code snippet in Viz.js that I am working with: digraph G { node [fontname = "font-awesome"]; 17 [id=17, shape="hexagon", label=<<TABLE BORDER="0"> <TR><TD>undefined</TD></TR> <TR><TD>[47-56]< ...

I'm trying to create a transparent v-card, but for some reason it's not turning out the way I want

How can I make the v-card transparent while keeping its content opaque using CSS? card.vue <v-card class="cardColor"> <v-card-text> TEXT </v-card-text> <v-card-actions> <v-btn color="prima ...

The browsers Firefox and Internet Explorer are unable to perform ajax requests

Currently, I am utilizing jQuery version 3.3 in conjunction with the following Ajax script: <script type="text/javascript"> $(document).ready(function(){ $("form").submit(function(){ $.ajax({ url: 'msgs.p ...

Simple steps to generate a static header in list view on asp.net

I'm struggling to keep my header fixed while scrolling and can't seem to figure it out. Below is my ListView Code: <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="FormSectionSubSectionItemRelID" OnSele ...

Issue with mouse hover not triggering overlay effect between two div elements

I am trying to display articles in a 2x3 matrix with article details like image, title, author, and description wrapped inside a div. I want this entire div to be overlapped by another div of the same dimensions containing a single image. Below is a snipp ...

Can you please explain what shape-id denotes and provide guidance on locating it within a CSS file?

I have a question that may seem trivial to experienced web developers - what exactly is "shape-id"? For example, in the code <hr shape-id="2">. I'm currently attempting to change the color of the horizontal lines (hr) on my website, but I can& ...

Divide information in the chart

<table id="tab"> <tr><td class="sub">mmmmm</td><td class="sub">jjjjj</td></tr> <tr><td class="sub">lllll</td><td class="sub">wwwww&l ...

Angular 2's innovative approach to implementing a sticky footer concept

Is there a way to make my footer sticky without being fixed? I attempted using the CSS negative margin trick, but it did not work as expected. In the provided Plunker code, I tried to replicate the issue in my Angular 2 app. The goal is for the footer to s ...

Ensure that the input box expands to occupy the entire HTML page

After reviewing numerous pages and questions related to this topic, I have located the correct solution but am struggling to implement it. My goal is to achieve a similar outcome to the second question, but I'm having difficulty figuring out how to do ...

Listening for JS events on a CSS class called "int-only" which only accepts

Having an issue: I'm encountering a problem with this PHP code: <?php for($i = 0; $i < sizeof($floating_ips_json["floating_ips"]); $i++){ ?> <tr class="details-control-<?php echo $i; ?> cursor-pointer"> <t ...

How can I transfer Django Ajax data to a template?

Currently, I am facing the challenge of passing a 2D array into a template through ajax. While I have successfully received the data from the server upon clicking, I am uncertain about how to manipulate this data within the template. When I attempt to plac ...

A step-by-step guide on initializing and setting a cookie value with expiration

Below is the code I have added. Can someone please help me locate the bug? Here is the code snippet: $_SESSION['browser'] = session_id(); setcookie($expire, $_SESSION['browser'], time() + (60 * 1000), "/"); echo "Value is: " . $_COO ...

Tips for creating a form-flip, similar to a card-flip effect, using web technologies

Looking to create a card flip effect similar to the one shown here. Once the sign up process is finished, the card will smoothly flip over to reveal the other side with a transitioning effect. ...

Creating a jQuery plugin with configurable options but without attaching it to any specific HTML element can be

I am currently working on developing a unique plugin that does not require a DOM element but comes with default options pre-set. However, upon executing the code snippet below, I encounter the error message TypeError: $.myApp is not a function. What modi ...

Dynamic CSS Changes in AngularJS Animations

I am currently working on a multi-stage web form using AngularJS. You can see an example of this form in action by visiting the link below: http://codepen.io/kwakwak/full/kvEig When clicking the "Next" button, the form slides to the right smoothly. Howev ...

detecting syntax errors in CSS with @media queries and keyframes

/*general CSS setting for all device types above hd*/ * { margin: 0; padding: 0; } #watchonly { display: none; } ...

jQuery disrupts the functionality of other scripts

Let me start by saying that I have very little knowledge about scripting and HTML. Recently, I came across the following code: <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script> < ...

Can CKEditor be integrated with Mutation Observer? If so, how can this be achieved?

Trying to detect changes in the current CKEditor content. The goal is to identify which element's content has been modified when a user writes multiple paragraphs. Not well-versed in JavaScript or jQuery, but managed to come up with this code after s ...

What is the best way to wrap all divs except for the one with a .header-container-wrapper class?

In the midst of a project involving hubspot, I am facing an issue. I need to enclose all div elements within the body tag, except those with the class .header-container-wrapper. The default code provided by hubspot wraps all divs within #site-wrapper. $(& ...