0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-30 17:32:38 +00:00

Move livescrollToggle function out into a class method instead of an anonymous function.

Adjust code accordingly ( event.target vs document.getElementByClassname )
This commit is contained in:
David Bolack
2024-07-30 03:09:25 -05:00
parent dcdc8b4943
commit b34027699f

View File

@@ -105,6 +105,21 @@ const SplitPane = createClass({
userSetDividerPos : newSize
});
},
liveScrollToggle : function(e) {
const flipLiveScroll = !this.state.liveScroll;
const toggle = e.target;
const toggleDiv = toggle.parentElement;
if(flipLiveScroll) {
toggle.className = 'fas fa-lock';
toggleDiv.className = 'arrow lock';
} else {
toggle.className = 'fas fa-unlock';
toggleDiv.className = 'arrow unlock';
}
window.localStorage.setItem('liveScroll', String(flipLiveScroll));
this.setState({ liveScroll: flipLiveScroll });
},
/*
unFocus : function() {
if(document.selection){
@@ -138,20 +153,7 @@ const SplitPane = createClass({
</div>
<div id='scrollToggleDiv' className={`arrow lock`}
style={{ left: this.state.currentDividerPos-4 }}
onClick={()=>{
const flipLiveScroll = !this.state.liveScroll;
const toggle = document.getElementById('scrollToggle');
const toggleDiv = document.getElementById('scrollToggleDiv');
if(flipLiveScroll) {
toggle.className = 'fas fa-lock';
toggleDiv.className = 'arrow lock';
} else {
toggle.className = 'fas fa-unlock';
toggleDiv.className = 'arrow unlock';
}
window.localStorage.setItem('liveScroll', String(flipLiveScroll));
this.setState({ liveScroll: flipLiveScroll });
}} >
onClick={this.liveScrollToggle} >
<i id='scrollToggle' className={`fas fa-lock`} />
</div>
</>;