From cf23a81c33eb29153196e01d9a68d45230ff1933 Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Wed, 10 Aug 2016 14:14:58 +0200 Subject: [PATCH] frio: highlight - use offset() instead of postion() --- view/theme/frio/js/mod_display.js | 4 ++-- view/theme/frio/js/theme.js | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/view/theme/frio/js/mod_display.js b/view/theme/frio/js/mod_display.js index 1faacaeb7..c93d2c006 100644 --- a/view/theme/frio/js/mod_display.js +++ b/view/theme/frio/js/mod_display.js @@ -3,9 +3,9 @@ */ // Catch the GUID from the URL -var itemID = window.location.pathname.split("/").pop(); +var itemGuid = window.location.pathname.split("/").pop(); $(document).ready(function(){ // Scroll to the Item by its GUID - scrollToItem(itemID); + scrollToItem('item-'+itemGuid); }); diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index f153fc33f..1e93be24c 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -553,11 +553,15 @@ function scrollToItem(itemID) { var colWhite = {backgroundColor:'#F5F5F5'}; var colShiny = {backgroundColor:'#FFF176'}; + // Get the Item Position (we need to substract 100 to match + // correct position + var itemPos = $('#'+itemID).offset().top - 100; + // Scroll to the DIV with the ID (GUID) $('html, body').animate({ - scrollTop: $('#item-'+itemID).position().top + scrollTop: itemPos }, 400, function() { // Highlight post/commenent with ID (GUID) - $('#item-'+itemID).animate(colWhite, 1000).animate(colShiny).animate(colWhite, 2000); + $('#'+itemID).animate(colWhite, 1000).animate(colShiny).animate(colWhite, 600); }); }