From 69ce0655880d916c132489b539f7d5c92c00dc95 Mon Sep 17 00:00:00 2001 From: FlorianZahn Date: Sun, 3 Oct 2021 20:56:10 +0200 Subject: [PATCH 01/19] Scrolling over the segment times will change them --- src/components/SponsorTimeEditComponent.tsx | 61 +++++++++++++++++++-- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index a4422703..bba1a3c4 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -56,6 +56,11 @@ class SponsorTimeEditComponent extends React.Component this.configUpdate(); @@ -86,7 +91,6 @@ class SponsorTimeEditComponent extends React.Component this.setTimeToNow(0)}> {chrome.i18n.getMessage("bracketNow")} - { + // 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); + this.setState({sponsorTimeEdits}); + this.saveEditTimes(); + } }}> @@ -135,6 +156,24 @@ 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(); + } }}> @@ -155,12 +194,14 @@ class SponsorTimeEditComponent extends React.Component + onClick={this.toggleEditTime.bind(this)} + onWheel={this.toggleEditTime.bind(this)}> {utils.getFormattedTime(segment[0], true) + ((!isNaN(segment[1]) && getCategoryActionType(sponsorTime.category) === CategoryActionType.Skippable) - ? " " + chrome.i18n.getMessage("to") + " " + utils.getFormattedTime(segment[1], true) : "")} + ? " " + chrome.i18n.getMessage("to") + " " + utils.getFormattedTime(segment[1], true) : "")} ); } @@ -240,6 +281,18 @@ class SponsorTimeEditComponent extends React.Component 0) + { + return false; + } + } getCategoryOptions(): React.ReactElement[] { const elements = [(