com web/php: Fix navbar issue when # scroll is used: js/common.js
| From: | Dejan Marjanovic | Date: | Sat, 23 Nov 2013 02:32:26 +0000 |
| Subject: | com web/php: Fix navbar issue when # scroll is used: js/common.js | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-17219@lists.php.net to get a copy of this message | ||
Commit: f0a599b5d062e782469e8bbde2dbf2f8db835dc4
Author: Dejan Marjanovic <dejan.marjanovic@gmail.com> Sat, 23 Nov 2013 03:32:26
+0100
Parents: e80825e1c16de218febe4a7351088f04aa52edbe
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=f0a599b5d062e782469e8bbde2dbf2f8db835dc4
Log:
Fix navbar issue when # scroll is used
Changed paths:
M js/common.js
Diff:
diff --git a/js/common.js b/js/common.js
index 538c56f..dac7951 100755
--- a/js/common.js
+++ b/js/common.js
@@ -215,6 +215,30 @@ $(document).ready(function() {
language: getLanguage(),
limit: 3
});
+
+ // Hash scroll
+ var jHtmlBody = $('html, body');
+ function scroll(target, interval)
+ {
+ if ( ! interval && interval !== 0)
+ interval = 400;
+
+ jHtmlBody.animate({
+ scrollTop: $(target).offset().top - 52
+ }, interval);
+ return false;
+ }
+
+ if (window.location.hash)
+ scroll(window.location.hash, 0)
+
+ $('a[href^=#]').click(function(e){
+ e.preventDefault();
+ var hash = $.attr(this, 'href');
+ scroll(hash);
+ window.location.hash = hash;
+ });
+
});
/**