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

resizing to width #3056

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 9 additions & 7 deletions WGLMakie/src/wglmakie.bundled.js
Original file line number Diff line number Diff line change
Expand Up @@ -20319,6 +20319,9 @@ function threejs_module(canvas, comm, width, height, resize_to_body) {
renderer.setClearColor("#ffffff");
renderer.setPixelRatio(pixelRatio1);
renderer.setSize(width / pixelRatio1, height / pixelRatio1);
console.log(canvas);
console.log(width);
console.log(height);
const mouse_callback = (x, y)=>comm.notify({
mouseposition: [
x,
Expand Down Expand Up @@ -20382,15 +20385,14 @@ function threejs_module(canvas, comm, width, height, resize_to_body) {
canvas.addEventListener("contextmenu", (e)=>e.preventDefault());
canvas.addEventListener("focusout", contextmenu);
function resize_callback() {
const bodyStyle = window.getComputedStyle(document.body);
const width_padding = parseInt(bodyStyle.paddingLeft, 10) + parseInt(bodyStyle.paddingRight, 10) + parseInt(bodyStyle.marginLeft, 10) + parseInt(bodyStyle.marginRight, 10);
const height_padding = parseInt(bodyStyle.paddingTop, 10) + parseInt(bodyStyle.paddingBottom, 10) + parseInt(bodyStyle.marginTop, 10) + parseInt(bodyStyle.marginBottom, 10);
const width = (window.innerWidth - width_padding) * pixelRatio1;
const height = (window.innerHeight - height_padding) * pixelRatio1;
const div = canvas.parentNode;
console.log(div);
console.log(div.offsetHeight * pixelRatio1);
console.log(div.offsetWidth * pixelRatio1);
comm.notify({
resize: [
width,
height
div.offsetWidth * pixelRatio1,
div.offsetHeight * pixelRatio1
]
});
}
Expand Down
24 changes: 7 additions & 17 deletions WGLMakie/src/wglmakie.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ function threejs_module(canvas, comm, width, height, resize_to_body) {
// `renderer.setSize` also updates `canvas` size
renderer.setPixelRatio(pixelRatio);
renderer.setSize(width / pixelRatio, height / pixelRatio);

const mouse_callback = (x, y) => comm.notify({ mouseposition: [x, y] });
const notify_mouse_throttled = throttle_function(mouse_callback, 40);

Expand Down Expand Up @@ -217,23 +216,14 @@ function threejs_module(canvas, comm, width, height, resize_to_body) {
canvas.addEventListener("focusout", contextmenu);

function resize_callback() {
const bodyStyle = window.getComputedStyle(document.body);
// Subtract padding that is added by VSCode
const width_padding =
parseInt(bodyStyle.paddingLeft, 10) +
parseInt(bodyStyle.paddingRight, 10) +
parseInt(bodyStyle.marginLeft, 10) +
parseInt(bodyStyle.marginRight, 10);
const height_padding =
parseInt(bodyStyle.paddingTop, 10) +
parseInt(bodyStyle.paddingBottom, 10) +
parseInt(bodyStyle.marginTop, 10) +
parseInt(bodyStyle.marginBottom, 10);
const width = (window.innerWidth - width_padding) * pixelRatio;
const height = (window.innerHeight - height_padding) * pixelRatio;

const div = canvas.parentNode;
// Send the resize event to Julia
comm.notify({ resize: [width, height] });
comm.notify({
resize: [
div.offsetWidth * pixelRatio,
div.offsetHeight * pixelRatio,
],
});
}
if (resize_to_body) {
const resize_callback_throttled = throttle_function(resize_callback, 100);
Expand Down