Permalink
Browse files

merge to doc

  • Loading branch information...
1 parent f741439 commit 5025d377d87da89d5da2633b29854ba1328fe0a3 @ArthurClemens committed Jan 29, 2012
Showing with 24 additions and 14 deletions.
  1. +12 −12 index.html
  2. +12 −2 js/jquery.page-scroll.js
View
@@ -19,19 +19,19 @@
$('body').hide();
// secretly go to top
window.scrollTo(0, 0);
-
- $(window).pageScroll({
- id: location.hash,
- event: 'load hashchange',
- speed: 700,
- maxDuration: 2000,
- mayScroll: function(opts) {
- if ($('body').is(':hidden')) {
- $('body').show();
- }
- }
- });
}
+
+ $(window).pageScroll({
+ id: location.hash,
+ event: 'load hashchange',
+ speed: 700,
+ maxDuration: 2000,
+ mayScroll: function(opts) {
+ if ($('body').is(':hidden')) {
+ $('body').show();
+ }
+ }
+ });
if (console) {
console.log("page scroll defaults: ", $.fn.pageScroll.defaults);
View
@@ -36,13 +36,23 @@ Reset default values by passing null.
scrollToAnchor;
getIdFromAnchorUrl = function (url) {
+ if (!url) {
+ return '';
+ }
return url.replace(/^[^#]*#?!?(.*)$/, '$1');
};
getTargetOnThisPage = function (elem) {
var $target,
- id = getIdFromAnchorUrl(elem.hash),
- targetEl = document.getElementById(id);
+ id,
+ targetEl;
+
+ if (!elem.hash) {
+ return undefined;
+ }
+ id = getIdFromAnchorUrl(elem.hash);
+ targetEl = document.getElementById(id);
+
if (location.pathname.replace(/^\//, '') === elem.pathname.replace(/^\//, '') && location.hostname === elem.hostname) {
if (!targetEl) {
// try named link

0 comments on commit 5025d37

Please sign in to comment.