Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples of opening programmatically other than touch swipe? #10

Closed
bluematter opened this issue Apr 2, 2013 · 6 comments
Closed

Examples of opening programmatically other than touch swipe? #10

bluematter opened this issue Apr 2, 2013 · 6 comments

Comments

@bluematter
Copy link

Instead of using touch swipe how can I use 2 different selectors to open/close one opening and the other selector closing?

@artberri
Copy link
Owner

artberri commented Apr 5, 2013

// An example for opening:
$('#open-button').click(function(e) {
    e.preventDefault();
    $.sidr('open', 'sidr-name');
});

// An example for closing:
$('#close-button').click(function(e) {
    e.preventDefault();
    $.sidr('close', 'sidr-name');
});

;)

@artberri artberri closed this as completed Apr 5, 2013
@bluematter
Copy link
Author

Ok thanks, simple like I thought. That creates a better user experience..

If you're willing, how would I write it to close at a pixel point of the page scroll?

Ex. scrolling 800 px down it closes? Man I need to pick up a book on jquery... Thanks though this is awesome and am using it in a theme, will show some love and give credit to you.

@bluematter
Copy link
Author

This worked perfect for me, but the content inside the menu does not show, do I need to add something?

@artberri
Copy link
Owner

artberri commented Apr 5, 2013

For the first question:

$(window).scroll(function() {
    if($(window).scrollTop() > 800) {
        $.sidr('close', 'sidr-name');
    }
});

For the second... did you write correctly the sidr name?

@bluematter
Copy link
Author

Wow brilliant my man! You're right I didn't realize how important the name was, and didn't realize the name needed to be the ID.

I just bought the jQuery Cookbook by oreilly, bout to get into it ASAP...

The sidr on the theme looks great!!

Thanks a million

@Papagorgio
Copy link

@artberri Hi, I used your code to close sidr when scrolling up however sidr doesn't close (minimize to the left) it just disappears and leaves a empty space on the left side of the screen?

Any ideas? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants