Creating a full-screen overlay that is mobile-friendly using Javascript and CSS

I'm currently developing a jQuery lightbox plugin that needs to work seamlessly on both mobile devices and desktop computers. The main issue I'm facing is with the full-screen overlay effect. Most resources suggest using position: fixed or background-attachment: fixed for this, but fixed positioning is not fully supported on mobile devices, leading me to explore alternative solutions.

My current approach involves dynamically adjusting the overlay dimensions based on window resize events using $( window ).on( 'resize' ). However, this method causes flickering scroll bars when resizing the window, resulting in a jumpy user experience. You can see this behavior in action at the following links: (http://jsfiddle.net/dominic_p/ZqLCx/3/ or ).

Does anyone have suggestions on how to address this issue? While the code is still a work in progress, I've identified what I believe to be the two main problem areas in the jsFiddle example with a comment labeled "THE PROBLEM: START".

Update: I recently came up with an idea to switch to position: fixed for desktop browsers while maintaining the window resize approach for mobile devices. This adjustment has improved performance, but there is still noticeable flickering when reducing the browser window size, especially vertically. Additionally, using position: fixed on Android 4 results in a large white gap on the side of the screen that can be horizontally scrolled through in portrait mode only. Any recommendations on resolving these issues?

Answer №1

To solve the issue of flickering, it appears that setting the overflow-x (or simply overflow if you prefer) property for the <body> element to hidden is the solution. Interestingly, it was not the overlay layer causing the flicker, but rather the contents of the lightbox.

Although I am still facing a challenge with a white gap appearing on Android devices, this is a separate issue that I will address separately. Therefore, I am sharing this as the resolution to the flicker problem.

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

Node.js route does not support io.sockets.on functionality

Incorporating io.sockets.on into a route within a Node.js and Express application is proving to be challenging. I have been following the guidance provided here: While I am able to successfully send io.sockets.emit events, I am encountering an issue with ...

Using ObjectIDs in MongoDB may be successful, however, it may not function properly in Mongoose

The desired effect is successfully achieved by the first code snippet shown below: //in mongodb console: db.collection.update({"username":"name"}, {$pull : { "task" : { "_id" : ObjectId("55280205702c316b6d79c89c")}}}) However, the second code snippet wri ...

Can you explain the significance of the sentinel value NULL mentioned in the Android Developer JSONObject reference page?

Can you explain the significance of the sentinel value NULL in Android Developer JSONObject reference page? Here is an excerpt from the page for reference: The class represents null in two incompatible ways: the standard Java null reference, and the senti ...

What is the best way to choose an HTML element in React?

Is there a way in React to change the theme value based on localStorage and set it to either light or dark mode? https://i.sstatic.net/Iecsj.jpg I am familiar with using Ref hooks in components, but how can I access a DOM element in the index.html file? ...

Delay with Vue.js v-bind causing form submission to occur before the value is updated

Trying to update a hidden input with a value from a SweetAlert modal, but encountering issues. The following code isn't working as expected - the form submits, but the hidden field's value remains null. HTML: <input type="hidden" name="inpu ...

The AngularJS $rootscope $destroy event is not being triggered, resulting in timeouts not being cancelled

Below is the code snippet that I am currently working with: function initialize() { var defer = $q.defer(); var deferTimer = $q.defer(); var cancelTimeout = $timeout(function() { if (defer !== null) { ctrlr.setProcessingParameters('X ...

Incorporating Chakra UI, what is the best way to display a modal box upon page load?

Is there a way to display a modal box when the page loads in Chakra UI? I have been searching through Chakra's documentation but couldn't find any information on this. import { useDisclosure, Modal, ModalOverlay, ModalContent, ...

An issue occurred when attempting to add @nguniversal/express-engine@next with ng add command

Issue I have been attempting to integrate SEO features into my Angular project by executing "ng add @nguniversal/express-engine@next", however, I keep encountering an error message: An uncaught exception occurred: Cannot locate module '@schematics/ ...

What could be causing Typed.js to not function properly in my situation?

Having an issue with typed.js not functioning properly. Here is the code snippet: <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="js/jquery-1.11.3.min.js"></script> <!-- Include all compiled plugins ...

Adjust the width of the table's td elements

I am looking to create a table similar to the one shown above. Here is my implementation. Please review my JSFiddle. HTML: <table border="0" id="cssTable"> <tr> <td>eredgb</td> <td><a href="self">0 ...

In the process of making a request with axios in an express server

Struggling with a simple call to an API using Axios with Express, and I can't figure out why it's always pending in the browser. Here is my route: var express = require("express"); var router = express.Router(); const controller = require("../. ...

In Swift 5, accessing MKMapView within a UITableViewCell poses usability challenges for users

My attempt to embed a MKMapView in a UITableViewCell seems successful at first glance. However, I've run into some issues where the map is not interactive - it can't be zoomed, scrolled, or tapped. Even the legal link provided by Apple is unrespo ...

Instructions on keeping a numerical counter at its current value for all site visitors

Recently, I integrated a number counter into my website. However, I am facing an issue where the count resets to zero whenever a new visitor accesses the site. I'd like the count to remain persistent and update based on the previous count. For instanc ...

HTML2Canvas now offers full compatibility with Scalable Vector Graphics (

Looking to snag a screenshot of a div that contains svg elements and other components using html2canvas. I came across 2 different versions of html2canvas. Version 1 Version 2 What sets them apart, and do either of them support svg elements and work wel ...

What is the method to create an HTML div with a sloping edge?

my HTML & CSS code looks like this: https://i.sstatic.net/8vIaZ.jpg I would like it to look more like: https://i.sstatic.net/O9SA6.jpg Any tips on how I can achieve this?... ...

Make the height of the div the same as the size of the screen

In my Twitter Bootstrap project, I have a div element that contains content which will overflow vertically off the screen. I want the div to adjust its height to match the size of the browser window, allowing the remaining content to scroll vertically wit ...

Make sure to properly check the size of the image before uploading it in express js

Below is the code I have written to verify if an image's size and width meet the specified criteria: im.identify(req.files.image,function (err,features) { //console.log(features); if(features.width<1000 ...

Can we customize and include our own advertising banner?

I am thinking about incorporating my own custom ad banners in my app instead of relying on existing banners like iAd or AdMob. Is it feasible to include custom ad banners in an Apple app? Does Apple offer any tools or support for this? ...

Experimenting with sails.socket using npm for testing purposes

Currently, I am utilizing sails.js v0.11.0 and delving into unit testing. While I have a good grasp on testing normal controllers through http requests, I am at a loss on how to approach testing the same calls via socket requests. Any recommendations for ...

Angular2 does not load Js twice

I specified the path to my JS file in angular.cli. It loaded successfully during the initialization of the Angular app, but when navigating back to the component, it failed to load. Any suggestions on how to fix this issue would be greatly appreciated. Th ...