lexgui 0.7.8 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/extensions/codeeditor.js +398 -321
- package/build/extensions/videoeditor.js +50 -10
- package/build/lexgui.js +24 -10
- package/build/lexgui.min.js +1 -1
- package/build/lexgui.module.js +24 -10
- package/build/lexgui.module.min.js +1 -1
- package/changelog.md +16 -1
- package/package.json +1 -1
|
@@ -34,7 +34,7 @@ class TimeBar {
|
|
|
34
34
|
|
|
35
35
|
this.markerWidth = options.markerWidth ?? 8;
|
|
36
36
|
this.markerHeight = options.markerHeight ?? (this.canvas.height * 0.5);
|
|
37
|
-
this.offset = options.offset || (this.markerWidth*0.5 +
|
|
37
|
+
this.offset = options.offset || (this.markerWidth*0.5 + 5);
|
|
38
38
|
|
|
39
39
|
// dimensions of line (not canvas)
|
|
40
40
|
this.lineWidth = this.canvas.width - this.offset * 2;
|
|
@@ -147,7 +147,7 @@ class TimeBar {
|
|
|
147
147
|
ctx.fillStyle = ctx.strokeStyle = options.fillColor || '#111' // "#FFF";
|
|
148
148
|
|
|
149
149
|
|
|
150
|
-
y -= this.offset +
|
|
150
|
+
y -= this.offset + 8;
|
|
151
151
|
// Current time ball grab
|
|
152
152
|
ctx.fillStyle = options.fillColor || '#e5e5e5';
|
|
153
153
|
ctx.beginPath();
|
|
@@ -318,7 +318,7 @@ class VideoEditor {
|
|
|
318
318
|
|
|
319
319
|
this.playing = false;
|
|
320
320
|
this.requestId = null;
|
|
321
|
-
|
|
321
|
+
this.videoReady = false;
|
|
322
322
|
this.currentTime = this.startTime = 0;
|
|
323
323
|
this.startTimeString = "0:0";
|
|
324
324
|
this.endTimeString = "0:0";
|
|
@@ -349,7 +349,7 @@ class VideoEditor {
|
|
|
349
349
|
this.dragOffsetY = 0;
|
|
350
350
|
// Create video element and load it
|
|
351
351
|
let video = this.video = options.video ?? document.createElement( 'video' );
|
|
352
|
-
this.
|
|
352
|
+
this.loop = options.loop ?? false;
|
|
353
353
|
|
|
354
354
|
if(options.src) {
|
|
355
355
|
this.video.src = options.src;
|
|
@@ -397,7 +397,10 @@ class VideoEditor {
|
|
|
397
397
|
this.controlsPanelLeft.addButton('', "", (v) => {
|
|
398
398
|
this.playing = !this.playing;
|
|
399
399
|
if(this.playing) {
|
|
400
|
-
this.video.
|
|
400
|
+
if( this.video.currentTime + 0.000001 >= this.endTime) {
|
|
401
|
+
this.video.currentTime = this.startTime;
|
|
402
|
+
}
|
|
403
|
+
this.video.play()
|
|
401
404
|
}
|
|
402
405
|
else {
|
|
403
406
|
this.video.pause();
|
|
@@ -447,13 +450,16 @@ class VideoEditor {
|
|
|
447
450
|
event.preventDefault();
|
|
448
451
|
event.stopPropagation();
|
|
449
452
|
|
|
450
|
-
|
|
453
|
+
this.playing = !this.playing;
|
|
454
|
+
if(this.playing) {
|
|
455
|
+
if( this.video.currentTime + 0.000001 >= this.endTime) {
|
|
456
|
+
this.video.currentTime = this.startTime;
|
|
457
|
+
}
|
|
451
458
|
this.video.play();
|
|
452
459
|
}
|
|
453
460
|
else {
|
|
454
461
|
this.video.pause();
|
|
455
462
|
}
|
|
456
|
-
this.playing = !this.playing;
|
|
457
463
|
this.controlsPanelLeft.refresh();
|
|
458
464
|
}
|
|
459
465
|
}
|
|
@@ -610,15 +616,41 @@ class VideoEditor {
|
|
|
610
616
|
}
|
|
611
617
|
|
|
612
618
|
async _loadVideo( options = {} ) {
|
|
619
|
+
this.videoReady = false;
|
|
613
620
|
while(this.video.duration === Infinity || isNaN(this.video.duration) || !this.timebar) {
|
|
614
621
|
await new Promise(r => setTimeout(r, 1000));
|
|
615
622
|
this.video.currentTime = 10000000 * Math.random();
|
|
616
623
|
}
|
|
624
|
+
this.video.currentTime = 0.01; // BUG: some videos will not play unless this line is present
|
|
617
625
|
|
|
626
|
+
// Duration can change if the video is dynamic (stream). This function is to ensure to load all buffer data
|
|
627
|
+
const forceLoadChunks = () => {
|
|
628
|
+
const state = this.videoReady;
|
|
629
|
+
if(this.video.readyState > 3) {
|
|
630
|
+
this.videoReady = true;
|
|
631
|
+
}
|
|
632
|
+
if(!state) {
|
|
633
|
+
this.video.currentTime = this.video.duration;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
this.video.addEventListener( "canplaythrough", forceLoadChunks, {passive :true} );
|
|
638
|
+
|
|
639
|
+
this.video.ondurationchange = (v) => {
|
|
640
|
+
if( this.video.duration != this.endTime ) {
|
|
641
|
+
|
|
642
|
+
this.video.currentTime = this.startTime;
|
|
643
|
+
console.log("duration changed from", this.endTime, " to ", this.video.duration);
|
|
644
|
+
this.endTime = this.video.duration;
|
|
645
|
+
const x = this._timeToX(this.endTime);
|
|
646
|
+
this._setEndValue(x);
|
|
647
|
+
}
|
|
648
|
+
this.video.currentTime = this.startTime;
|
|
649
|
+
}
|
|
650
|
+
|
|
618
651
|
this.timebar.startX = this.timebar.position.x;
|
|
619
652
|
this.timebar.endX = this.timebar.position.x + this.timebar.lineWidth;
|
|
620
653
|
|
|
621
|
-
this.video.currentTime = 0.01; // BUG: some videos will not play unless this line is present
|
|
622
654
|
this.endTime = this.video.duration;
|
|
623
655
|
|
|
624
656
|
this._setEndValue(this.timebar.endX);
|
|
@@ -660,8 +692,16 @@ class VideoEditor {
|
|
|
660
692
|
this.onDraw();
|
|
661
693
|
}
|
|
662
694
|
if(this.playing) {
|
|
663
|
-
if(this.video.currentTime >= this.endTime) {
|
|
664
|
-
this.video.
|
|
695
|
+
if( this.video.currentTime + 0.000001 >= this.endTime) {
|
|
696
|
+
this.video.pause();
|
|
697
|
+
if(!this.loop) {
|
|
698
|
+
this.playing = false;
|
|
699
|
+
this.controlsPanelLeft.refresh();
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
this.video.currentTime = this.startTime;
|
|
703
|
+
this.video.play();
|
|
704
|
+
}
|
|
665
705
|
}
|
|
666
706
|
const x = this._timeToX(this.video.currentTime);
|
|
667
707
|
this._setCurrentValue(x, false);
|
package/build/lexgui.js
CHANGED
|
@@ -14,7 +14,7 @@ console.warn( 'Script _build/lexgui.js_ is depracated and will be removed soon.
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
const LX = {
|
|
17
|
-
version: "0.7.
|
|
17
|
+
version: "0.7.9",
|
|
18
18
|
ready: false,
|
|
19
19
|
extensions: [], // Store extensions used
|
|
20
20
|
signals: {}, // Events and triggers
|
|
@@ -1332,18 +1332,18 @@ class DropdownMenu {
|
|
|
1332
1332
|
else
|
|
1333
1333
|
{
|
|
1334
1334
|
menuItem.addEventListener( "click", () => {
|
|
1335
|
-
const f = item.callback;
|
|
1336
|
-
if( f )
|
|
1337
|
-
{
|
|
1338
|
-
f.call( this, key, menuItem );
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
1335
|
const radioName = menuItem.getAttribute( "data-radioname" );
|
|
1342
1336
|
if( radioName )
|
|
1343
1337
|
{
|
|
1344
1338
|
this._trigger[ radioName ] = key;
|
|
1345
1339
|
}
|
|
1346
1340
|
|
|
1341
|
+
const f = item.callback;
|
|
1342
|
+
if( f )
|
|
1343
|
+
{
|
|
1344
|
+
f.call( this, key, menuItem, radioName );
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
1347
|
// If has options, it's a radio group label, so don't close the menu
|
|
1348
1348
|
if( !item.options && ( item.closeOnClick ?? true ) )
|
|
1349
1349
|
{
|
|
@@ -15169,17 +15169,26 @@ class Menubar {
|
|
|
15169
15169
|
} });
|
|
15170
15170
|
};
|
|
15171
15171
|
|
|
15172
|
-
entry.addEventListener("
|
|
15172
|
+
entry.addEventListener("mousedown", (e) => {
|
|
15173
|
+
e.preventDefault();
|
|
15174
|
+
});
|
|
15175
|
+
|
|
15176
|
+
entry.addEventListener("mouseup", (e) => {
|
|
15177
|
+
|
|
15178
|
+
e.preventDefault();
|
|
15179
|
+
|
|
15173
15180
|
const f = item[ 'callback' ];
|
|
15174
15181
|
if( f )
|
|
15175
15182
|
{
|
|
15176
|
-
f.call( this, key, entry );
|
|
15183
|
+
f.call( this, key, entry, e );
|
|
15177
15184
|
return;
|
|
15178
15185
|
}
|
|
15179
15186
|
|
|
15180
15187
|
_showEntry();
|
|
15181
15188
|
|
|
15182
15189
|
this.focused = true;
|
|
15190
|
+
|
|
15191
|
+
return false;
|
|
15183
15192
|
});
|
|
15184
15193
|
|
|
15185
15194
|
entry.addEventListener( "mouseover", (e) => {
|
|
@@ -15346,7 +15355,12 @@ class Menubar {
|
|
|
15346
15355
|
}
|
|
15347
15356
|
|
|
15348
15357
|
const _b = button.querySelector('a');
|
|
15349
|
-
|
|
15358
|
+
|
|
15359
|
+
_b.addEventListener( "mousedown", (e) => {
|
|
15360
|
+
e.preventDefault();
|
|
15361
|
+
});
|
|
15362
|
+
|
|
15363
|
+
_b.addEventListener( "mouseup", (e) => {
|
|
15350
15364
|
if( callback && !disabled )
|
|
15351
15365
|
{
|
|
15352
15366
|
callback.call( this, _b, e );
|