diff --git a/src/apps/viewer/app.ts b/src/apps/viewer/app.ts index 4e675858d87b3821d95f70cf4c7c4cb19f2f398e..b399d04bc9f6570004484e9652c05244a8d1f20c 100644 --- a/src/apps/viewer/app.ts +++ b/src/apps/viewer/app.ts @@ -101,7 +101,14 @@ export class Viewer { } static async create(elementOrId: string | HTMLElement, options: Partial<ViewerOptions> = {}) { - const o = { ...DefaultViewerOptions, ...options }; + const definedOptions = {} as any; + // filter for defined properies only so the default values + // are property applied + for (const p of Object.keys(options) as (keyof ViewerOptions)[]) { + if (options[p] !== void 0) definedOptions[p] = options[p]; + } + + const o: ViewerOptions = { ...DefaultViewerOptions, ...definedOptions }; const defaultSpec = DefaultPluginUISpec(); const spec: PluginUISpec = { diff --git a/src/apps/viewer/index.html b/src/apps/viewer/index.html index d5e4b11e43a9d8bb3dea64c6a94906b00a78366e..9299dcca61a4224c28c3bd180b163b1ba3128acc 100644 --- a/src/apps/viewer/index.html +++ b/src/apps/viewer/index.html @@ -57,7 +57,7 @@ var pickScale = getParam('pick-scale', '[^&]+').trim(); var pickPadding = getParam('pick-padding', '[^&]+').trim(); var disableWboit = getParam('disable-wboit', '[^&]+').trim() === '1'; - var preferWebgl1 = getParam('prefer-webgl1', '[^&]+').trim() === '1'; + var preferWebgl1 = getParam('prefer-webgl1', '[^&]+').trim() === '1' || void 0; molstar.Viewer.create('app', { layoutShowControls: !hideControls, @@ -71,7 +71,7 @@ pixelScale: parseFloat(pixelScale) || 1, pickScale: parseFloat(pickScale) || 0.25, pickPadding: isNaN(parseFloat(pickPadding)) ? 1 : parseFloat(pickPadding), - enableWboit: !disableWboit, + enableWboit: disableWboit ? true : void 0, // use default value if disable-wboit is not set preferWebgl1: preferWebgl1, }).then(viewer => { var snapshotId = getParam('snapshot-id', '[^&]+').trim();