Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dcd6d4a

Browse filesBrowse files
committed
Fix hover bug
1 parent 9010f78 commit dcd6d4a
Copy full SHA for dcd6d4a

File tree

Expand file treeCollapse file tree

2 files changed

+9
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-6
lines changed

‎src/components/modebar/modebar.js

Copy file name to clipboardExpand all lines: src/components/modebar/modebar.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ proto.update = function(graphInfo, buttons) {
6060
document.querySelectorAll(groupSelector).forEach(function(group) {
6161
group.style.backgroundColor = style.bgcolor;
6262
});
63-
// set styles on hover using event listeners instead of inline CSS that's not allowed by strict CSP's
64-
Lib.setStyleOnHover('#' + modeBarId + ' .modebar-btn', '.active', '.icon path', 'fill: ' + style.activecolor, 'fill: ' + style.color);
65-
6663
// if buttons or logo have changed, redraw modebar interior
6764
var needsNewButtons = !this.hasButtons(buttons);
6865
var needsNewLogo = (this.hasLogo !== context.displaylogo);
@@ -92,6 +89,10 @@ proto.update = function(graphInfo, buttons) {
9289
}
9390

9491
this.updateActiveButton();
92+
93+
// set styles on hover using event listeners instead of inline CSS that's not allowed by strict CSP's
94+
Lib.setStyleOnHover('#' + modeBarId + ' .modebar-btn', '.active', '.icon path', 'fill: ' + style.activecolor, 'fill: ' + style.color, this.element);
95+
9596
};
9697

9798
proto.updateButtons = function(buttons) {

‎src/lib/dom.js

Copy file name to clipboardExpand all lines: src/lib/dom.js
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,14 @@ function deleteRelatedStyleRule(uid) {
101101
* @param {string} activeStyle style that has to be applied when 'hovered' or 'active'
102102
* @param {string} inactiveStyle style that has to be applied when not 'hovered' nor 'active'
103103
*/
104-
function setStyleOnHover(selector, activeSelector, childSelector, activeStyle, inactiveStyle) {
104+
function setStyleOnHover(selector, activeSelector, childSelector, activeStyle, inactiveStyle, element) {
105105
var activeStyleParts = activeStyle.split(':');
106106
var inactiveStyleParts = inactiveStyle.split(':');
107107
var eventAddedAttrName = 'data-btn-style-event-added';
108-
109-
document.querySelectorAll(selector).forEach(function(el) {
108+
if (!element) {
109+
element = document;
110+
}
111+
element.querySelectorAll(selector).forEach(function(el) {
110112
if(!el.getAttribute(eventAddedAttrName)) {
111113
// Emulate ":hover" CSS style using JS event handlers to set the
112114
// style in a strict CSP-compliant manner.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.