angular-ticker
A (stupid) AngularJS component for tickers.
Table of contents
Demo
Here.
Note: A copy of the demo code is inside the demo
folder of this
repository.
Usage
Basic
Note that:
text
is the text to displaylength
is the number of cells for the tickerperiod
is the time interval after which a character moves to the next cell (measured in milliseconds)
Also, keep in mind that styling is up to you. See the Styling section.
Dynamic
...provided that your_text
, your_length
, your_period
are suitable values
available inside the enclosing scope.
Defaults
Parameters are all optional, i.e. you can even write something like this:
When parameters are omitted default values from the MslTickerDefaults
service
are used. This service is actually a plain JS object with a TEXT
, LENGTH
and
PERIOD
properties representing the default values:
angular ;
If you don't like these defaults, you can change them inside a config
block:
angular ;
Styling
The HTML template for the ticker is just a sequence of div
s (with
display: inline-block;
), e.g.:
F O O B A R
Use the msl-ticker > div
selector for further customization. A nice example
is inside the demo folder.
Keep in mind that the purpose of the ticker is to move characters from cell to cell: how a cell can be styled is not (completely) part of the API.
How to put it in your app
The ticker component is available inside an npm package
called angular-ticker
:
npm install angular-ticker
Once installed, remember to load the code:
...and to declare msl.ticker
as a dependency:
var your_app = angular;
API
Here is a more detailed, official description of what the ticker does and what you should (and should not) do when using the ticker.
Any behavior not explicitly documented there is to be intended as implementation-specific and should not be relied on.
Disclaimer
While nicely written and documented, this code was developed just for fun and is not tested (not in an automated fashion, at least). That being said, it seems to me that is working well :D
Also note that this code is MIT-licensed.
Surprise!
You have read all this document?! Thank you. Here is a little gift: the demo website of this repo supports text, length and period customization through query parameters. You can use this feature to send funny messages to your friends, e.g.:
https://marcoliceti.github.io/angular-ticker/demo/#!?text=eat my shorts