Skip to content

Commit

Permalink
change the hover method
Browse files Browse the repository at this point in the history
  • Loading branch information
dealfonso committed Jun 16, 2023
1 parent 87044a3 commit 187a343
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
27 changes: 12 additions & 15 deletions js/simplelottieplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,6 @@ class SimpleLottiePlayer {
}

if (this.options.fullsizeButton) {
let stylesheet = document.styleSheets[0];
let found = false;
for (let selector in [...stylesheet.cssRules]) {
if (selector.selectorText === `.${this._id}`) {
found = true;
break;
}
}

if (!found) {
// Add the rules (the placeholder and the hover); we want a hover effect in this case, so we need to use this mechanism (which I don't like very much)
document.styleSheets[0].insertRule(`.${this._id} {}`);
document.styleSheets[0].insertRule(`.${this._id}-btn:hover { opacity: 1 !important; }`)
}

let fullScreenBtn = document.createElement("div");
fullScreenBtn.classList.add(`${this._id}-btn`);
if (this.options.cssClassFullsizeButton !== null) {
Expand Down Expand Up @@ -249,6 +234,18 @@ class SimpleLottiePlayer {
fullScreenBtn.style.display = "flex";
event.stopImmediatePropagation();
});
fullScreenBtn.addEventListener('mouseover', function(event) {
fullScreenBtn.style.opacity = "1";
});
fullScreenBtn.addEventListener('mouseout', function(event) {
fullScreenBtn.style.opacity = "0.5";
});
exitFullScreenBtn.addEventListener('mouseover', function(event) {
exitFullScreenBtn.style.opacity = "1";
});
exitFullScreenBtn.addEventListener('mouseout', function(event) {
exitFullScreenBtn.style.opacity = "0.5";
});
}

if (this.options.controlButtons) {
Expand Down
24 changes: 12 additions & 12 deletions simplelottieplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,6 @@ class SimpleLottiePlayer {
this._buttonEventHandler = null;
}
if (this.options.fullsizeButton) {
let stylesheet = document.styleSheets[0];
let found = false;
for (let selector in [ ...stylesheet.cssRules ]) {
if (selector.selectorText === `.${this._id}`) {
found = true;
break;
}
}
if (!found) {
document.styleSheets[0].insertRule(`.${this._id} {}`);
document.styleSheets[0].insertRule(`.${this._id}-btn:hover { opacity: 1 !important; }`);
}
let fullScreenBtn = document.createElement("div");
fullScreenBtn.classList.add(`${this._id}-btn`);
if (this.options.cssClassFullsizeButton !== null) {
Expand Down Expand Up @@ -363,6 +351,18 @@ class SimpleLottiePlayer {
fullScreenBtn.style.display = "flex";
event.stopImmediatePropagation();
});
fullScreenBtn.addEventListener("mouseover", function(event) {
fullScreenBtn.style.opacity = "1";
});
fullScreenBtn.addEventListener("mouseout", function(event) {
fullScreenBtn.style.opacity = "0.5";
});
exitFullScreenBtn.addEventListener("mouseover", function(event) {
exitFullScreenBtn.style.opacity = "1";
});
exitFullScreenBtn.addEventListener("mouseout", function(event) {
exitFullScreenBtn.style.opacity = "0.5";
});
}
if (this.options.controlButtons) {
let playBtn = document.createElement("div");
Expand Down
Loading

0 comments on commit 187a343

Please sign in to comment.