Skip to content

Commit

Permalink
style: fix eslint error
Browse files Browse the repository at this point in the history
  • Loading branch information
swsoyee committed Feb 6, 2021
1 parent 5447f4c commit 438b1de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ module.exports = {
sourceType: 'module',
},
rules: {
'max-len': ['error', { code: 150 }],
'no-eval': 'off',
'no-param-reassign': 'off',
},
};
21 changes: 12 additions & 9 deletions inst/htmlwidgets/r3dmol.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global $ HTMLWidgets $3Dmol Shiny */
const isAutoRenderFunction = [
// Other
'createModelFrom',
Expand Down Expand Up @@ -28,7 +29,7 @@ HTMLWidgets.widget({

type: 'output',

factory: (el, width, height) => {
factory: (el) => {
let initialized = false;
const elementId = el.id;
const container = document.getElementById(elementId);
Expand Down Expand Up @@ -75,24 +76,26 @@ HTMLWidgets.widget({
// Save last call function name for auto render function call
const lastCallFunction = x.api[numApiCalls - 1].method;

for (let i = 0; i < numApiCalls; i++) {
for (let i = 0; i < numApiCalls; i += 1) {
const call = x.api[i];
const { method } = call;
delete call.method;
try {
evalFun(call);
that[method](call);
} catch (err) { }
} catch (err) {
// continue regardless of error
}
}
// Auto render
if (isAutoRenderFunction.findIndex((el) => el === lastCallFunction) > -1) {
if (isAutoRenderFunction.findIndex((element) => element === lastCallFunction) > -1) {
viewer.render();
}
},

resize: (width, height) => {
container.setAttribute('width', width);
container.setAttribute('height', height);
resize: (newWidth, newHeight) => {
container.setAttribute('width', newWidth);
container.setAttribute('height', newHeight);
},
render: () => viewer.render(),
rotate: (params) => viewer.rotate(params.angle, params.axis, params.animationDuration, params.fixedPath),
Expand Down Expand Up @@ -190,15 +193,15 @@ if (HTMLWidgets.shinyMode) {
if (el && el.widget) {
delete message.id;
el.widget[fxn](message);
if (isAutoRenderFunction.findIndex((el) => el === fxn) > -1) {
if (isAutoRenderFunction.findIndex((ele) => ele === fxn) > -1) {
el.widget.render();
}
}
},
);
};

for (let i = 0; i < functionList.length; i++) {
for (let i = 0; i < functionList.length; i += 1) {
addShinyHandler(functionList[i])();
}
}

0 comments on commit 438b1de

Please sign in to comment.