fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7f9be0d
)
Start scroll only if anchor references existing element.
author
Marek Stępniowski
<marek@stepniowski.com>
Mon, 22 Sep 2008 13:54:54 +0000
(15:54 +0200)
committer
Marek Stępniowski
<marek@stepniowski.com>
Mon, 22 Sep 2008 13:54:54 +0000
(15:54 +0200)
wolnelektury/media/js/book.js
patch
|
blob
|
history
diff --git
a/wolnelektury/media/js/book.js
b/wolnelektury/media/js/book.js
index
fb4467f
..
41e3be2
100644
(file)
--- a/
wolnelektury/media/js/book.js
+++ b/
wolnelektury/media/js/book.js
@@
-1,10
+1,12
@@
$(function() {
function scrollToAnchor(anchor) {
if (anchor) {
- var name = anchor.slice(1);
- $.scrollTo('a[name="' + name + '"]', 500, {offset: {top: -50, left: 0}});
- $('a[name="' + name + '"]').highlightFade('yellow');
- window.location.hash = '#' + name;
+ var element = $('a[name="' + anchor.slice(1) + '"]');
+ if (element.length > 0) {
+ $.scrollTo(element, 500, {offset: {top: -50, left: 0}});
+ $(element).highlightFade('yellow');
+ window.location.hash = anchor;
+ }
}
}