Fossil SCM

Experimental change to scroll the focused entry into view with a Fossil-style scrolling function to keep the entry centered vertically. This is much better than `Element.scrollIntoView()' for FF (but maybe a matter of tweaking the function arguments). Kudos to the wiz who programmed the `scrollToSelected()' function!

florian 2022-08-04 06:57 timeline-keyboard-navigation
Commit ad3a8e0b87ea716f416daa0719ad161c151eb02f7403161cc0930fa9df1c5548
1 file changed +11 -2
+11 -2
--- src/graph.js
+++ src/graph.js
@@ -905,10 +905,18 @@
905905
'hash': ti.rowinfo[k].h,
906906
'branch': ti.rowinfo[k].br };
907907
}
908908
}
909909
return null;
910
+ }
911
+ function focusScrollToIntoViewTheFossilWay(e){
912
+ var y = 0;
913
+ do{
914
+ y += e.offsetTop;
915
+ }while( e = e.offsetParent );
916
+ y -= window.innerHeight/2;
917
+ if( y>0 ) window.scrollTo(0,y);
910918
}
911919
function focusVisualize(id,scroll){
912920
var td = document.querySelector('.timelineFocused');
913921
if( td ) td.classList.remove('timelineFocused');
914922
if( !id ) return true;
@@ -916,12 +924,13 @@
916924
if( tn ){
917925
td = tn.parentElement.nextElementSibling;
918926
if( td ) {
919927
td.classList.add('timelineFocused');
920928
if( scroll ){
921
- if( td.scrollIntoViewIfNeeded ) td.scrollIntoViewIfNeeded();
922
- else td.scrollIntoView(false);
929
+ focusScrollToIntoViewTheFossilWay(td);
930
+ //if( td.scrollIntoViewIfNeeded ) td.scrollIntoViewIfNeeded();
931
+ //else td.scrollIntoView(false);
923932
}
924933
return true;
925934
}
926935
}
927936
return false;
928937
--- src/graph.js
+++ src/graph.js
@@ -905,10 +905,18 @@
905 'hash': ti.rowinfo[k].h,
906 'branch': ti.rowinfo[k].br };
907 }
908 }
909 return null;
 
 
 
 
 
 
 
 
910 }
911 function focusVisualize(id,scroll){
912 var td = document.querySelector('.timelineFocused');
913 if( td ) td.classList.remove('timelineFocused');
914 if( !id ) return true;
@@ -916,12 +924,13 @@
916 if( tn ){
917 td = tn.parentElement.nextElementSibling;
918 if( td ) {
919 td.classList.add('timelineFocused');
920 if( scroll ){
921 if( td.scrollIntoViewIfNeeded ) td.scrollIntoViewIfNeeded();
922 else td.scrollIntoView(false);
 
923 }
924 return true;
925 }
926 }
927 return false;
928
--- src/graph.js
+++ src/graph.js
@@ -905,10 +905,18 @@
905 'hash': ti.rowinfo[k].h,
906 'branch': ti.rowinfo[k].br };
907 }
908 }
909 return null;
910 }
911 function focusScrollToIntoViewTheFossilWay(e){
912 var y = 0;
913 do{
914 y += e.offsetTop;
915 }while( e = e.offsetParent );
916 y -= window.innerHeight/2;
917 if( y>0 ) window.scrollTo(0,y);
918 }
919 function focusVisualize(id,scroll){
920 var td = document.querySelector('.timelineFocused');
921 if( td ) td.classList.remove('timelineFocused');
922 if( !id ) return true;
@@ -916,12 +924,13 @@
924 if( tn ){
925 td = tn.parentElement.nextElementSibling;
926 if( td ) {
927 td.classList.add('timelineFocused');
928 if( scroll ){
929 focusScrollToIntoViewTheFossilWay(td);
930 //if( td.scrollIntoViewIfNeeded ) td.scrollIntoViewIfNeeded();
931 //else td.scrollIntoView(false);
932 }
933 return true;
934 }
935 }
936 return false;
937

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button