vmitsaras / js-offcanvas

A lightweight, flexible jQuery off-canvas navigation plugin which lets you create fully accessible sidebar or top/bottom sliding (or push) panels with keyboard interactions and ARIA attributes.
http://codepen.io/vmitsaras/pen/gwGwJE
MIT License
269 stars 30 forks source link

Offcanvas appearing on initial page load #11

Closed p-f-d-d closed 6 years ago

p-f-d-d commented 6 years ago

Hello sorry perhaps this is a simple issue to resolve but whenever the page loads first on https://lesfestivalsdewallonie.be the offcanvas elements seem to appear. Its mainly noticeable on https://lesfestivalsdewallonie.be (homepage) and https://lesfestivalsdewallonie.be/programme/.

Any ideas why this is?

vmitsaras commented 6 years ago

The CSS-Classes are applied with js. Try to hide the Offcanvas-Elements on page load

<aside class='is-hidden js-offcanvas' id='...'>

.is-hidden { display:none!important }

$( document ).on( "create.offcanvas", function( event ){
       $( event.target ).removeClass('.is-hidden');
});
p-f-d-d commented 6 years ago

Thanks for the above, I applied this but the panels don't display - I can see the overlay being applied but the panel content remains as " display: none "

vmitsaras commented 6 years ago

Solution A:

Change/Add CSS and JS Files

CSS

<style type="text/css">
.is-hidden { display:none!important }
</style>

JS

<script>    
jQuery(document).ready(function($) {

  $('#calendrier').offcanvas({resize: false});
  $( document ).on( "create.offcanvas", function( event ){
       $( event.target ).removeClass('.is-hidden');
  });
  $(document).trigger("enhance");
});
</script>

Solution B:

Try to apply the CSS-Classes HTML

<aside class="is-hidden js-offcanvas" data-offcanvas-options='{ "modifiers": "right,overlay" }' id="calendrier">...
/* change to this*/
<aside class="js-offcanvas c-offcanvas c-offcanvas--right c-offcanvas--overlay is-closed" data-offcanvas-options='{ "modifiers": right,overlay" }" id="calendrier"> ...
p-f-d-d commented 6 years ago

Thanks! the css-class solution worked perfectly!