Skip to content

Commit

Permalink
Add toggle for gradient animation
Browse files Browse the repository at this point in the history
  • Loading branch information
lizgw committed Aug 24, 2020
1 parent 804f1b1 commit 2908ce7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
1 change: 0 additions & 1 deletion assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ hr {

background: #ffffff;
background-size: 600% 600%;
animation: Animation 25s ease-in-out infinite;

display: flex;
text-align: center;
Expand Down
6 changes: 5 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,15 @@ function pickColors(num)

// get gradient speed and set the gradient
chrome.storage.sync.get({
gradientSpeed: 25
gradientSpeed: 25,
animateGradient: true
}, function(items) {
container.style.background = "linear-gradient(45deg, " + colorString + ")";
container.style.backgroundSize = "200% 200%";
container.style.animation = "Animation " + items.gradientSpeed + "s ease-in-out infinite";

if (!items.animateGradient)
container.style.webkitAnimationPlayState = "paused";
});

// set the options menu info
Expand Down
13 changes: 11 additions & 2 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ function updatePrefs(event) {
{
formatDateString();
updateDate();
} else if (id == "animateGradient") {
if (event.target.checked) {
container.style.webkitAnimationPlayState = "running";
} else {
container.style.webkitAnimationPlayState = "paused";
}
}
}

// called when one of the gradien selection radios is pressed
// called when one of the gradient selection radios is pressed
function changeSelectionMode(event)
{
// change it to either "random" or "select"
Expand Down Expand Up @@ -61,7 +67,8 @@ function restoreOptions()
gradientSpeed: 25,
showDayOfWeek: true,
showDayOfMonth: true,
showYear: true
showYear: true,
animateGradient: true
}, function(items) {
// set up switches according to stored options
document.getElementById('showTime').checked = items.showTime;
Expand All @@ -70,6 +77,7 @@ function restoreOptions()
document.getElementById("showDayOfWeek").checked = items.showDayOfWeek;
document.getElementById("showDayOfMonth").checked = items.showDayOfMonth;
document.getElementById("showYear").checked = items.showYear;
document.getElementById("animateGradient").checked = items.animateGradient;

// set the slider position to the current value
document.getElementById("opt-speed").value = items.gradientSpeed;
Expand Down Expand Up @@ -115,6 +123,7 @@ function resetOptions()
options.showDayOfWeek = true,
options.showDayOfMonth = true,
options.showYear = true
options.animateGradient = true;

// set the storage
chrome.storage.sync.set(options);
Expand Down
5 changes: 5 additions & 0 deletions wavetab.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ <h3>Current Gradient Info</h3>
<p>Name: <span id="cgName"></span></p>
<p>Package: <span id="cgPackage"></span></p>
<p>ID: <span id="cgID"></span></p>
<br>
<li><label class="switch">
<input type="checkbox" checked id="animateGradient">
<div class="slider"></div>
</label>Animate Gradient</li>
<h3>Gradient Selection</h3>
<div class="radio-container">
<input type="radio" name="grad-select" value="random" id="opt-grad-random" class="grad-selection-radio">
Expand Down

0 comments on commit 2908ce7

Please sign in to comment.