Prettified all files.
This commit is contained in:
+27
-22
@@ -1,6 +1,4 @@
|
||||
|
||||
export default class Events {
|
||||
|
||||
static stop(event) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
@@ -20,8 +18,7 @@ export default class Events {
|
||||
}
|
||||
|
||||
static isCaptured(event) {
|
||||
if (event.__capturedBy)
|
||||
return true
|
||||
if (event.__capturedBy) return true
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -30,7 +27,7 @@ export default class Events {
|
||||
}
|
||||
|
||||
static isPointerDown(event) {
|
||||
// According to
|
||||
// According to
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events
|
||||
// pointer events use the buttons feature to represent pressed buttons
|
||||
return event.buttons
|
||||
@@ -77,8 +74,15 @@ export default class Events {
|
||||
for (let i = 0; i < targets.length; i++) {
|
||||
let t = targets[i]
|
||||
let touchTarget = document.elementFromPoint(t.pageX, t.pageY)
|
||||
let touch = new Touch(undefined, touchTarget, t.identifier,
|
||||
t.pageX, t.pageY, t.screenX, t.screenY)
|
||||
let touch = new Touch(
|
||||
undefined,
|
||||
touchTarget,
|
||||
t.identifier,
|
||||
t.pageX,
|
||||
t.pageY,
|
||||
t.screenX,
|
||||
t.screenY
|
||||
)
|
||||
touches.push(touch)
|
||||
}
|
||||
return new TouchList(...touches)
|
||||
@@ -168,8 +172,7 @@ export default class Events {
|
||||
for (let key of keys) {
|
||||
try {
|
||||
result += ' ' + key + ':' + event[key]
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
console.log('Invalid key: ' + key)
|
||||
}
|
||||
}
|
||||
@@ -179,11 +182,15 @@ export default class Events {
|
||||
static compareExtractedWithSimulated() {
|
||||
var diffs = 0
|
||||
if (this.extracted.length != this.simulated.length) {
|
||||
alert('Unequal length of extracted [' + this.extracted.length +
|
||||
'] and simulated events [' + this.simulated.length + '].')
|
||||
alert(
|
||||
'Unequal length of extracted [' +
|
||||
this.extracted.length +
|
||||
'] and simulated events [' +
|
||||
this.simulated.length +
|
||||
'].'
|
||||
)
|
||||
diffs += 1
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for (let i = 0; i < this.extracted.length; i++) {
|
||||
var extracted = this.extracted[i]
|
||||
var simulated = this.simulated[i]
|
||||
@@ -238,8 +245,10 @@ export default class Events {
|
||||
div.innerHTML = line
|
||||
this.popup.appendChild(div)
|
||||
}
|
||||
Elements.setStyle(this.popup,
|
||||
{ left: event.clientX + 'px', top: event.clientY + 'px' })
|
||||
Elements.setStyle(this.popup, {
|
||||
left: event.clientX + 'px',
|
||||
top: event.clientY + 'px'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +259,6 @@ Events.simulated = []
|
||||
Events.simulationRunning = false
|
||||
|
||||
export class EventRecorder {
|
||||
|
||||
constructor() {
|
||||
this.recording = []
|
||||
this.recorded = []
|
||||
@@ -262,8 +270,7 @@ export class EventRecorder {
|
||||
if (length == 0) {
|
||||
this.startTime = event.timeStamp
|
||||
Events.reset()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
let last = this.recording[length - 1]
|
||||
if (event.timeStamp < last.time) {
|
||||
console.log('warning: wrong temporal order')
|
||||
@@ -291,7 +298,7 @@ export class EventRecorder {
|
||||
if (this.step < this.recorded.length) {
|
||||
let { type, time, constructor, data } = this.recorded[this.step]
|
||||
Events.simulateEvent(type, constructor, data)
|
||||
|
||||
|
||||
this.step += 1
|
||||
let dt = 0
|
||||
if (this.step < this.recorded.length) {
|
||||
@@ -305,8 +312,7 @@ export class EventRecorder {
|
||||
let delta = Math.round(dt)
|
||||
setTimeout(() => this.replay(whileCondition, onComplete), delta)
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
console.log('Played ' + this.step + ' events' + onComplete)
|
||||
Events.simulationRunning = false
|
||||
if (onComplete != null) {
|
||||
@@ -316,4 +322,3 @@ export class EventRecorder {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user