briangonzalez / codrops-medium-style-page-transitions

The repository for this article: http://tympanus.net/codrops/2013/10/30/medium-style-page-transition/
258 stars 40 forks source link

Back Button #7

Open michaelmco opened 10 years ago

michaelmco commented 10 years ago

Hi thanks so much for posting the article! I have a really quick question.

When I hit the back button in the browser, it will change the url from index.html#2 to index.html#1 but the data from "post_2.json" remains.

Thanks in advance.

briangonzalez commented 10 years ago

How are you running the example?

michaelmco commented 10 years ago

Both in Chrome on my mac and on my iPhone.

michaelmco commented 10 years ago

I just uploaded it to my server. michaelm.co/new That fixed my issue in chrome on my mac (I had been testing locally before), but the issue persists on my iPhone. Thanks for your help.

briangonzalez commented 10 years ago

Hmm, I don't have time to dig in right now, but I am sure if you dig in to app.js, you'll find the culprit by searching for popState / pushState.

IsaacHub commented 7 years ago

@michaelmco @briangonzalez It's working.. Browsers' both back and forward buttons are working well... Just comment the if block in the following function:

ArticleAnimator.bindPopstate = function(){
  var self = this;
  $window.on('popstate', function(e){

    /*if( !history.state || self.initialLoad ){
     self.initialLoad = false;
     return;
     }*/

    self.currentPostIndex = history.state.index;
    self.$current.replaceWith( history.state.current );
    self.$next.replaceWith( history.state.next );

    self.refreshCurrentAndNextSelection();
    self.createPost({ type: 'next' });
    self.bindGotoNextClick();

  });
}