Skip to content

a jQuery plugin to automatically activate elements, one after the other. Make running lights, blinking Christmas decorations, traffic lights - the possibilities are endless

Notifications You must be signed in to change notification settings

RayHyde/sequential_activation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sequential activation: activate elements one after the other

Sometimes you need to automatically set elements active, one after the other, e.g. for creating running lights.

See it in action: http://rayhyde.github.io/sequential_activation/

The Goodies

You can activate the plugin on as many elements on the page as you need, bar the processing limits of your viewer's computer, of course.

You can set the speed and how many times you want it to loop till indefinite.

If you only want the activation sequence to run once, you can opt to keep everything active.

How to use this plugin

1. Link the files you need

Include the jQuery script at the bottom of your page, e.g. through a CDN:

<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>

Then include the minimized version of the script:

<script src="[path to your script]/jquery.sequential_activation.min.js"></script>

Change [path to your script] to where it resides, eg "js".

2. Create your HTML markup

This is very simple: create an element and style the element containing it. Like

<ul id="lights">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
<style>
  #lights {
    margin: 0;
    padding: 0;
    list-style: none;
    background: black;
  }
  #lights li {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    ...
  }
</style>
			

3. Call the plugin

Then initialize the plugin, telling it in which element it needs to run:

<script>
  $(<containing element here, e.g. "#lights">).sequentialActivation({
    animationSpeed: 1000, 
    elementToActivate: 'li', 
    loop: 0, 
    keepActive: false 
  });

// a second container: $(<containing element here, e.g. "nav">).sequentialActivation({ animationSpeed: 1000, elementToActivate: 'div', loop: 3, keepActive: false }); </script>

4. Putting it all together

This is your basic page to get the plugin up and running:

<!DOCTYPE html>
<html>
<head>
...
<link rel="stylesheet" href="css/mysequential_activation.css">
</head>
<body>
...
<ul id="lights">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
...
<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="js/jquery.sequential_activation.min.js"></script>
<script>
$('#lights').sequentialActivation();
</script>
</body>
</html>

Options

If you don't specify options, like in the example above, the plugin will use its default settings:
- animation speed: 300
- the element that needs to be activated: 'li'
- loop: 0, thus indefinite
- keep active: false. In the example of running

These are the options:

Speed

in the usual thousands of seconds

animationSpeed: 300

Elements that need to be activated

This lists the elements in the container that will be activated one by one:

elementToActivate: 'li'

Loop

You can specify the number of times it needs to loop. '0' means indefinite

loop: 0

Keep active

The elements will remain activated if set to 'true'. This means that looping needs to be set to '1', as otherwise the script continues unnecessarily.

keepActive: false

Download from Github

My Playground

This project is part of my Playground - a collection of fun (and dare I say it: clever) stuff I made in the past, from jQuery games and plugins to CSS animation tricks.

Please drop in on my portfolio site www.rayhyde.nl!

About

a jQuery plugin to automatically activate elements, one after the other. Make running lights, blinking Christmas decorations, traffic lights - the possibilities are endless

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published