Skip to content

Commit 1e9fcaf

Browse files
committed
Add "embedded" canvas option
1 parent 1108544 commit 1e9fcaf

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

squeak.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ function setupFullscreen(display, canvas, options) {
130130
display.fullscreen = fullscreen;
131131
var fullwindow = fullscreen || options.fullscreen;
132132
box.style.background = fullwindow ? 'black' : '';
133+
box.style.border = fullwindow ? 'none' : '';
134+
box.style.borderRadius = fullwindow ? '0px' : '';
133135
setTimeout(onresize, 0);
134136
}
135137

@@ -185,10 +187,12 @@ function updateMousePos(evt, canvas, display) {
185187
display.cursorCanvas.style.top = (evtY + canvas.offsetTop + display.cursorOffsetY) + "px";
186188
}
187189
var x = (evtX * canvas.width / canvas.offsetWidth) | 0,
188-
y = (evtY * canvas.height / canvas.offsetHeight) | 0;
190+
y = (evtY * canvas.height / canvas.offsetHeight) | 0,
191+
w = display.width || canvas.width,
192+
h = display.height || canvas.height;
189193
// clamp to display size
190-
display.mouseX = Math.max(0, Math.min(display.width, x));
191-
display.mouseY = Math.max(0, Math.min(display.height, y));
194+
display.mouseX = Math.max(0, Math.min(w, x));
195+
display.mouseY = Math.max(0, Math.min(h, y));
192196
}
193197

194198
function recordMouseEvent(what, evt, canvas, display, options) {
@@ -345,6 +349,8 @@ function createSqueakDisplay(canvas, options) {
345349
if (options.fullscreen) {
346350
document.body.style.margin = 0;
347351
document.body.style.backgroundColor = 'black';
352+
canvas.style.border = 'none';
353+
canvas.style.borderRadius = '0px';
348354
document.ontouchmove = function(evt) { evt.preventDefault(); };
349355
}
350356
var display = {
@@ -1073,8 +1079,10 @@ function createSqueakDisplay(canvas, options) {
10731079
);
10741080
};
10751081

1076-
onresize();
1077-
window.onresize = onresize;
1082+
if (!options.embedded) {
1083+
onresize();
1084+
window.onresize = onresize;
1085+
}
10781086

10791087
return display;
10801088
}

0 commit comments

Comments
 (0)