# HG changeset patch # User Alexandre Segura # Date 1487846987 -3600 # Node ID 1bcbdeb60eee98a24c20111fa07c6717717112cd # Parent a61f9a9ebdc9ab9f0d1d24ec6e8750883dc935ae Scroll to annotation on page load. diff -r a61f9a9ebdc9 -r 1bcbdeb60eee src/iconolab/templates/iconolab/detail_image.html --- a/src/iconolab/templates/iconolab/detail_image.html Wed Feb 22 18:42:39 2017 +0100 +++ b/src/iconolab/templates/iconolab/detail_image.html Thu Feb 23 11:49:47 2017 +0100 @@ -31,7 +31,7 @@ {% else %}
-
Pas d'annotation pour cette image
+
Pas d'annotation pour cette image
{% endif %} @@ -155,12 +155,19 @@ location.hash = ''; }); + function scrollTo($container, $el) { + $container.animate({ + scrollTop: $container.scrollTop() - $container.offset().top + $el.offset().top + }, 600); + } + function router () { var url = location.hash.slice(1); if (url.length) { var annotation = url; var $el = $('.list-group a[data-annotation-id="'+annotation+'"]'); displayAnnotation($el); + scrollTo($el.closest('.panel'), $el); } } // window.addEventListener('hashchange', router);