Skip to content

v0.2.0: pangea.js!

Latest
Compare
Choose a tag to compare
@schlosser schlosser released this 22 Mar 21:22
· 4 commits to master since this release

New name, same old library!

Well, with some bugfixes. The most crazy of which involves issues with swiping backwards in Safari for Mac. While most browsers restart the JavaScript when you swipe back, Safari actually freezes the JavaScript state and continues it when you swipe back (normally leaving the previous page dangling in it's intermediate state). This is fixed by running code to reset the state in a setTimeout call which executes after the page changes. Check out this snippet below:

var followLink = function() {

  // Run this code after we've left the page. On most browsers, this code
  // will never run, but for browsers that suspend sessions and return to
  // them when you press back, this will undo the transformations we
  // performed so that we're not left with a half-transformed page.
  setTimeout(function() {
    this.body.className = this.body.className.replace(animation.bodyClass, '');
    animation.finalElement.removeEventListener(this.transitionEndEvent, this.boundOnTransitionEnd);
    this.currentAnimation = null;
  }.bind(this), 100);

  if (window.location.pathname === animation.path) {
    window.location.reload();
  } else {
    window.location = animation.path;
  }
}.bind(this);