1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

change resize handler

This commit is contained in:
Kevin Levron 2021-02-21 13:47:04 +01:00
parent ee30c75d88
commit 787b361b09
2 changed files with 4 additions and 3 deletions

View File

@ -9,7 +9,7 @@ export default {
mouseMove: { type: [Boolean, String], default: false },
mouseRaycast: { type: Boolean, default: false },
orbitCtrl: { type: [Boolean, Object], default: false },
resize: { type: [Boolean, String, Element], default: 'window' },
resize: { type: [Boolean, String], default: true },
shadow: Boolean,
width: String,
height: String,

View File

@ -21,7 +21,7 @@ export default function useThree() {
orbit_ctrl: false,
mouse_move: false,
mouse_raycast: false,
resize: 'window',
resize: true,
width: 0,
height: 0,
};
@ -222,7 +222,8 @@ export default function useThree() {
if (conf.resize === 'window') {
setSize(window.innerWidth, window.innerHeight);
} else {
setSize(conf.resize.clientWidth, conf.resize.clientHeight);
const elt = obj.renderer.domElement.parentNode;
setSize(elt.clientWidth, elt.clientHeight);
}
afterResizeCallbacks.forEach(c => c());
}