forked from M-Labs/web2019
fix(Solvespace): Uses env (desktop/mobile) to set TreeJS params
This commit is contained in:
parent
6049d15e0b
commit
573a89908d
|
@ -16,6 +16,31 @@
|
|||
<script>
|
||||
(function () {
|
||||
|
||||
function findBootstrapEnvironment() {
|
||||
let envs = ['xs', 'sm', 'md', 'lg', 'xl'];
|
||||
|
||||
let el = document.createElement('div');
|
||||
document.body.appendChild(el);
|
||||
|
||||
let curEnv = envs.shift();
|
||||
|
||||
for (let env of envs.reverse()) {
|
||||
el.classList.add(`d-${env}-none`);
|
||||
|
||||
if (window.getComputedStyle(el).display === 'none') {
|
||||
curEnv = env;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
document.body.removeChild(el);
|
||||
return curEnv;
|
||||
}
|
||||
|
||||
var bootstrap_env = findBootstrapEnvironment();
|
||||
var params_chamber = (bootstrap_env === 'xs' || bootstrap_env == 'sm') ? {width: 400, height: 200, scale: 1} : {width: 800, height: 600, scale: 3};
|
||||
var params_k526s_fixture = (bootstrap_env === 'xs' || bootstrap_env == 'sm') ? {width: 400, height: 200, scale: 6} : {width: 800, height: 400, scale: 12};
|
||||
|
||||
var nodes = [{
|
||||
id: 'kf25',
|
||||
model: solvespace_model_kf25,
|
||||
|
@ -31,7 +56,7 @@
|
|||
}, {
|
||||
id: 'chamber',
|
||||
model: solvespace_model_chamber,
|
||||
params: {width: 800, height: 600, scale: 3},
|
||||
params: params_chamber,
|
||||
}, {
|
||||
id: 'k526s-body',
|
||||
model: solvespace_model_k526s_body,
|
||||
|
@ -43,7 +68,7 @@
|
|||
}, {
|
||||
id: 'k526s-fixture',
|
||||
model: solvespace_model_k526s_fixture,
|
||||
params: {width: 800, height: 400, scale: 12},
|
||||
params: params_k526s_fixture,
|
||||
}, {
|
||||
id: 'k526s-adapter',
|
||||
model: solvespace_model_k526s_adapter,
|
||||
|
|
Loading…
Reference in New Issue