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

Unexpected 'is-animating' pages when turning page right after init #10

Closed
benjaminlong opened this issue Dec 7, 2016 · 2 comments
Closed

Comments

@benjaminlong
Copy link

First of all, thank you for your awesome work !

I discovered a tiny bug.
If you programmatically turning a page right after init like this:

var book1 = new Heidelberg($('#Heidelberg-example-1'), {
  previousButton: $('#previous'),
  nextButton: $('#next'),
  hasSpreads: true,
  onPageTurn: function(el, els) {
    console.log('Page turned');
  },
  onSpreadSetup: function(el) {
    console.log('Spread setup');
  }
});

book1.turnPage(5);

Page 5 is active, but webkitTransitionEnd oTransitionEnd msTransitionEnd transitionend events wont be triggered - See file heidelberg.js line 207

els.pagesAnimating.on('webkitTransitionEnd oTransitionEnd msTransitionEnd transitionend', function () {
  els.pagesAnimating.removeClass('is-animating');
  els.pagesActive.removeClass('was-active');
}.bind(document));

and you will have unexpected 'is-animating' pages.

screen shot 2016-12-07 at 11 23 16 am

As a result, if you keep turning the pages 'forward', the left page will stay the same.
My goal was to init the book and open it at a given page. I guess, It could be done directly by adding an option to Heidelberg and update the code around line 80-88. But I am not sure it's a wanted behavior.

if(!options.canClose) {
  var coverEl = $('<div />').addClass('Heidelberg-HiddenCover');
  el.prepend(coverEl.clone());
  el.append(coverEl.clone());
  els.pages.eq(0).add(els.pages.eq(1)).addClass('is-active');
}
else {
  els.pages.eq(0).addClass('is-active');
}

I was hoping to come with a pull request to fix this, but I don't have it yet. I was hoping to have some feedbacks and advices from you.

All the best !

@benjaminlong
Copy link
Author

Adding an "index" options could result to something like:
benjaminlong@12801e8

@djgrant
Copy link
Owner

djgrant commented Dec 31, 2016

Thanks for the bug report @benjaminlong. I like your solution. Adding an initialActivePage parameter to the options block seems like a sensible idea to me. Feel free to submit a PR for this!

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

2 participants