Optional
CSSSelectorSets the CSS selector used when selecting elements to change backgrounds on; multiple element selections are supported. e.g. "main"
"body"
Optional
backgroundsSets an array of CSS backgrounds to be used. e.g. ["red","green","blue"]
An array of demo CSS backgrounds
Optional
randomSets whether to pick the next background value at random (true
) or sequentially (false
).
true
Optional
timeoutSets the time between background changes (in milliseconds). e.g. 5000
Never set the transition duration longer than the timeout.
// DO NOT SET transition > timeout
// Bad
const options = {
transition: "5000ms", // transition duration set to 5 seconds
timeout: 3000, // time between backgrounds set to 3 seconds
...
}
// Bad
bgChanger.transition = "5000ms"; // transition duration set to 5 seconds
bgChanger.timeout = 3000; // time between backgrounds set to 3 seconds
If it is longer, the transition to a new background will not complete before the next background is set, causing background changes to glitch past animations.
7500
Optional
transitionSets the CSS transition (without a transition-property) used when changing between backgrounds. e.g. "500ms ease-in"
or "0.5s ease-in-out 0.25s"
Never set the transition duration longer than the timeout.
// DO NOT SET transition > timeout
// Bad
const options = {
transition: "5000ms", // transition duration set to 5 seconds
timeout: 3000, // time between backgrounds set to 3 seconds
...
}
// Bad
bgChanger.transition = "5000ms"; // transition duration set to 5 seconds
bgChanger.timeout = 3000; // time between backgrounds set to 3 seconds
If it is longer, the transition to a new background will not complete before the next background is set, causing background changes to glitch past animations.
"5000ms"
Generated using TypeDoc
An interface for options used when initializing a background changer. It is passed to the create function or a bRando class constructor.