GithubHelp home page GithubHelp logo

Comments (22)

zbabtkis avatar zbabtkis commented on May 17, 2024

I'm having this same problem. I'm calling a function called sidrSetup() when the window is resized which checks to see if the window is less than 960px and then calls .sidr() on my menu link.

from sidr.

artberri avatar artberri commented on May 17, 2024

I will try to reproduce it and to solve it during this weekend.

from sidr.

josholdham avatar josholdham commented on May 17, 2024

Thanks - much appreciated.

Let us know if you crack it.

from sidr.

josholdham avatar josholdham commented on May 17, 2024

Still can't crack this the proper way, but I came up with a cheap dirty hack: it's a pretty obvious and inelegant solution but thought I'd post it.

  1. Set a variable (e.g. counterHack) to 0.
  2. In the on-complete function, which does activate first time even if the toogle itself doesn't, add a decision layer in that checks if the counterHack === 0, and if so adds one, and then runs the toogle function as you tried originally.
  3. The next time the on-complete function is run (which will actually be right after this, as the toogle function you activate from within the decision pathway will have this same on-complete call), the else side of the decision will be activated, so this is where you need to put any code you want to execute genuinely on a successful toogle event.

That seems over-explained - it's actually very simple and hopefully will help.

If anyone finds a better solution let me know though. Thanks.

from sidr.

zbabtkis avatar zbabtkis commented on May 17, 2024

Thanks a lot man -- I'll use this for now and post here if I come across a better solution.

from sidr.

chrismadrigal avatar chrismadrigal commented on May 17, 2024

@josholdham can you give a code example? Thanks

from sidr.

DWboutin avatar DWboutin commented on May 17, 2024

I got it! :D Simple, add

$sideMenu.hide(); //at line 195.

The problem is that the menu .is(':visible') at start and doesn't go trought the condition

if('open' === action || ('toogle' === action && !$menu.is(':visible'))) { ... } //at line 71 

from sidr.

betoflakes avatar betoflakes commented on May 17, 2024

I tried adding $sideMenu.hide(); but still not working...

from sidr.

DWboutin avatar DWboutin commented on May 17, 2024

Check this file
http://www.soluvox.ca/wp-content/themes/soluvox/javascripts/jquery.sidr.min.js
It worked for me. Maybe it's the line 195 who aren't the exact line

from sidr.

charly83 avatar charly83 commented on May 17, 2024

I have the same problem, but when I use your file the menu works only one time.

from sidr.

DWboutin avatar DWboutin commented on May 17, 2024

Check this website http://soluvox.ca/ i uses it and it works well. Maybe it can help you!

from sidr.

charly83 avatar charly83 commented on May 17, 2024

I can not find the error. :(
My code for the menu: http://jsfiddle.net/Db6hs/

EDIT: I found it in the css file... display: none; :)

from sidr.

ryanbotha avatar ryanbotha commented on May 17, 2024

@artberri I am having the same issue with having to click/tap the menu button twice for the sidr menu to open. Is there a solution?
I have looked through all the forums and not one solution.
I tried adding the $sideMenu.hide(); as suggested by @DWboutin , but that seemed to work on a previous version when the code had some typos.
Great plugin :)
...but kinda desperate.

from sidr.

aaron-niemi avatar aaron-niemi commented on May 17, 2024

I posted a potential solution here: #133
It might work for you all?
HTH
-Aaron

from sidr.

MichelMathijssen avatar MichelMathijssen commented on May 17, 2024

I used this:

< style>
#mobile-header {
display: none;
}

@media only screen and (max-width: 767px){
#mobile-header {
display: block;
}
}
</ style>

< script>
$(function() {
$('#responsive-menu-button').sidr({
name: 'sidr-main',
source: '#navigation'
});
jQuery.sidr('close', 'sidr-main');
$(window).resize(function () {
jQuery.sidr('close', 'sidr-main');
});
});
</ script>

< div id="mobile-header">
< a id="responsive-menu-button" href="javascript:void(0)">Menu</ a>
</ div>

Solved the double click and does the menu disapeare when resizing.
No need to adjust the source js file.

Not tested on mobile devices yet...

from sidr.

 avatar commented on May 17, 2024

The only solution that works for me is closing sidr after its initialization. So code looks like:
$(document).ready(function() {
$('#sidr-menu').sidr();
$.sidr('close', 'sidr');
});

Hope it will help someone

from sidr.

biyanpasau avatar biyanpasau commented on May 17, 2024

Script from @DWboutin worked. Thank you!

from sidr.

sham2bam avatar sham2bam commented on May 17, 2024

@MichelMathijssen this worked like a charm—thanks man

from sidr.

maorb avatar maorb commented on May 17, 2024

I had similar issue with sidr on my android device (on chrome mobile debugger obn desktop the bug didn't reproduced), when I click the link to open the sidr, it always redirected me back to homepage
I tried @DWboutin code, and that bug also disappered! thank you very much!

from sidr.

maorb avatar maorb commented on May 17, 2024

Well, when using @DWboutin version of code, it appears that the onOpen and onClose events are missing, how can the two be merged?

from sidr.

wpexplorer avatar wpexplorer commented on May 17, 2024

Just make sure whatever you named the sidebar to hide it with CSS:

// JS
$( '.mobile-toggle-button' ).sidr({
name: 'sidr-main',
source: '#navigation'
});
/*css*/
#sidr-main { display: none; }

from sidr.

artberri avatar artberri commented on May 17, 2024

@wpexplorer gave you the proper answer. You need to hide the sidebar on CSS.

from sidr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.