Fix the demo file upload option

This commit is contained in:
David Wendt 2019-08-20 22:15:39 -06:00
parent be21a0dbbb
commit c0e6866745
2 changed files with 11 additions and 15 deletions

View File

@ -28,7 +28,8 @@ class RuffleObjectShadow extends HTMLElement {
this.ruffle = null;
}
connected() {
connectedCallback() {
console.log("Welcome to ruffle");
//Kick off the SWF download.
if (this.params.movie) {
fetch(this.params.movie).then(response => {
@ -94,7 +95,10 @@ class RuffleObjectShadow extends HTMLElement {
}
}
window.customElements.define("ruffle-object", RuffleObjectShadow);
const observer = new MutationObserver(function (mutationsList, observer) {
console.log(mutationsList);
for (let mutation of mutationsList) {
for (let node of mutation.addedNodes) {
RuffleObjectShadow.wrap_tree(node);
@ -102,7 +106,7 @@ const observer = new MutationObserver(function (mutationsList, observer) {
}
});
RuffleObjectShadow.wrap_tree(document);
document.addEventListener("DOMContentLoaded", function() {
RuffleObjectShadow.wrap_tree(document.getElementsByTagName("html")[0]);
}, false);
observer.observe(document, { childList: true, subtree: true});
window.customElements.define("ruffle-object", RuffleObjectShadow);

View File

@ -1,5 +1,5 @@
import { Ruffle } from "../../pkg/ruffle";
import "./element";
import { RuffleObjectShadow } from "./element";
let sampleFileInput = document.getElementById("sample-file");
if (sampleFileInput) {
@ -55,13 +55,5 @@ let timestamp = 0;
let animationHandler;
function playSwf(swfData) {
if (ruffle) {
ruffle.destroy();
ruffle = null;
}
let canvas = document.getElementById("player");
if (swfData && canvas) {
ruffle = Ruffle.new(canvas, new Uint8Array(swfData));
}
document.getElementById("player").play_swf(swfData);
}