Stacked divs experiencing layout issues in Firefox browser

An innovative book animation has been crafted, showcasing flipping pages with a clever use of z-index to stack the pages. While everything displays correctly in the browser UI, an interesting situation arises when inspecting elements.

In Firefox, selecting inspect after right-clicking on page 1 unexpectedly directs to the element for page 4. Furthermore, input elements placed on different pages exhibit varying behavior - some are unresponsive while others function as intended. This inconsistency persists as one flips through the pages.

This peculiar glitch seems to be isolated to Firefox; Chrome performs flawlessly without any issues. The question that lingers is whether this discrepancy stems from browser compatibility or something within the code itself?

EDIT: https://codesandbox.io/s/my-book-jlrmw?file=/src/components/HelloWorld.vue

Template:

<template>
<!-- Template content goes here -->
</template>

Script:

<script>
// Script content goes here
</script>

CSS:

<style scoped>
/* CSS content goes here */
</style>

Answer №1

One solution is to hide all hidden pages by using the CSS property display: none. When I tried this in Firefox dev tools, the issue disappeared. However, I had trouble implementing this in your specific program...

Answer №2

Shoutout to @biberman for discovering that using display: none resolves the issue. I've also found that incorporating pointer-events: none works as well, offering a better solution for my specific needs.

The necessary changes to resolve the problem have been implemented accordingly.

A bug report has been submitted here: https://bugzilla.mozilla.org/show_bug.cgi?id=1715796

script:

    export default {
        data() {
            return {
                pageNum: 1,
            }
        },
        methods: {
            openBook() {
                if(this.bookOpen === false) {
                    this.setPageStackOrder();
                    this.bookOpen = true;
                    
                    const cover = $(".front-cover").eq(1);
                    cover.addClass("turn");
                    setTimeout( () => {
                        cover.css("z-index", 0)
                    }, 2500);
                    
                    const page = $(".page").eq(this.numPages - this.pageNum);
                    page.removeClass("disable");
                    page.addClass("enable");
                }
            },

            setPageStackOrder() {
                for(let n = 0; n < this.numPages; n++) {
                    const page = $(".page").eq(n);
                    page.css("z-index", n+1);
                    page.addClass("disable")
                }
                const cover = $(".front-cover").eq(1);
                cover.css("z-index", 8);
            },
            
            SetPageEvents(direction) {
                const cur = this.numPages - this.pageNum;
                const next = (direction === "forward") ? cur - 1 : cur + 1;
                const prev = (direction === "forward") ? cur + 1 : cur - 1;
                const page = $(".page").eq(cur);
                const nextPage = $(".page").eq(next);
                const prevPage = $(".page").eq(prev);
                
                page.addClass("enable");
                page.removeClass("disable");
                nextPage.addClass("enable");
                nextPage.removeClass("disable");
                prevPage.addClass("disable");
                prevPage.removeClass("enable");
            },
            
            nextPage() {
                if(this.bookOpen === true && this.pageNum <= this.numPages) {
                    const page = $(".page").eq(this.numPages - this.pageNum);
                    const zIndex = this.pageNum;
                    
                    this.SetPageEvents("forward");
                    page.removeClass("turnBack");
                    page.addClass("turn");
                    setTimeout( () => {
                        page.css("z-index", zIndex);
                    }, 1000);
                    
                    this.pageNum++;
                }
            },
            
            previousPage() {
                if(this.bookOpen === true && this.pageNum > 0) {
                    this.pageNum--;
                    const page = $(".page").eq(this.numPages - this.pageNum);
                    const zIndex = (this.numPages - this.pageNum);
                    
                    this.SetPageEvents("backward");
                    page.removeClass("turn");
                    page.addClass("turnBack");
                    setTimeout( () => {
                        page.css("z-index", zIndex);
                    }, 2200);
                }
            },
        },

CSS:

.page.enable {
    pointer-events: all;
}

.page.disable {
    pointer-events: none;
}

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

Using ng-disabled on input elements within an ng-repeat directive

Showing different inputs based on an array looks like this <div data-ng-repeat="n in langInput.values"> <input type="text" id="auction_name_{{n.selected}}" class="form-control" name="auction_name_{{$index}}" ...

AJAX enhancing the functionality of the webgrid with dynamic filtering

I'm encountering a problem with implementing JS on my webgrid for sorting purposes. The scenario is that a user enters a string into a textbox and the webgrid below is refreshed (filtered based on matching results) without the entire page being refres ...

Importing an Excel file in .xlsx format cannot be done through AJAX JQUERY

I am trying to display the content of an Excel file when a button is clicked. It works fine when I change the extension to .csv, but when I change it to .xlsx, I get a character type error that looks like "y!+EfMykK5=|t G)s墙UtB)". These strange charact ...

What is the best way to add space between div elements with bootstrap classes?

For my project, I am utilizing bootstrap and I need to create space between divs. Here is the code I am using: <div className="container"> <div className="row"> <div className="col-lg-4 col-md-4 col-sm-12 col-12 box">a</div&g ...

Operating with JavaScript arrays and objects

My JavaScript array/object consists of the following data: [ { "name": "A", "selected_color": "Red" }, { "name": "B", "selected_color": "Green" }, { ...

Ensure the active pill remains visible upon refreshing the page with Bootstrap 4

Currently, I am in the process of building a website with Bootstrap 4, and I have chosen to use pills for my navigation bar buttons. The issue that I am facing is that whenever I refresh the page while on a different tab, it always redirects me back to the ...

Vue in Laravel triggers a 500 Internal Server Error with XHR when attempting to post data

Currently facing an issue with data storage in Laravel. I have followed the steps of creating a request using php artisan make:request, adding fillable fields to my Model, and incorporating the process into the Vue component. The button for form submissio ...

Issue with import alias not functioning within route grouping in Nextjs

Exploring the use of route groups and nested layout files led to encountering a "module-not-found" error with every import that used "@". Here is my jsconfig.json setup: { "compilerOptions": { "baseUrl": "./src", &q ...

Adding elements to an array in Node.js

In my 'both' object, I need to store 2 arrays: eng and fr. Each of these arrays contains multiple objects. How can I transfer all values from frDisplayData to fr:[] within the 'both' object: const displayData = []; var both = {eng:dis ...

Incorrect Display of Datepicker Position

Trying to display a datepicker in a modal, but the output is not as expected: The datepicker is appearing in the wrong place. However, it works fine when testing on jsfiddle. Here is the link: http://jsfiddle.net/alverhothasi/D7bBg/ Currently using the ...

Two ng-click events are triggered within a nested ng-click

I am facing an issue with using the ng-click within a nested list under another list that also has a ng-click event. Here is my code snippet: <ul> <li ng-repeat="facet in node.Facets" ng-click="updateNav(facet.Action)" ng-cloak & ...

Incorporating graphics into a React component

Currently exploring React JS and looking to dive into the practical side of things. Following a documentation tutorial that constructs a basic comment system. I've replicated the component structure outlined in the tutorial: PostBox PostList Pos ...

Microsoft Edge browser incorrectly calculates range.endOffset value

This particular problem is specific to the Microsoft Edge browser. I am attempting to apply a CSS style to a selected word using Range API's, but I am encountering an issue with the range.endOffset functionality in Edge. Below is the code snippet I am ...

Modify the layout of columns in Bootstrap dynamically without compromising on responsiveness

On my webpage, I have a section where I display cards of specific sizes (250*250). I want to show a maximum of 4 cards per row, stacking them on smaller viewports. Currently, the layout works fine with 4 or more cards, with the excess automatically moving ...

How do I convert images and information stored in a BLOB object into a PDF using JS, jQuery, and jsPDF?

Converting HTML code to a BLOB object as a PDF has been successful for me. var that = this; var doc = new jsPDF('p', 'pt', 'a4'); var htmlString = '<div class="container"> <img src="bas ...

How to optimize the utilization of Javascript variables within a Jquery function?

Currently, I am working on implementing an HTML5 min and max date range function. Initially, I wrote the code using variables and then embedded them in the correct attribute locations. However, after reviewing my code, my client (code reviewer) suggested ...

Develop a personalized event that is compatible with all types of selectors

If I have a simple script that changes the background color of an element when clicked: $(".foo").on("change.color", function() { $(this).css("background-color", "red"); }); $(".foo").click(function() { $(this).trigger("change.color"); }); Currently ...

Utilizing jQuery to convert letter input values into English: a step-by-step guide

I am developing a basic web application using Jquery. In this application, I aim to restrict user input language. For instance, if a user enters the Russian letter б in the input field, I want to automatically convert it to an English character. Below is ...

Adjusting the line height of an inline-block div causes surrounding inline-block siblings to shift downward

As I venture into exploring the line-height property, I came across information on MDN which stated: For non-replaced inline elements, it determines the height used in calculating the line box height. However, in this scenario, when I set the line-heigh ...

The Philosophy Behind Structuring Node.js Modules

There appears to be a common understanding regarding the directory structure in node.js, but I have not come across any official documentation on this topic. Based on my exploration of open source projects, it seems that most projects typically include a ...