From ff7bfac019e7788324bef0f33d930f9020c9e681 Mon Sep 17 00:00:00 2001 From: Sebastiaan Deckers Date: Fri, 22 Nov 2013 18:23:32 +0800 Subject: [PATCH] Smooth scrolling (WIP) #16 --- scripts/definitions.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/definitions.js b/scripts/definitions.js index ecb384f..73f61ac 100644 --- a/scripts/definitions.js +++ b/scripts/definitions.js @@ -235,6 +235,10 @@ document.body.appendChild(tooltip); }; + var smoothScrollTo = function (anchor) { + console.log(anchor, anchor.scrollTop, anchor.hash); + }; + var article = $('section > article'); $(article, 'dfn') @@ -263,6 +267,10 @@ anchor.addEventListener('mouseout', function (event) { hideTooltip(); }); + anchor.addEventListener('click', function (event) { + event.preventDefault(); + smoothScrollTo(anchor); + }); range.surroundContents(anchor); }); });