mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 13:07:05 +03:00
Scrolling over the segment times will change them
This commit is contained in:
@@ -56,6 +56,11 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Prevent scrolling while changing times
|
||||||
|
document.getElementById("sponsorTimesContainer" + this.idSuffix).addEventListener('wheel', function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
}, {passive: false});
|
||||||
|
|
||||||
// Add as a config listener
|
// Add as a config listener
|
||||||
if (!this.configUpdateListener) {
|
if (!this.configUpdateListener) {
|
||||||
this.configUpdateListener = () => this.configUpdate();
|
this.configUpdateListener = () => this.configUpdate();
|
||||||
@@ -86,7 +91,6 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
node.style.setProperty("text-shadow", "none", "important");
|
node.style.setProperty("text-shadow", "none", "important");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create time display
|
// Create time display
|
||||||
let timeDisplay: JSX.Element;
|
let timeDisplay: JSX.Element;
|
||||||
const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
|
const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
|
||||||
@@ -101,7 +105,6 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
onClick={() => this.setTimeToNow(0)}>
|
onClick={() => this.setTimeToNow(0)}>
|
||||||
{chrome.i18n.getMessage("bracketNow")}
|
{chrome.i18n.getMessage("bracketNow")}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<input id={"submittingTime0" + this.idSuffix}
|
<input id={"submittingTime0" + this.idSuffix}
|
||||||
className="sponsorTimeEdit sponsorTimeEditInput"
|
className="sponsorTimeEdit sponsorTimeEditInput"
|
||||||
ref={oldYouTubeDarkStyles}
|
ref={oldYouTubeDarkStyles}
|
||||||
@@ -114,6 +117,24 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
|
|
||||||
this.setState({sponsorTimeEdits});
|
this.setState({sponsorTimeEdits});
|
||||||
this.saveEditTimes();
|
this.saveEditTimes();
|
||||||
|
}}
|
||||||
|
onWheel={(e) => {
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
}}>
|
}}>
|
||||||
</input>
|
</input>
|
||||||
|
|
||||||
@@ -135,6 +156,24 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
this.setState({sponsorTimeEdits});
|
this.setState({sponsorTimeEdits});
|
||||||
|
|
||||||
this.saveEditTimes();
|
this.saveEditTimes();
|
||||||
|
}}
|
||||||
|
onWheel={(e) => {
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
}}>
|
}}>
|
||||||
</input>
|
</input>
|
||||||
|
|
||||||
@@ -155,9 +194,11 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
timeDisplay = (
|
timeDisplay = (
|
||||||
|
|
||||||
<div id={"sponsorTimesContainer" + this.idSuffix}
|
<div id={"sponsorTimesContainer" + this.idSuffix}
|
||||||
className="sponsorTimeDisplay"
|
className="sponsorTimeDisplay"
|
||||||
onClick={this.toggleEditTime.bind(this)}>
|
onClick={this.toggleEditTime.bind(this)}
|
||||||
|
onWheel={this.toggleEditTime.bind(this)}>
|
||||||
{utils.getFormattedTime(segment[0], true) +
|
{utils.getFormattedTime(segment[0], true) +
|
||||||
((!isNaN(segment[1]) && getCategoryActionType(sponsorTime.category) === CategoryActionType.Skippable)
|
((!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<SponsorTimeEditProps, Spo
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wheelUpOrDown(e: React.WheelEvent): Boolean{
|
||||||
|
// Returns true if the wheel scrolls up and false if the wheel scrolls down
|
||||||
|
console.log("wheelUpOrDown")
|
||||||
|
if (e.deltaY < 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (e.deltaY > 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
getCategoryOptions(): React.ReactElement[] {
|
getCategoryOptions(): React.ReactElement[] {
|
||||||
const elements = [(
|
const elements = [(
|
||||||
<option value={DEFAULT_CATEGORY}
|
<option value={DEFAULT_CATEGORY}
|
||||||
|
|||||||
Reference in New Issue
Block a user