Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit e8808e7

Browse files
committed
adding a moveTo function
1 parent 89bca90 commit e8808e7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

public/styleguide/js/annotations-viewer.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ var annotationsViewer = {
111111
$('#sg-annotation-container').css('bottom',-pos);
112112
},
113113

114+
/**
115+
* moves to a particular item in the viewer
116+
*/
117+
moveTo: function(number) {
118+
if (document.getElementById("annotation-"+number) !== undefined) {
119+
var top = document.getElementById("annotation-"+number).offsetTop;
120+
$('#sg-annotation-container').animate({scrollTop: top - 10}, 600);
121+
}
122+
},
123+
114124
/**
115125
* when turning on or switching between patterns with annotations view on make sure we get
116126
* the annotations from from the pattern via post message
@@ -202,8 +212,7 @@ var annotationsViewer = {
202212
} else if (data.annotationState !== undefined) {
203213
document.getElementById("annotation-state-"+data.displayNumber).innerHTML = (data.annotationState == true) ? "" : " hidden";
204214
} else if (data.displaynumber !== undefined) {
205-
var top = document.getElementById("annotation-"+data.displaynumber).offsetTop;
206-
$('#sg-annotation-container').animate({scrollTop: top - 10}, 600);
215+
annotationsViewer.moveTo(data.displaynumber);
207216
} else if (data.keyPress !== undefined) {
208217
if (data.keyPress == 'ctrl+shift+a') {
209218
annotationsViewer.toggleComments();

0 commit comments

Comments
 (0)