Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the new reason-loader with relative require() fixes #45

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/pages/mdn-game-tutorial/Animation.re
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
open Bindings;
open Canvas;
open Ball;

/* Bindings to external JavaScript APIs */
let ballRadius = 10;
/* The main render function */
let rec render = (canvasRef: reactRef, x, dx, y, dy) => {
Js.log(Document.getElementById(Document.document, "d"));
let canvas = getCurrent(canvasRef);
let ctx = getContext(canvas, "2d");
let square = x => x * x;
Expand Down
1 change: 1 addition & 0 deletions src/pages/mdn-game-tutorial/Ball.re
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let ballRadius = 130;
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
open Document;

type canvas;
type context2d;
type document;
type reactRef;

external document: document = "document";
[@mel.send]
external getElementById: (document, string) => canvas = "getElementById";
[@mel.send] external getContext: (canvas, string) => context2d = "getContext";
[@mel.get] external getWidth: canvas => int = "width";
[@mel.get] external getHeight: canvas => int = "height";
[@mel.get] external getCurrent: reactRef => canvas = "current";
[@mel.send] external getContext: (htmlElement, string) => context2d = "getContext";
[@mel.get] external getWidth: htmlElement => int = "width";
[@mel.get] external getHeight: htmlElement => int = "height";
[@mel.get] external getCurrent: reactRef => htmlElement = "current";
[@mel.send]
external clearRect: (context2d, float, float, float, float) => unit =
"clearRect";
Expand Down
5 changes: 5 additions & 0 deletions src/pages/mdn-game-tutorial/Document.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type document;
type htmlElement;
external document: document = "document";
[@mel.send]
external getElementById: (document, string) => htmlElement = "getElementById";