frio: highlight - use offset() instead of postion()

This commit is contained in:
rabuzarus 2016-08-10 14:14:58 +02:00
parent 531cba5ce5
commit cf23a81c33
2 changed files with 8 additions and 4 deletions

View file

@ -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);
});

View file

@ -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);
});
}