Comments (6)
Adding this CSS on #js-modal should correct it:
-webkit-overflow-scrolling: auto !important;
from jquery-accessible-modal-window-aria.
Hi,
the only "CSS-only" solution I've found that is working on my iPad 2 is to set up position fixed on the body, it prevents scroll on iPad. However, the page under the modal is going to the top, so it is not satisfying. :-\
@juliemoynat I've tested it on my iPad 2, it is not working :-\
from jquery-accessible-modal-window-aria.
Hi,
Sometimes it works...
Also, if you have an "overflow: hidden" on the body, it doesn't work on Safari. You'll need to have it on an element inside...
Yes, "position: fixed" works and it's not the best solution.
I have no idea of what to do to have a better experience again...
from jquery-accessible-modal-window-aria.
This is how I disable scrolling across all devices.
class ScrollClass {
constructor () {
this.$body = $('body');
this.styles = {
disabled: {
'height': '100%',
'overflow': 'hidden',
},
enabled: {
'height': '',
'overflow': '',
}
};
}
disable ($element = $(window)) {
let disabled = false;
let scrollTop = window.pageYOffset;
$element
.on('scroll.disablescroll', (event) => {
event.preventDefault();
this.$body.css(this.styles.disabled);
window.scrollTo(0, scrollTop);
return false;
})
.on('touchstart.disablescroll', () => {
disabled = true;
})
.on('touchmove.disablescroll', (event) => {
if (disabled) {
event.preventDefault();
}
})
.on('touchend.disablescroll', () => {
disabled = false;
});
}
enable ($element = $(window)) {
$element.off('.disablescroll');
this.$body.css(this.styles.enabled);
}
}
export const Scroll = new ScrollClass();
Essentially, the meat of it is setting a variable to true on touchstart
, check if the variable is true on touchmove
and setting the variable to false on touchend
.
from jquery-accessible-modal-window-aria.
Hi @alexmccabe How could I work this in with a click function for when a burger menu is open
I'm using this at the moment to add my body class
$('.site-header').on('click', '.menu-toggle', function(e) {
e.preventDefault();
$('body').toggleClass('no-scroll menu-open');
});
from jquery-accessible-modal-window-aria.
import Scroll from './path/to/ScrollClass';
$('.site-header').on('click', '.menu-toggle', function(e) {
e.preventDefault();
$('body').toggleClass('no-scroll menu-open');
Scroll.disable();
});
from jquery-accessible-modal-window-aria.
Related Issues (20)
- gestion des tabindex -1 quand modale ouverte HOT 10
- Bower package HOT 1
- Duplicate ID when using data-modal-content-id attribute
- Video auto play broken HOT 3
- Uncaught ReferenceError: $close is not defined HOT 2
- Add type="button" to button
- Fix compatibility with jquery 2.x and 3.x HOT 1
- Untranslatable text in background modal HOT 1
- attribute to focus something after opening HOT 4
- Modal Text Inaccessible on iOS HOT 7
- No modal role announced by NVDA ON Firefox HOT 2
- Fix invalid license format in package.json HOT 1
- [SPIP] Ajax + Modale = cassé HOT 11
- Focus not staying in the modal on iPhone (iOS 11.2.2) HOT 1
- keep link action with class="js-modal-close" HOT 4
- Add prefix classes to set up different styles
- Comportement étrange HOT 7
- Publish as npm package HOT 1
- Animating the modal? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-accessible-modal-window-aria.