Comparing version 0.3.9 to 0.3.10
@@ -128,2 +128,9 @@ 'use strict'; | ||
skipPopStateHandling: function skipPopStateHandling(event) { | ||
if (event.state && event.state.source == "swup") { | ||
return false; | ||
} | ||
return true; | ||
}, | ||
LINK_SELECTOR: 'a[href^="/"]:not([data-no-swup]), a[href^="#"]:not([data-no-swup]), a[xlink\\:href]' | ||
@@ -268,2 +275,11 @@ | ||
/** | ||
* modify initial history record | ||
*/ | ||
window.history.replaceState(Object.assign({}, window.history.state, { | ||
url: window.location.href, | ||
random: Math.random(), | ||
source: "swup" | ||
}), document.title, window.location.href); | ||
/** | ||
* trigger enabled event | ||
@@ -385,2 +401,3 @@ */ | ||
var link = new _Link2.default(); | ||
if (this.options.skipPopStateHandling(event)) return; | ||
link.setPath(event.state ? event.state.url : window.location.pathname); | ||
@@ -387,0 +404,0 @@ if (link.getHash() != '') { |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,4 +6,5 @@ module.exports = function (url) { | ||
url: url || window.location.href.split(window.location.hostname)[1], | ||
random: Math.random() | ||
random: Math.random(), | ||
source: "swup" | ||
}, document.getElementsByTagName('title')[0].innerText, url || window.location.href.split(window.location.hostname)[1]); | ||
}; |
{ | ||
"name": "swup", | ||
"version": "0.3.9", | ||
"version": "0.3.10", | ||
"description": "Animated page transitions with css.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -268,2 +268,17 @@ # swup | ||
### Skip popState Handling | ||
Swup is built around browser history API, but sometimes some other tools manipulating the browser history can be used as well. | ||
For this reason, swup places a source property into every history state object it creates, so it can be later identified (swup also modifies current history record on start, to include the "swup" source property as well). | ||
On `popState` events, swup only handles the records that were created by swup. | ||
This behavior can be modified by `skipPopStateHandling` option, which is represented by a function returning boolean (false = handle the popstate, true = do nothing). | ||
The function accepts one argument - the popstate event. Option defaults to the following: | ||
```javascript | ||
skipPopStateHandling: function(event){ | ||
if (event.state && event.state.source == "swup") { | ||
return false; | ||
} | ||
return true; | ||
} | ||
``` | ||
### Default values | ||
@@ -283,3 +298,9 @@ ```javascript | ||
support: true, | ||
disableIE: false | ||
disableIE: false, | ||
skipPopStateHandling: function(event){ | ||
if (event.state && event.state.source == "swup") { | ||
return false; | ||
} | ||
return true; | ||
}, | ||
} | ||
@@ -286,0 +307,0 @@ ``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
126709
413
0
32
959