You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by db...@apache.org on 2016/03/07 21:49:57 UTC
docs commit: CB-10744 Adding scroll offset for fragment links.
Repository: cordova-docs
Updated Branches:
refs/heads/master 73a881b0c -> e2108c62c
CB-10744 Adding scroll offset for fragment links.
Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/e2108c62
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/e2108c62
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/e2108c62
Branch: refs/heads/master
Commit: e2108c62c287cf7ad3337b0fd033f39dbfe1be8d
Parents: 73a881b
Author: Dmitry Blotsky <dm...@gmail.com>
Authored: Fri Mar 4 16:20:23 2016 -0800
Committer: Dmitry Blotsky <dm...@gmail.com>
Committed: Mon Mar 7 12:49:23 2016 -0800
----------------------------------------------------------------------
www/static/js/index.js | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/e2108c62/www/static/js/index.js
----------------------------------------------------------------------
diff --git a/www/static/js/index.js b/www/static/js/index.js
index 4e5c272..06230be 100644
--- a/www/static/js/index.js
+++ b/www/static/js/index.js
@@ -168,7 +168,7 @@ $(document).ready(function () {
// are annoying to escape
var targetSelector = "*[id='" + targetName + "'], *[name='" + targetName + "']";
- var matchingTargets = $(targetSelector);
+ var matchingTargets = $(targetSelector);
if (matchingTargets.length < 1) {
return;
}
@@ -177,10 +177,15 @@ $(document).ready(function () {
}
// get resulting scroll height
- // NOTE:
- // offset() returns the offset for the first element
- // if the array contains more than one element
- var scrollHeight = matchingTargets.offset().top;
+ var matchingTarget = matchingTargets.first();
+ var scrollHeight = matchingTarget.offset().top;
+
+ // add an extra offset (to account for the fixed page header),
+ // but only if there is no "fragment-anchor" class (because it
+ // already has an offset of its own for this purpose)
+ if (!matchingTarget.hasClass("fragment-anchor")) {
+ scrollHeight -= 50;
+ }
// animate
$('html, body').animate(
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org