title: How to check if the user is going to the previous page with vue-router?
body: <p><strong>Context</strong></p>
  
  <p>I have this <a href="https://sachinchoolur.github.io/lightGallery/" rel="nofollow noreferrer">LightGallery</a> plugin, and I noticed that when it is in fullscreen, clicking on the previous page button will not close the LightGallery but go "silently" to the previous page without the user to be aware of it. </p>
  
  <p>In my case, I am building an SPA using VueJS and VueRouter, and when the user closes the LightGallery after clicking the previous page, it is confusing because the user expected to get back where he/she was.</p>
  
  <p>I know that VueRouter has navigation guards, but I miss one feature, to easily know if the user is going back or not.</p>
  
  <p>I am using VueRouter in "history" mode.</p>
  
  <p>As I use the "history" mode, I guess this explains why the <a href="https://www.npmjs.com/package/lg-hash" rel="nofollow noreferrer">lg-hash</a> plugin for LightGallery is of no help. It only appens a hash to my route, but the VueRouter is working independently of this hash.</p>
  
  <p><strong>Question</strong></p>
  
  <p>How to know if the user is going to the previous page using VueRouter? </p>
  
  <p>In "history" mode, VueRouter is using the History API. Is there anyway to use it to have a clue? Or should I eventually store manually the history and process it at each route change?</p>
  
  <p>I have found that we can listen to previous/next page using <code>window.onpopstate = function() {}</code>, but can I exclusively check for the previous page only using this method?</p>