From 9cb8246ecac91865912e3fcc028fe4732b471cb5 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Thu, 22 Jan 2015 09:30:28 +0000 Subject: [PATCH] Stop Chrome redrawing the page when programatically updating the hash --- js/jquery.responsiveTabs.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/jquery.responsiveTabs.js b/js/jquery.responsiveTabs.js index a93b293..27680e9 100644 --- a/js/jquery.responsiveTabs.js +++ b/js/jquery.responsiveTabs.js @@ -221,7 +221,17 @@ // Check if hash has to be set in the URL location if(_this.options.setHash) { - window.location.hash = activatedTab.selector; + // Set the hash using the history api if available to tackle Chromes repaint bug on hash change + if(history.pushState) { + + history.pushState(null, null, activatedTab.selector); + + } else { + + // Otherwise fallback to the hash update for sites that don't support the history api + window.location.hash = activatedTab.selector; + + } } e.data.tab._ignoreHashChange = true;