Comments (8)
That would be an idea, I have to test.
I'm almost sure it would be possible to create a small delay to start/end an animation before adding/removing it.
from jquery-accessible-modal-window-aria.
I didn't test that much but this would be handy :)
from jquery-accessible-modal-window-aria.
Yop,
a few minutes of testing, and it is not so bad : http://a11y.nicolas-hoffmann.net/modal/ (cf 2nd example, different on mobile and desktop 👍 ).
One remaining point : for ending/closing animation. Do I add a delay parameter in JS to let it execute itself in the other sense. Or get directly animation value with JS ??
from jquery-accessible-modal-window-aria.
I'll go for the delay: apply a class to run the animation (let's say during 1s
) then after the delay of 1s
remove the <dialog>
from DOM (no need to toggle visibility, I guess).
What's your opinion?
from jquery-accessible-modal-window-aria.
I've managed to do it, but it is not intuitive at all. This is the code when you perform a close action.
I get the computed value of animation-duration (0.5s), convert it to ms for jquery delay.
That was the easy part.
$page.removeAttr('aria-hidden');
var delay = $js_modal.css( "animation-duration" );
if ( delay != '0s' ){
var timeout = parseFloat(delay.replace('s','')) * 1000;
timeout++;
$js_modal.removeClass( $class_element );
setTimeout(function() { $js_modal.addClass( $class_element_reverse ); }, 1);
setTimeout(function() {
$body.removeClass('no-scroll');
$js_modal.remove();
$js_modal_overlay.remove();
$( $focus_back ).focus();
$js_modal.removeClass( $class_element_reverse );
$js_modal.addClass( $class_element );
}, timeout);
}
else {
$body.removeClass('no-scroll');
$js_modal.remove();
$js_modal_overlay.remove();
$( $focus_back ).focus();
}
I thought adding a class like this would be enough :
.simple-animated-modal--reverse {
animation-direction: reverse;
}
The animation has to be set up from a different class name (the easier solution), or you have to trigger a reflow, etc. https://css-tricks.com/restart-css-animation/
The only way I've found to do it is :
- remove the class
- to set up a time out to add the reverse animation class
- and get back to starting conditions.
Sometimes it is not working, I suppose that you have to wait for the animation to be done.
Well, a bit complicated, however, having 2 differents class names could be cool to set up different animations.
Any better ideas ? Maybe transitions with attributes could be easy to manage but less powerful?
from jquery-accessible-modal-window-aria.
I can't have a look right now but I'll try next week. Just reading, it seems a bit complicated. We'll do simpler !
from jquery-accessible-modal-window-aria.
You can see the result here : http://a11y.nicolas-hoffmann.net/modal/ ;) (the code is not yet on Github, I would like to find simpler)
from jquery-accessible-modal-window-aria.
I close it, until we find a better solution ! ;)
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
- no-scroll class does not prevent scrolling in iOS HOT 6
- 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
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.