diff --git a/src/mol-canvas3d/camera.ts b/src/mol-canvas3d/camera.ts index 92d489e0bc2ea0a0946f8fda1fddd0444c7b3e41..21c300e59cc3dc0b1bf56135e723942cfed2d33a 100644 --- a/src/mol-canvas3d/camera.ts +++ b/src/mol-canvas3d/camera.ts @@ -250,7 +250,7 @@ function updateOrtho(camera: Camera) { let top = cy + dy let bottom = cy - dy - if (viewOffset && viewOffset.enabled) { + if (viewOffset.enabled) { const zoomW = zoom / (viewOffset.width / viewOffset.fullWidth) const zoomH = zoom / (viewOffset.height / viewOffset.fullHeight) const scaleW = (fullRight - fullLeft) / viewOffset.width @@ -279,7 +279,7 @@ function updatePers(camera: Camera) { let width = aspect * height let left = -0.5 * width - if (viewOffset && viewOffset.enabled) { + if (viewOffset.enabled) { left += viewOffset.offsetX * width / viewOffset.fullWidth top -= viewOffset.offsetY * height / viewOffset.fullHeight width *= viewOffset.width / viewOffset.fullWidth diff --git a/src/mol-plugin/component.ts b/src/mol-plugin/component.ts index e60e69c1976f3dc1a460b66f9872088467bddb55..92a4ddc60578957d3268e1c80570fcadfd40f764 100644 --- a/src/mol-plugin/component.ts +++ b/src/mol-plugin/component.ts @@ -8,7 +8,7 @@ import { shallowMergeArray } from '../mol-util/object'; import { RxEventHelper } from '../mol-util/rx-event-helper'; export class PluginComponent<State> { - private _ev: RxEventHelper; + private _ev: RxEventHelper | undefined; protected get ev() { return this._ev || (this._ev = RxEventHelper.create()); diff --git a/src/mol-plugin/layout.ts b/src/mol-plugin/layout.ts index bdff4dcdcded588b332e4aab5931a56c01148a30..e430acaca9f176e82afbb651928eeecc35e33b7d 100644 --- a/src/mol-plugin/layout.ts +++ b/src/mol-plugin/layout.ts @@ -54,7 +54,7 @@ export class PluginLayout extends PluginComponent<PluginLayoutStateProps> { this.events.updated.next(); } - private root: HTMLElement; + private root: HTMLElement | undefined; private rootState: RootState | undefined = void 0; private expandedViewport: HTMLMetaElement; @@ -78,7 +78,7 @@ export class PluginLayout extends PluginComponent<PluginLayoutStateProps> { let body = document.getElementsByTagName('body')[0]; let head = document.getElementsByTagName('head')[0]; - if (!body || !head) return; + if (!body || !head || !this.root) return; if (this.state.isExpanded) { let children = head.children; diff --git a/src/mol-plugin/state.ts b/src/mol-plugin/state.ts index e28aa4cc2147ef53944354056f148ebef01dfdea..0afb842b15da7d8169c09ba3ccd2269f3c3ac09c 100644 --- a/src/mol-plugin/state.ts +++ b/src/mol-plugin/state.ts @@ -53,12 +53,10 @@ class PluginState { camera: p.camera ? { current: this.plugin.canvas3d.camera.getSnapshot(), transitionStyle: p.cameraTranstion.name, - transitionDurationInMs: (params && params.cameraTranstion && params.cameraTranstion.name === 'animate' && params.cameraTranstion.params.durationInMs) || void 0 + transitionDurationInMs: (params && params.cameraTranstion && params.cameraTranstion.name === 'animate') ? params.cameraTranstion.params.durationInMs : undefined } : void 0, cameraSnapshots: p.cameraSnapshots ? this.cameraSnapshots.getStateSnapshot() : void 0, - canvas3d: p.canvas3d ? { - props: this.plugin.canvas3d.props - } : void 0, + canvas3d: p.canvas3d ? { props: this.plugin.canvas3d.props } : void 0, durationInMs: params && params.durationInMs }; } @@ -69,7 +67,7 @@ class PluginState { if (snapshot.behaviour) await this.plugin.runTask(this.behaviorState.setSnapshot(snapshot.behaviour)); if (snapshot.data) await this.plugin.runTask(this.dataState.setSnapshot(snapshot.data)); if (snapshot.canvas3d) { - if (snapshot.canvas3d.props) await PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { settings: snapshot.canvas3d.props || { } }); + if (snapshot.canvas3d.props) await PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { settings: snapshot.canvas3d.props }); } if (snapshot.cameraSnapshots) this.cameraSnapshots.setStateSnapshot(snapshot.cameraSnapshots); if (snapshot.animation) { diff --git a/src/mol-plugin/util/interactivity.ts b/src/mol-plugin/util/interactivity.ts index 96dbd307be97ec6e4314e6145d1af3f1e8d358a1..f44f6e6b4fbab0f3d316999f0c8bd35b9bc27877 100644 --- a/src/mol-plugin/util/interactivity.ts +++ b/src/mol-plugin/util/interactivity.ts @@ -176,7 +176,7 @@ namespace Interactivity { } else if (modifiers.shift && buttons === ButtonsType.Flag.Primary) { // try to extend sequence on Shift + Left-Click let loci: StructureElement.Loci = normalized.loci; - if (modifiers && modifiers.shift) { + if (modifiers.shift) { loci = this.sel.tryGetRange(loci) || loci; } this.toggleSel({ loci, repr: normalized.repr }); diff --git a/src/mol-task/task.ts b/src/mol-task/task.ts index ec67e573f19cf3ed1fd9f5a43e09c51c54b097ce..f27c85df7dac2f2e666d8604431c37db6dd99660 100644 --- a/src/mol-task/task.ts +++ b/src/mol-task/task.ts @@ -34,8 +34,8 @@ namespace Task { class Impl<T> implements Task<T> { readonly id: number; - run(observer?: Progress.Observer, updateRateMs?: number): Promise<T> { - if (observer) return ExecuteObservable(this, observer, updateRateMs as number || 250); + run(observer?: Progress.Observer, updateRateMs = 250): Promise<T> { + if (observer) return ExecuteObservable(this, observer, updateRateMs); return this.f(SyncRuntimeContext); } diff --git a/src/mol-util/monadic-parser.ts b/src/mol-util/monadic-parser.ts index 9438c0782b6713496db8058ef83e0c45f42f85e6..18cf7714e075b1283a97d47a365b321895711b7d 100644 --- a/src/mol-util/monadic-parser.ts +++ b/src/mol-util/monadic-parser.ts @@ -323,10 +323,9 @@ export namespace MonadicParser { return RegExp('^(?:' + re.source + ')', flags(re)); } - export function regexp(re: RegExp, groupNumber?: number) { + export function regexp(re: RegExp, group = 0) { const anchored = anchoredRegexp(re); const expected = '' + re; - const group = groupNumber || 0; return new MonadicParser(function (input, i) { const match = anchored.exec(input.slice(i)); if (match) { diff --git a/src/mol-util/param-definition.ts b/src/mol-util/param-definition.ts index d94f32864c051da74ed8261c21b74f34cbe65ceb..5a8663d22a944da825ecc8f0a03374fd61c2511a 100644 --- a/src/mol-util/param-definition.ts +++ b/src/mol-util/param-definition.ts @@ -293,8 +293,6 @@ export namespace ParamDefinition { return areEqual(p.params, a, b); } else if (p.type === 'mapped') { const u = a as NamedParams, v = b as NamedParams; - if (!u) return !v; - if (!u || !v) return false; if (u.name !== v.name) return false; const map = p.map(u.name); return isParamEqual(map, u.params, v.params);