-
Notifications
You must be signed in to change notification settings - Fork 13
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
Programmatic way to go to a slide? #26
Comments
I am doing a workaround similar to this: window.getPanelHeight = function() {
var firstpanel = $('.dm-pnl:first');
window.panelheight = parseInt($(firstpanel).css('min-height').replace('px', ''));
console.log(window.panelheight);
};
// debounced resize event catcher.
$( window ).resize(function() {
window.getPanelHeight();
var paneltimeout = window.setTimeout(getPanelHeight, 1000);
});
window.goToSlide = function(num) {
var oneheight = window.panelheight;
var targetheight = oneheight * num;
$("html,body").scrollTop(targetheight);
} |
Hey @HongPong Sorry for the delayed response. To programatically navigate to a slide will require a workaround. Doing a simple To retain the animation, the quickest solution will be to use This will of course first require that you have window.Doormat.prototype.travelTo = function(index) {
var panels = document.querySelectorAll('.dm-pnl');
if (panels[index - 1]) {
var pos = panels[index - 1].STARTING_POS;
if (pos !== undefined) $('body').animate({scrollTop: pos});
} else {
throw Error('Doormat: no panel available at that index!');
}
} The result will be that you can slide to any panel you want by index. For example; var myDoormat = new Doormat();
myDoormat.travelTo(4); Hope that helps you out! 😎 I'll add a note about this in the |
This is great! excellent timing and works like a charm. Cheers! |
No problem 😄 glad I could help! |
At least for me, this isn't working for IE11 (oh joy, fun times) - I can post diagnostic info if you can point me to what you might need. Thanks again. I'm not up on all the oddities that might happen with passing through prototype constructors in IE, maybe that is the issue? |
I found a different way to work around it. Best regards, thanks again for all the help. |
Hi,
Thanks for all your help before, the snapping is working very well. I am wondering if there is a way to go programmatically to a slide, if I call a JS event (preferable) or call going to an anchor (also cool). I.e. to make a table of contents that can be clicked to bring you to a slide. Thank you!
The text was updated successfully, but these errors were encountered: