From b34027699f33f6c618b73158758d3dd900119c1a Mon Sep 17 00:00:00 2001 From: David Bolack Date: Tue, 30 Jul 2024 03:09:25 -0500 Subject: [PATCH] Move livescrollToggle function out into a class method instead of an anonymous function. Adjust code accordingly ( event.target vs document.getElementByClassname ) --- shared/naturalcrit/splitPane/splitPane.jsx | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/shared/naturalcrit/splitPane/splitPane.jsx b/shared/naturalcrit/splitPane/splitPane.jsx index 8e10085c8..91faadcb5 100644 --- a/shared/naturalcrit/splitPane/splitPane.jsx +++ b/shared/naturalcrit/splitPane/splitPane.jsx @@ -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({
{ - 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} >
;