Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want or have to stick to CSS 3 transitions for performance or other reasons, then you could use <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window.setTimeout" rel="nofollow">window.setTimeout</a> to add a class after the timeout period that sets the display property to none. This should prevent the links from being clickable, remove the hover effects and prevent screen readers from reading the hidden content.</p> <p>The obvious flaw in this is that the setTimeout period would need to be the same as the period used in your transition, which introduces a maintenance cost.</p> <p><strong>Update:</strong> </p> <p>Thanks to DoXicK, I have created a <a href="http://jsfiddle.net/pwdst/PC28J/" rel="nofollow">JSFiddle which uses the transitionEnd event</a> to add the 'hide' class to the notification box if the standard transition property is available in the browser. It falls back to the setTimeout as described above.</p> <pre><code>// Notify Box (function() { var $notifyBox = $(".notify-box"); var supportsStandardTransition = ($notifyBox[0].style['transition'] !== undefined); if (supportsStandardTransition) { $notifyBox.on('transitionEnd', function() { $(this).addClass('hide'); }); } $(".notify-icon").on('click', function(){ if ($notifyBox.hasClass('show')) { $notifyBox.removeClass('show'); if (!supportsStandardTransition) { window.setTimeout(function () { $notifyBox.addClass('hide'); }, 150); } } else { $notifyBox.addClass('show').removeClass('hide'); } }); })(); </code></pre> <p>CSS-</p> <pre><code>.notify-box { background: #FFF; position: absolute; top: 50px; left: 0; opacity: 0; top: 70px; -ms-transition: opacity 0.15s ease-in-out; -moz-transition: opacity 0.15s ease-in-out; -o-transition: opacity 0.15s ease-in-out; -webkit-transition: opacity 0.15s ease-in-out; transition: opacity 0.15s ease-in-out; width: 200px; z-index: 9998; } .notify-box.show { opacity: 1; -ms-transition: none; -moz-transition: none; -o-transition: none; -webkit-transition: none; transition: none; } .notify-box.hide { display: none; } </code></pre> <p>I have also modified the HTML to initially add the 'hide' class to the notify box, added a class definition in the CSS and tweaked the transition styles to be specific to opacity, and removed the transition when the 'show' class is applied - to make the notification box appear 'instantly' (as quickly as the browser can render it) and only transition when hiding. I have also moved the top property to the .notify-box class so it doesn't move as it is being hidden, which looked odd.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload