0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-31 10:52:42 +00:00

Add a Live Scroll lock/unlock below Brew/Source Jump buttons.

The button displays the *next* state of the toggle. IE, if the current state is locked ( Live scrolling is active ) the icon is unlock with a corresponding mouse-over.

It may be desirable to invert this.
This commit is contained in:
David Bolack
2024-05-18 22:17:29 -05:00
parent 8ece54701d
commit b7dc47fe9e
3 changed files with 30 additions and 4 deletions

View File

@@ -28,7 +28,8 @@ let liveScroll = true;
const isElementCodeMirror=(element)=>{
let el = element;
while( el.tagName != 'body' ) {
if( el.classList.contains('CodeMirror-code') || el.classList.contains('CodeMirror-line'))
if ( !el?.classList ) return false
if( el?.classList?.contains('CodeMirror-code') || el.classList.contains('CodeMirror-line'))
return true;
el = el.parentNode;
}
@@ -43,6 +44,7 @@ const Editor = createClass({
text : '',
style : ''
},
liveScroll : true,
onTextChange : ()=>{},
onStyleChange : ()=>{},
@@ -99,6 +101,9 @@ const Editor = createClass({
if(prevProps.moveSource !== this.props.moveSource) {
this.sourceJump();
};
if(prevProps.liveScroll !== this.props.liveScroll) {
liveScroll = !liveScroll;
};
},
handleControlKeys : function(e){
@@ -126,10 +131,7 @@ const Editor = createClass({
if ((e.shiftKey) && (!e.altKey) && (e.keyCode == J_KEY)) this.sourceJump();
// Toggle Live-scrolling on Shift-CTRL-ALT-J
if((e.shiftKey) && (e.altKey) && (e.keyCode == J_KEY)) {
console.log('Trying to flip the property?')
console.log(liveScroll);
liveScroll = !liveScroll;
console.log(liveScroll);
}
if( e.keyCode == J_KEY) {