Skip to content

Commit

Permalink
chore: lint:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rpeterman-gp committed Oct 4, 2023
1 parent b1d9e66 commit b18abb7
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app/javascript/controllers/audio_breakpoint_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class extends Controller {

if (this.hasStartTimeValue) {
this.startTimeTarget.placeholder = convertSecondsToDuration(this.startTimeValue)
} else if (this.idValue === 'postRoll') {
} else if (this.idValue === "postRoll") {
this.startTimeTarget.placeholder = convertSecondsToDuration(this.initialMarkerValue.endTime)
}
}
Expand Down
20 changes: 11 additions & 9 deletions app/javascript/controllers/audio_breakpoints_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default class extends Controller {
id: "postRoll",
labelText: this.labelPostRollValue,
startTime: this.postRollPoint || this.durationValue,
endTime: this.durationValue
endTime: this.durationValue,
}
)

Expand Down Expand Up @@ -138,7 +138,9 @@ export default class extends Controller {
let newBreakpointMarker = {
...breakpointMarker,
changed: new Date().getMilliseconds(),
startTime: hasEndTime ? Math.max(this.minTime, Math.min(newStartTime, newEndTime, this.durationValue)) : newStartTime,
startTime: hasEndTime
? Math.max(this.minTime, Math.min(newStartTime, newEndTime, this.durationValue))
: newStartTime,
endTime: hasEndTime ? Math.min(this.durationValue, Math.max(newStartTime, newEndTime, this.minTime)) : undefined,
}
const isSegment = !!newBreakpointMarker.endTime
Expand Down Expand Up @@ -166,7 +168,8 @@ export default class extends Controller {
}
}
} else {
const inValidStartTime = newBreakpointMarker.startTime <= this.minTime || newBreakpointMarker.startTime >= this.durationValue
const inValidStartTime =
newBreakpointMarker.startTime <= this.minTime || newBreakpointMarker.startTime >= this.durationValue
const intersectingSegment = this.breakpointMarkers.find(
({ id: iId, startTime: iStartTime, endTime: iEndTime }) =>
id !== iId && newBreakpointMarker.startTime > iStartTime && newBreakpointMarker.startTime < iEndTime
Expand Down Expand Up @@ -324,10 +327,7 @@ export default class extends Controller {
const segmentStart = startTime > this.minTime ? startTime : null
const segmentEnd = (this.durationValue - next.startTime) * 100 > 10 ? next.startTime : null

return [
...a,
[segmentStart, segmentEnd]
]
return [...a, [segmentStart, segmentEnd]]
}, [])
}

Expand Down Expand Up @@ -359,9 +359,11 @@ export default class extends Controller {
control.dataset.audioBreakpointEndTimeValue = endTime
}

if (marker.id === 'postRoll') {
if (marker.id === "postRoll") {
control.dataset.audioBreakpointEndTimeValue = endTime
control.querySelector('[data-audio-breakpoint-target="startTime"]').setAttribute('placeholder', convertSecondsToDuration(this.durationValue))
control
.querySelector('[data-audio-breakpoint-target="startTime"]')
.setAttribute("placeholder", convertSecondsToDuration(this.durationValue))
}

controls.push(control)
Expand Down
12 changes: 6 additions & 6 deletions app/javascript/controllers/waveform_inspector_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ export default class extends Controller {
...optionsDefault,
id,
labelText,
time: startTime
time: startTime,
})

// Add a placeholder segment for this point.
const placeholderSegment = {
id: `placeholder.segments.${id}`,
startTime: id === 'preRoll' ? 0 : startTime,
endTime: id === 'postRoll' ? Math.ceil(this.peaks.player.getDuration()) : startTime
startTime: id === "preRoll" ? 0 : startTime,
endTime: id === "postRoll" ? Math.ceil(this.peaks.player.getDuration()) : startTime,
}
segments.push(placeholderSegment)
}
Expand All @@ -204,9 +204,9 @@ export default class extends Controller {
this.peaks?.segments.add(segments)

this.peaks?.segments.add({
startTime:0,
endTime:0.0001,
color: '#f00'
startTime: 0,
endTime: 0.0001,
color: "#f00",
})
}

Expand Down
7 changes: 3 additions & 4 deletions app/javascript/custom/PrxPointMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class PrxPointMarker {
}

init(group) {

// Label

if (this._options.view === "zoomview") {
Expand Down Expand Up @@ -158,7 +157,7 @@ class PrxPointMarker {
})
}

group.on('xChange', (evt) => {
group.on("xChange", (evt) => {
const layer = evt.currentTarget.getLayer()

self.updateLabelPosition(evt.newVal, layer)
Expand All @@ -167,7 +166,7 @@ class PrxPointMarker {
}

updateLabelPosition(posX, layer) {
if(!this._label || !layer?.canvas) return
if (!this._label || !layer?.canvas) return

const canvasWidth = layer.canvas.width
const labelWidth = this._label.getWidth()
Expand All @@ -190,7 +189,7 @@ class PrxPointMarker {
}

updateTimePosition(posX, layer) {
if(!this._time || !layer?.canvas) return
if (!this._time || !layer?.canvas) return

const timeWidth = this._time.getWidth()

Expand Down
32 changes: 16 additions & 16 deletions app/javascript/custom/PrxSegmentMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,23 @@ class PrxSegmentMarker {
}

if (
options.startMarker && this._segment.id === 'preRoll'
|| !options.startMarker && this._segment.id === 'postRoll'
(options.startMarker && this._segment.id === "preRoll") ||
(!options.startMarker && this._segment.id === "postRoll")
) {
this._disabled = true
}

if (!options.startMarker && this._segment.id === 'preRoll') {
if (!options.startMarker && this._segment.id === "preRoll") {
this._isPreRollMarker = true
}

if (options.startMarker && this._segment.id === 'postRoll') {
if (options.startMarker && this._segment.id === "postRoll") {
this._isPostRollMarker = true
}
}

init(group) {

if (this._disabled) return
if (this._disabled) return

// Label

Expand Down Expand Up @@ -170,10 +169,11 @@ class PrxSegmentMarker {
self._time.hide()
})

group.on('xChange', (evt) => {
group.on("xChange", (evt) => {
const layer = evt.currentTarget.getLayer()
self._canvas = layer.canvas
self._overlay = self._overlay || layer.children.find((child) => child.attrs.name === 'overlay' && child.attrs.draggable)
self._overlay =
self._overlay || layer.children.find((child) => child.attrs.name === "overlay" && child.attrs.draggable)

if (self._isPreRollMarker || self._isPostRollMarker) {
self._overlay.draggable(false)
Expand All @@ -185,11 +185,11 @@ class PrxSegmentMarker {
}

updateLabelPosition(posX) {
if(!this._label || !this._overlay) return
if (!this._label || !this._overlay) return

if (this._isPreRollMarker || this._isPostRollMarker) {
// Position Pre/Post roll marker label.
this.positionPreOrPostRollLabel(posX);
this.positionPreOrPostRollLabel(posX)
} else {
// Position label sticky within bounds of segment overlay.
this.positionLabelSticky(posX)
Expand Down Expand Up @@ -221,7 +221,7 @@ class PrxSegmentMarker {
const segmentWidth = this._overlay.getWidth()
const labelWidth = this._label.getWidth()
const rightBound = segmentWidth - this._paddingX - labelWidth
let newX = this._paddingX;
let newX = this._paddingX

if (posX < 0) {
newX = Math.min(Math.abs(posX) + this._paddingX, rightBound)
Expand All @@ -231,14 +231,14 @@ class PrxSegmentMarker {
}

updateTimePosition(posX) {
if(!this._time || !this._canvas) return
if (!this._time || !this._canvas) return

const canvasWidth = this._canvas.getWidth()
const timeWidth = this._time.getWidth()

if (
this._options.startMarker && posX < timeWidth ||
!this._options.startMarker && posX < canvasWidth - timeWidth
(this._options.startMarker && posX < timeWidth) ||
(!this._options.startMarker && posX < canvasWidth - timeWidth)
) {
this._time.x(this._handleWidth - this._lineWidth / 2)
this._timeTag.cornerRadius([0, this._tagCornerRadius, this._tagCornerRadius, 0])
Expand All @@ -249,7 +249,7 @@ class PrxSegmentMarker {
}

fitToView() {
if (this._disabled) return;
if (this._disabled) return

const height = this._options.layer.getHeight()

Expand All @@ -265,7 +265,7 @@ class PrxSegmentMarker {
}

timeUpdated(time) {
if (this._disabled) return;
if (this._disabled) return

if (this._time) {
this._timeText.setText(this._options.layer.formatTime(time))
Expand Down

0 comments on commit b18abb7

Please sign in to comment.