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 2015/09/03 03:22:55 UTC

docs commit: Fixed autoscrolling code breaking on non-heading links

Repository: cordova-docs
Updated Branches:
  refs/heads/cordova-website 58e6dc86f -> 359da1d01


Fixed autoscrolling code breaking on non-heading 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/359da1d0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/359da1d0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/359da1d0

Branch: refs/heads/cordova-website
Commit: 359da1d019cbbe44dd0a5ebcacaec8335b30e60e
Parents: 58e6dc8
Author: riknoll <ri...@microsoft.com>
Authored: Wed Sep 2 15:44:22 2015 -0700
Committer: riknoll <ri...@microsoft.com>
Committed: Wed Sep 2 15:44:22 2015 -0700

----------------------------------------------------------------------
 www/static/js/index.js | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/359da1d0/www/static/js/index.js
----------------------------------------------------------------------
diff --git a/www/static/js/index.js b/www/static/js/index.js
index b2c18c2..b10ceb6 100644
--- a/www/static/js/index.js
+++ b/www/static/js/index.js
@@ -116,22 +116,23 @@ $(document).ready(function () {
 
     // Smooth scroll to anchor links
     $("a[href^='#']").on('click', function(e) {
+        if(this.hash) {
+            // prevent default anchor click behavior
+            console.log('Scrolled to where you asked');
+            e.preventDefault();
 
-        // prevent default anchor click behavior
-        console.log('Scrolled to where you asked');
-        e.preventDefault();
+            // store hash
+            var hash = this.hash;
 
-        // store hash
-        var hash = this.hash;
-
-        // animate
-        $('html, body').animate(
-            {scrollTop: $(hash).offset().top},
-            300,
-            function () {
-                // when done, add hash to url (default click behaviour)
-                window.location.hash = hash;
-            }
-        );
+            // animate
+            $('html, body').animate(
+                {scrollTop: $(hash).offset().top},
+                300,
+                function () {
+                    // when done, add hash to url (default click behaviour)
+                    window.location.hash = hash;
+                }
+            );
+        }
     });
 });


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org