diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index 0790e24f..7bafb9c9 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -118,25 +118,7 @@ class SponsorTimeEditComponent extends React.Component { - // Using mousewheel will increment the number in the edit box - const step = 0.01; - const sponsorTimeEdits = this.state.sponsorTimeEdits; - var timeAsNumber = utils.getFormattedTimeToSeconds(this.state.sponsorTimeEdits[0]); - if (timeAsNumber !== null) { - if (this.wheelUpOrDown(e)){ - timeAsNumber += step; - }else if (timeAsNumber >= step){ - timeAsNumber -= step; - } else { - timeAsNumber = 0; - } - sponsorTimeEdits[0] = utils.getFormattedTime(timeAsNumber, true); - if (getCategoryActionType(sponsorTime.category) === CategoryActionType.POI) sponsorTimeEdits[1] = sponsorTimeEdits[0]; - this.setState({sponsorTimeEdits}); - this.saveEditTimes(); - } - }}> + onWheel={(e) => {this.changeTimesWhenScrolling(0, e, sponsorTime)}}> {getCategoryActionType(sponsorTime.category) === CategoryActionType.Skippable ? ( @@ -158,24 +140,7 @@ class SponsorTimeEditComponent extends React.Component { - // Using mousewheel will decrement the number in the edit box - const step = 0.01; - const sponsorTimeEdits = this.state.sponsorTimeEdits; - var timeAsNumber = utils.getFormattedTimeToSeconds(this.state.sponsorTimeEdits[1]); - if (timeAsNumber !== null) { - if (this.wheelUpOrDown(e)){ - timeAsNumber += step; - }else if (timeAsNumber >= step){ - timeAsNumber -= step; - } else { - timeAsNumber = 0; - } - sponsorTimeEdits[1] = utils.getFormattedTime(timeAsNumber, true); - this.setState({sponsorTimeEdits}); - this.saveEditTimes(); - } - }}> + onWheel={(e) => {this.changeTimesWhenScrolling(1, e, sponsorTime)}}> = step){ + timeAsNumber -= step; + } else { + timeAsNumber = 0; + } + sponsorTimeEdits[index] = utils.getFormattedTime(timeAsNumber, true); + if (getCategoryActionType(sponsorTime.category) === CategoryActionType.POI) sponsorTimeEdits[1] = sponsorTimeEdits[0]; + this.setState({sponsorTimeEdits}); + this.saveEditTimes(); + } + } + + isWheelScrollingUp(e: React.WheelEvent): boolean { console.log("wheelUpOrDown") if (e.deltaY < 0) {