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

Unrelated section tag breaks 'home button' #5

Closed
VictorVelarde opened this issue Dec 21, 2018 · 2 comments
Closed

Unrelated section tag breaks 'home button' #5

VictorVelarde opened this issue Dec 21, 2018 · 2 comments

Comments

@VictorVelarde
Copy link
Contributor

VictorVelarde commented Dec 21, 2018

Hi @jakobzhao, thx for your nice library!

Having used it recently in a little example, we were having problems with 'home button' not working fine. We checked the code and the problem is this function:

$('.storymap-scroll-down').click(function () {
  var viewing = $(".viewing");
  if (viewing.data("scene") !== $("section:last").data("scene")) {
    if (nav.length !== 0) {
      window.scrollBy(0, viewing.offset().top + viewing.height() - $(window).scrollTop() - $('.storymap-navbar').height() - 10);
    } else {
      window.scrollBy(0, viewing.offset().top + viewing.height() - $(window).scrollTop() - 10);
    }
  } else {
    window.scrollTo(0, 0);
  }
}); 

As you can see, there is a DOM selector like $("section:last").data("scene")), and in our web page we had another, unrelated 'section' tag (without any 'scene' attribute), so that broke the 'if' when returning undefined.

IMO it should be enough to just replace it with $("section[data-scene]:last").data('scene') to fix it.

Thx!


PD We were using https://cdn.rawgit.com/jakobzhao/storymap/master/dist/storymap.2.4.js

@jakobzhao
Copy link
Owner

bug fixed! Thank you so much @VictorVelarde

jakobzhao added a commit that referenced this issue Jan 10, 2019
@VictorVelarde
Copy link
Contributor Author

Thx @jakobzhao !!

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