Skip to content

Commit cb66829

Browse files
fix: polyfills and media (#135)
1 parent cd36597 commit cb66829

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

packages/canvas-media/video/index.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class Video extends VideoBase {
8989
getCurrentFrame(context?: WebGLRenderingContext) {
9090
const ctx = arguments[1] as any;
9191
const flipY = ctx._flipY;
92-
const ptr = ctx._canvas._canvas.getNativeGL();
92+
const ptr = ctx._canvas._canvas.getNativeContext();
9393

9494
this._instance.getCurrentFrame(!!this.isLoaded, ptr, flipY, arguments[4], arguments[5]);
9595
}

packages/canvas-polyfill/DOM/EventTarget.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ export class EventTarget {
4949
}
5050
}
5151

52-
dispatchEvent(event) {
52+
/**
53+
* Dispatches an event to this EventTarget.
54+
* https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent
55+
* @param event
56+
* @returns false if event is cancelable, and at least one of the event handlers which received event called Event.preventDefault(). Otherwise true.
57+
*/
58+
dispatchEvent(event): boolean {
5359
let emitter: Observable;
5460

5561
if (global.isAndroid) {
@@ -63,5 +69,7 @@ export class EventTarget {
6369
if (emitter !== null && emitter !== undefined) {
6470
emitter.notify({ ...event, eventName: event.type, object: emitter });
6571
}
72+
73+
return !event?.defaultPrevented;
6674
}
6775
}

packages/canvas-polyfill/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require('globals');
1+
require('@nativescript/core/globals');
22

33
if (__ANDROID__ && !(global as any).__canvasLoaded) {
44
try {

packages/canvas/Canvas/common.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ export class Event {
7373
}
7474
}
7575

76+
export class CustomEvent extends Event {
77+
detail: any;
78+
79+
constructor(type: string, options?: EventOptions & { detail?: any }) {
80+
super(type, options);
81+
this.detail = options?.detail ?? null;
82+
}
83+
}
84+
7685
interface UIEventOptions extends EventOptions {
7786
detail?: number;
7887
view?: any;

0 commit comments

Comments
 (0)