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

Animation is slow with push, replace state #183

Open
zhenyuan0502 opened this issue Dec 22, 2023 · 0 comments
Open

Animation is slow with push, replace state #183

zhenyuan0502 opened this issue Dec 22, 2023 · 0 comments

Comments

@zhenyuan0502
Copy link

With Obsidian.js, I encountered the problem of animation is being slow and freezing if we do click to a paper in the home screen and back with multiple times, in such case, refresh the page would solve the problem, I am not quite sure how we can improve on it, here is the original code

    Obsidian.L(url, function (data) {
      if (!$(data).filter('#single').length) {
        location.href = url;
        return;
      }
      switch (flag) {
        case 'push':
          history.pushState(state, title, url);
          $('#preview').html($(data).filter('#single'));
          break;
        case 'replace':
          history.replaceState(state, title, url);
          $('#preview').html($(data).filter('#single'));
          break;
      }
      document.title = title;
      $('#preview').html($(data).filter('#single'));
      switch (flag) {
        case 'push':
          Obsidian.preview();
          break;
        case 'replace':
          Obsidian.initArticleJs();
          window.scrollTo(0, 0);
          Obsidian.loaded();
          break;
      }
      setTimeout(function () {
        Obsidian.player();
        $('#top').show();
        comment = $('#gitalk-container');
        if (comment.data('ae') == true) {
          comment.click();
        }
      }, 0);
    });

What I have temporarily done is wipe out all animation and focus on url page change only

Obsidian.L(url, function (data) {
      location.href = url;
}
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

1 participant