-
Notifications
You must be signed in to change notification settings - Fork 11
Conversation
The build check warning about adding a function inside a loop has made me realize that if there is more than one property they will not all be applied since the |
You would also have a problem that https://stackoverflow.com/a/13977142/806777 I would try creating a function that take the something like: if (btn.hover && !disable) {
button.element.addEventListener('mouseenter', this.onMouseEnter(btn), {passive: true});
...
onMouseEnter(btn) {
return function () {
for (const propName in btn.hover) {
const style = btn.hover[propName];
this.style[changeCase.camelCase(propName)] = style;
}
};
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to use tabs and align the for loop in onMouseEnter
lib/flex-tool-bar.js
Outdated
btn['preHoverVal'] = new Object(); | ||
|
||
for (const propName in btn.hover) { | ||
btn.preHoverVal[propName] = this.style[changeCase.camelCase(propName)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you save the changeCase.camelCase(propName)
to a variable instead of calculating it every time it is needed?
Also if you change the propName
in btn.preHoverVal[propName]
to the camel case variable you won't need to calculate the camel case prop name in onMouseLeave
Sorry about the formatting issue, I should have caught that... Also, I should have caught the camel case conversion. I even thought about this briefly, but instead of reading up on what it was actually doing, I (incorrectly) assumed it was something that was "needed" and dismissed it without further thought. The name even implies it is a string manipulation function that would be more efficient to run once 😞. |
No problem. I will merge this and create a new release tonight. Thanks a lot for this, it is incredibly useful. 💯 |
Happy to help! Thanks for providing guidance and feedback, it was good information to learn. |
released in v2.1.0 Thanks again |
This change stems from the flex-toolbar issue discussion.