GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — nimblephysics/javascript/src/embeddable.ts at master · PARCO-LAB/nimblephysics Expand file tree/ Copy pathembeddable.tsMore file actions 63 lines (54 loc) · 1.7 KB / Copy pathembeddable.tsFile metadata and controls63 lines (54 loc) · 1.7 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 import NimbleStandaloneReact from "./NimbleStandaloneReact"; import React, { useEffect, useState } from 'react'; import ReactDOM from 'react-dom'; const embedNimbleVisualizer = (div: HTMLElement, rawURL: string, defaultPlaybackSpeed: number = 1.0) => { console.log("Embedding Nimble Visualizer for "+rawURL+" into page."); console.log(div); // Clear the pre-existing contents of the div div.innerHTML = ""; const Embedded = () => { const [frame, setFrame] = useState(0); const [playing, setPlaying] = useState(false); const [sizeX, setSizeX] = useState(div.getBoundingClientRect().width); const [sizeY, setSizeY] = useState(div.getBoundingClientRect().height); const onWindowResize = () => { setSizeX(div.getBoundingClientRect().width); setSizeY(div.getBoundingClientRect().height); }; useEffect(() => { window.addEventListener('resize', onWindowResize); return () => { window.removeEventListener('resize', onWindowResize); } }); let children = []; children.push(React.createElement(NimbleStandaloneReact, { loadUrl: rawURL, style: { width: sizeX+"px", height: sizeY+"px" }, key: 'gui', playing: playing, onPlayPause: (play) => { setPlaying(play); }, frame: frame, onFrameChange: (frame) => { setFrame(frame); }, defaultPlaybackSpeed: defaultPlaybackSpeed })); return React.createElement( "div", { }, children ); }; ReactDOM.render(React.createElement(Embedded), div); } if (window != null) { (window as any).embedNimbleVisualizer = embedNimbleVisualizer; } export default embedNimbleVisualizer; |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |