Tick Documentation
Tick
The Tick element servers as the base element of the Counter. It is the element you assign a value to and you define your callback methods on. The look 'n feel of the timer is all handled by elements added inside of the tick element. The base tick element looks like this:
<div class="tick"></div>
The size of the Tick counter can be defined with CSS font-size
. By default Tick follows the base font size (and font family) of the website. Depending on the view type you'll probably have to increase the font size of the Tick counter a fair bit to make it look great. You can do so using the CSS snippet below.
.tick {
font-size: 2em;
}
We'll now go over other configuration options for the base element, the views, the layout elements, animation options and data transforms.
The following attributes can be set on the tick element:
data-value
data-did-init
data-did-update
data-will-destroy
data-did-destroy
data-credits
Attribute | Description |
---|---|
data-value |
The If no value supplied, Tick will not render anything |
data-did-init |
The callback function to call when the counter has initialised. The default is no callback |
|
|
data-did-update |
A callback function to call when the value of the counter was updated. The default is no callback |
data-will-remove |
A callback function to call just before the counter will be removed. Useful for when you want to clean up some things before removal. The default is no callback |
data-did-remove |
A callback function to call when the counter was removed. The default is no callback |
data-credits |
Tick is given to you for free. To support the development of Tick please keep the tiny "Powered by PQINA" logo visible or place a link to "https://pqina.nl" somewhere else on your website. You can disable the credits message by setting 'false' to the data-credits attribute. The default is true |
Tick also has a public API. The following methods are available on the Tick
object:
supported
options
setConstant
DOM
create
destroy
parse
find
helper
interval
date
duration
data
request
poll
count
down
up
schedule
plugin
add
Method | Description |
---|---|
supported |
The |
|
|
setConstant |
Call |
|
|
DOM.create |
Call |
|
|
DOM.destroy |
Call |
|
|
DOM.parse |
Call |
DOM.find |
Call |
helper.interval |
Use The function returns a
The options object can be used to prevent the timer from automatically starting. |
An example with all parameters.
A live example with only the callback parameter.
|
|
helper.date |
Returns current time or date object based on ISO string.
|
helper.duration |
Can be used for three purposes:
|
data.request |
The |
|
|
data.poll |
|
count.down |
|
|
|
When given a date (either date object or ISO8610 string) the |
|
|
|
You can control the time denominations by passing an options object parameter like so.
The following additional parameters are available.
|
|
count.up |
|
|
|
count.schedule |
Tick supports a the following schedule directives where all numbers and denominations are configurable. The wait statements tell Tick to wait an x amount of time before resuming countdown.
You can combine schedules to create complex recurring events. For example
or
The schedule method takes an options object just like the countdown and countup. It exposes one additional property which is the
|
|
|
plugin.add |
An API endpoint to add plugins to Tick. By itself Tick only features a Text view and no custom fonts. Tick can then be extended with plugins to render all sorts of counters. The jQuery, Kickstart and Global packages of Tick will automatically load plugins. You only need this API when you are using the CommonJS, ES2015 or AMD version of Tick. The add function takes either three parameters or one. With three parameters:
One parameter:
|
A Tick instance exposes the following methods
destroy
root
value
Name | Description |
---|---|
value |
Used to set or get the value of the Tick Counter.
|
destroy |
Destroy this tick counter.
|
root |
Returns the root element of this tick counter.
|
Method | Description |
---|---|
|
|
create |
Call |
|
|
destroy |
Call |
parse |
Call |
find |
Call |
value |
Used to set or get the value of the Tick Counter.
|
root |
Returns the root element of the counter.
|
* |
The following methods function the same as described on the Tick JavaScript API.
The only difference is that calling them when using jQuery is done with So |
Tick Options
The options
object takes the following properties:
value
view
didInit
didUpdate
willRemove
didRemove
credits
Name | Description |
---|---|
value |
Used to set the initial value of the Tick Counter. Can be almost anything. No default value |
view |
The view to render, only necessary when building the tick counter using JavaScript. More information on the view property can be read below. Uses text view by default |
|
The callbacks as described in the Tick attribute table. |
credits |
Tick is given to you for free. To support the development of Tick please keep the tiny "Powered by PQINA" logo visible or place a link to "https://pqina.nl" somewhere else on your website. You can disable the credits message by setting this property to The default is true |
Tick View Property
The view
property available on the the options object of the Tick.DOM.create(element, options)
method can be used to build a tree of presenters with JavaScript. A presenter in this case is an object describing the element Tick should automatically create.
If we omit the element
parameter from the Tick.DOM.create
function, Tick will automatically create an element for us. The example below only contains the options
parameter to keep things concise. All presenter objects are marked with comments.
Setting up a Tick counter view in JavaScript
// create Tick Counter
var tick = Tick.DOM.create({
value: 1234,
view:
// definition for top level tick element
{
children:[
// presenter object
{
root: 'div',
layout: 'horizontal fill',
children: [
// presenter object
{
view: 'flip'
},
// presenter object
{
view: 'line',
root: 'div'
}
]
}
]
}
});
// add Tick Counter to body element
document.body.appendChild(tick.root);
Setting up a Tick counter view in jQuery
// create Tick Counter
$(element).tick('create', {
value: 1234,
view:
// definition for top level tick element
{
children:[
// presenter object
{
root: 'div',
layout: 'horizontal fill',
children: [
// presenter object
{
view: 'flip'
},
// presenter object
{
view: 'line',
root: 'div'
}
]
}
]
}
});
A presenter is either defines a layout or defines a view. A presenter is a view if the object has a view
property. Otherwise the presenter is automatically a layout.
The following properties are available on for presenter objects:
root
view
transform
style
overlay
key
children
layout
repeater
A view
presenter object cannot have the following properties:
children
layout
repeater
A layout
presenter object cannot have these properties:
view
style
Name | Description |
---|---|
view |
The name of the view in string format.
No default value. |
root |
The HTML element to use for the root of this presenter. It's either a string or an HTML element. By default this is a `span` |
style |
The style string to pass to the view. By default no styles are supplied |
overlay |
The No default value |
layout |
The No default value |
repeater |
Set to Default is false |
children |
An array of child presenters. Default is empty array |
key |
A Default is null |
transform |
A value transform chain to apply to the value received by this presenter. Default is null |
Views
Tick Studio (not available yet) ships with five different views for presenting data. It's also possible that you've bought a single view.
Each view features different configuration options and can be combined with the other views.
You setup the view using the data-view
attribute on an HTML element of your choice (within the tick element). This will most likely be a div
or a span
based on the type of layout you're building.
<!-- The HTML below creates a flip view -->
<div class="tick">
<span data-view="flip"></span>
</div>
Views can be styled and configured using the data-style
attribute. The data-style
attribute can be updated while the counter is running to update the presented view (for instance, change color when a certain value is presented). Some views have lots of style options while others are more limited.
<!-- Set custom styles to a flip view -->
<div class="tick">
<span data-view="flip"
data-style="flip-duration:500ms"></span>
</div>
Text
The text
view displays the given value as a simple text. The text
view accepts values of type string
and type number
.
<div class="tick"
data-value="Hello World">
<span data-view="text"></span>
</div>
You can set all style aspects of the text using CSS.
<style>
#text-styled [data-view="text"] {
font-weight: bold;
font-family: sans-serif;
color: red;
letter-spacing: .25em;
}
</style>
<div class="tick"
id="text-styled"
data-value="Hello World">
<span data-view="text"></span>
</div>
Swap
With the Swap view you can update text with animations. These animations can be configured with the transition
, transition-in
, transition-out
and transition-direction
properties.
Press the +1 button to view the animation example.
<div class="tick"
data-value="1000">
<span data-view="swap"
data-style="transition:swap, crossfade"></span>
</div>
If you want the text to be cut of use the overflow
CSS property.
<style>
#text-style-overflow [data-view="swap"] {
overflow-y:hidden;
}
</style>
<div class="tick"
id="text-style-overflow"
data-value="1000">
<span data-view="swap"
data-style="transition:swap, crossfade"></span>
</div>
More on setting and configuring transitions can be read below in the transitions topic as they can be used in different views. The transition-direction
property is text
view only so we'll discuss that one here.
If you set transition-direction
to detect
Tick will try to detect if the value is increasing or decreasing and will switch the animation direction accordingly.
<div class="tick"
data-value="1500">
<span data-view="swap"
data-style="transition-direction:detect; transition:swap, crossfade"></span>
</div>
Flip
The flip
view renders the familiar classic Flip Counter. It accepts values of type string
and type number
.
<div class="tick"
data-value="Hello World">
<span data-view="flip"></span>
</div>
Note that this is the exact HTML as shown in the text
example but we've replaced the word text
with flip
. We could even render both a text and a flip counter by adding another view node.
<div class="tick"
data-value="Hello World">
<span data-view="flip"></span>
<span data-view="text"></span>
</div>
Alright, let's revert back to showing only the Flip Counter. Tick will render and animate a subtle shadow below the flipper so it feels like it has depth.
You can tweak the flip counter to your liking with the following style properties flip-duration
, flip-easing
, shadow
and rounded
.
flip-duration
controls the duration of the flip which can be set in milliseconds. The default value is 800
milliseconds.
flip-easing
allows you to set different easing methods for the flip animation. By default Tick uses a bounce ease called ease-out-bounce
. You can view three other easing functions below.
shadow
controls the shadows displayed. Default value is all shadows, you can set it to inner
to only render inner shadows or none
to remove all shadows.
The rounded
property can be set to none
to remove all rounded corners, or panels
to add rounded corners to the panels themselves.
Here we define different easing modes on the flipper.
<div class="tick"
data-value="1000">
<span data-view="flip"
data-style="flip-easing: ease-linear"></span>
<span data-view="flip"
data-style="flip-easing: ease-in-circ"></span>
<span data-view="flip"
data-style="flip-easing: ease-in-out-quart"></span>
</div>
Styling of the flip counter can be done with CSS.
/* distance from other flippers */
.tick-flip {
margin-left: .0625em;
margin-right: .0625em;
}
/* border radius of the flipper */
.tick-flip {
border-radius: .125em;
}
/* color of the flipper */
.tick-flip-panel {
color: #eee;
background-color: #333;
}
/* shadow behind the flipper */
.tick-flip-shadow {
box-shadow: 0 0 1em #000;
}
/* padding in the flipper (both values should be the same) */
.tick-flip {
letter-spacing: .25em;
text-indent: .25em;
}
An example when we change the color, increase the padding and spacing between the characters and make the corners more round.
<style>
/* rounder corners */
#my-flip {
/* increase border radius */
border-radius:.3125em;
/* increase spacing between letters */
letter-spacing: .5em;
text-indent: .5em;
}
/* black on white colors */
#my-flip .tick-flip-panel {
color: #555;
background-color: #fafafa;
}
</style>
<div class="tick"
data-value="1000">
<span id="my-flip"
data-view="flip"></span>
</div>
Dots
The dots
view displays passed values in a led matrix display.
It can display numeric values, spaces, dashes dots and commas.
<div class="tick"
data-value="12.345,50">
<div data-view="dots" data-style="font:highres"></div>
</div>
You can define the border-radius, color, size, and distance between the pixels using CSS.
Use width
and height
to set the dot size, use margin
to define the distance between the dots.
By default the size of the dots is set to 5px
, the distance between them is 1px
. The color of the dots is derived from the text color.
<style>
#dots-size .tick-dots-dot {
width: 10px;
height: 10px;
margin: 2px;
border-radius: 25%;
background-color: red;
}
</style>
<div class="tick"
id="dots-size"
data-value="123">
<span data-view="dots"></span>
</div>
The distance between the characters is defined with CSS as well. The default distance is 0.05em
.
<style>
#dots-distance .tick-dots-character {
margin:0 1em 0 0;
}
</style>
<div class="tick"
id="dots-distance"
data-value="123">
<span data-view="dots"></span>
</div>
The dots
view has the following style properties:
font
shape
color
align
dot-update-delay
character-update-delay
transition
transition-in
transition-out
The transition properties take care of the animation between the dot off
and dot on
state. By default dots are faded out when turned off and faded in when turned on.
Name | Description |
---|---|
font |
The font to render the text in. Choose between Default is highres |
shape |
The shape of the dots. With small dot sizes browser rendering might turn Default is 'auto', slightly rounded corners with CSS
|
color |
The color of the dots. Any valid CSS color value. You can also set gradients. There are two types of gradients to choose from:
Horizontal will draw from left to right, where vertical will draw from top to bottom. You can set percentage values to define where each color should start like so The default background color is 'auto' which means the color is defined in CSS |
|
|
align |
The alignment of the text in the matrix display, mostly relevant for animation purposes. Set to either 'left' or 'right'. Default is 'left' |
dot-update-delay |
The delay between dot updates in milliseconds. Set to a higher value to slow down the character update animation. Default is 10 |
|
|
character-update-delay |
The delay between character updates in milliseconds. Combine with Default is 0 |
|
|
transition |
The transition to use when animating between dot states, The default transition is set to crossfade. For more about transitions read the transition documentation Default is 'crossfade' |
|
Line
The line
view is especially good in showing percentages. It accepts a value between 0
and 1
and cannot be used to present text.
It's best to use div
as a base element to apply the meter view to. By default the line
view presents data in a horizontal progress bar.
Below we present the value 0.25
in a default line
view. It renders a horizontal bar with a foreground and background color. You can feed other values into a meter (they don't have to be between 0 and 1), we'll get into that in the value transform section of the documentation.
<div class="tick"
data-value=".25">
<div data-view="line"></div>
</div>
The line
view can also be rotated vertically or transformed into a circle.
<div class="tick"
data-value=".25">
<div data-view="line"
data-style="orientation:vertical"></div>
</div>
I've added a div around the circular meter to make it a more acceptable size.
<div class="tick"
data-value=".25">
<div style="max-width:5em;">
<div data-view="line"
data-style="shape:circle; rail-color:#fff"></div>
</div>
</div>
The default rectangle shaped progress bars take the following style values:
fill-color
rail-color
cap-style
orientation
Name | Description |
---|---|
fill-color |
The color of the progress fill. By default it's styled with CSS. The default is none |
rail-color |
The color of the background of the meter. By default it's styled with CSS. The default is none |
cap-style |
The shape of the meter start and end. Can be either If set to The default is 'auto' |
orientation |
Either The default is 'horizontal' |
The circular shaped progress bar exposes the following style properties:
offset
length
gap-size
flip
invert
align
padding
cap-style
fill-color
fill-width
fill-shadow
rail-color
rail-width
rail-shadow
Name | Description |
---|---|
offset |
Defines the starting point of the circle in a value between 0 and 1. The default is 0 |
length |
Defines the length of the circle in a value between 0 and 1. The default is 1 |
gap |
Defines the gap between the fill and rail in a value between 0 and 1. The default is 0 |
flip |
Makes the progress indicator move in the opposite direction. The default is false |
invert |
Switches the fill and rail from position. The default is false |
align |
The alignment of the fill and the rail. Can be either The default is 'center' |
padding |
The padding of the draw area, useful in combination with align option if ring is drawn outside of canvas. Can be any CSS unit. The default is 0 |
cap-style |
The shape of the meter start and end. Can be either The default is 'butt' |
fill-color |
The color of the progress fill. Any valid CSS color value. You can also set a gradients. There's three types of gradients to choose from:
The follow gradient will draw a gradient along the circular progress line. Horizontal will draw from left to right, where vertical will draw from top to bottom. You can set percentage values to define where each color should start like so The default background color is #333 |
|
|
fill-width |
The width of the fill in CSS units of choice. The default is .125em |
fill-shadow |
The shadow thrown by the fill. A normal CSS shadow Tick will automatically scale down the ring to make the shadow fit the drawing area. The default is none |
|
|
rail-color |
The color of the background of the meter. Any CSS color value. The default is #eee |
rail-width |
The width of the rail in CSS units of choice. The default is .125em |
rail-shadow |
The shadow thrown by the rail. A normal CSS shadow The default is none |
Boom
The boom
view is used to play an audio fragment on value update. It is used in conjunction with other views as you can see in the example below.
For instance a "ka-tjing" sound when a new donation is made. Click the "plus" button below for a test.
This view doesn't work on IE11
<div class="tick"
data-value="1000">
<span data-view="text"></span>
<span data-view="boom"
data-style="sample: url(./media/bell.m4a), url(./media/bell.ogg);">
</span>
</div>
The quicker you press the button in succession the higher pitched the bell sound becomes. This is controlled with the pitch-step
, pitch-threshold
and pitch-max
properties.
The following properties are available on the audio
view.
sample
volume
pitch-threshold
pitch-step
pitch-max
Name | Description |
---|---|
sample |
The sample property defines the audio sample to use. You can supply multiple formats using a comma separated list of By default there are no audio files loaded. These will have to be supplied. |
volume |
The volume of the audio in a range from The default is .5 |
pitch-threshold |
The max time in milliseconds between each value change for the pitch to increase. The default is 1 second |
pitch-step |
The amount of pitch increased per time. The default is .05 |
pitch-max |
The maximum amount of pitch increase. The default is 1.35 |
Layouts
So, with all the views discussed let's move on to defining a counter layout.
Elements
Tick contains a couple default layout attributes to position views. These attributes can be used anywhere within the tick element and are applied with the data-layout
attribute.
We can position counters below each other using the data-layout="vertical"
attribute.
<div class="tick"
data-value="Hello World">
<div data-layout="vertical">
<span data-view="flip"></span>
<span data-view="text"></span>
</div>
</div>
There's three types of layouts.
horizontal
vertical
overlay
The horizontal
layout value will place all sub views on a line next to each other. Positioning of these sub views can then be handled with:
left
center
right
fill
baseline
So horizontal right
will align all sub views on a single line to the right. The fill
value will divide all space among the available sub views. The baseline
value will align items vertically by baseline offset.
Set the value to horizontal fit
to make Tick resize the subviews to take up all available space.
The vertical
layout value will place all sub views beneath each other. Positioning of these sub views is done with the following additional values:
top
bottom
middle
left
right
fill
Setting vertical bottom right
will align all items to the bottom right of the element (if it's bigger then the space the elements themselves take up).
The overlay
value will place elements on top of each other. Below we build a presenter with a double progress bar and a centered text view. The center
and stretch
values for the data-overlay
attribute as set on the views take care of positioning the elements correctly.
In this case, we want the first line
to define the space of the counter (there for it has no data-overlay
attribute). The text we want to center
on the meter, and the second meter we want to stretch
so it fills all available space.
<div class="tick"
data-value=".25">
<div style="max-width:8em">
<div data-layout="overlay">
<span data-overlay="center" data-view="text"></span>
<div data-view="line"
data-style="shape:circle; rail-color:#fff"></div>
<div data-overlay="stretch"
data-view="line"
data-style="padding:1em; shape:circle; rail-color:#fff"></div>
</div>
</div>
</div>
There's one last attribute available for layout views called data-value-mapping
. It controls how the element will pass on it's received value to it's children. By default all children receive the value the parent receives.
When the parent element value is in array form and data-value-mapping
is set to "indexes"
the parent element will assign each index of the array to an element.
If you explicitly set the value to "none"
the parent element will ignore child keys (see the Group tab).
Repeat
To create a repeat element we set the data-repeat
attribute to true
. The repeater splits an incoming value into separate characters and creates a view for each of the characters.
You can use the repeater with any child view (or group of child views).
Below we can see the left element is a normal flip counter. The second one is wrapped in a repeater. The repeater then automatically generates a flip element for each character.
<div class="tick"
data-value="1500">
<span data-view="flip"></span>
<span data-repeat="true">
<span data-view="flip"></span>
</span>
</div>
Group
Groups are used to bind values to certain child views.
Say you're value is an object and you want to assign properties of that object to different views then you can use the data-key
attribute to handle that. Set the value of the tick base element with an object either to JavaScript or using the format as shown below, then assign the correct keys to the presenters.
<div class="tick"
data-value="progress:.75, text:200">
<div data-layout="vertical center fill">
<div data-view="line"
data-key="progress"></div>
<span data-repeat="true"
data-key="text">
<span data-view="flip"></span>
</span>
</div>
</div>
Value Transforms
The value you set to the data-value
attribute can be transformed to be presented in all sorts of ways. We can do this using the data-transform
attribute. This attribute alone is the hearth of Tick and adds all the power and flexibility to it.
The transform attribute transforms the value it receives to another value we can then be presented by a view.
Let's use our progress indicator from the admin panel demo as an example. I've shown a simplified version of the code below. I've added a style
property with a max-width
to limit the size of the circular progress indicator.
<div class="tick"
data-value="45">
<div data-layout="overlay center"
style="max-width:5em">
<div data-view="line"
data-style="shape:circle; rail-color:#fff"></div>
<span data-view="text"
data-overlay="center"></span>
</div>
</div>
We've set 45
as the value. And we can see our text
view renders it nicely. But, our line
is completely filled while we would expect it to be near half filled.
What's happening? Our line
expects a value between 0
and 1
, where 0
is empty and 1
is full.
This is where the data-transform
attribute comes into play. We can add that attribute to the line
to transform the value into the right format.
<div class="tick"
data-value="45">
<div data-layout="overlay center"
style="max-width:5em">
<div data-view="line"
data-style="shape:circle; rail-color:#fff"
data-transform="fraction(0,100)"></div>
<span data-view="text"
data-overlay="center"></span>
</div>
</div>
Alright, we've added the fraction
transform.
The transform will take the received value and turn it into a fraction between the given min
and max
values, in this case 0
and 100
. This will result in a value of 0.45
which then gets send to the line
.
Now it would be nice if our text
showed a percentage sign. We can accomplish this with the format
transform.
<div class="tick"
data-value="45">
<div data-layout="overlay center"
style="max-width:5em">
<div data-view="line"
data-style="shape:circle; rail-color:#fff"
data-transform="fraction(0,100)"></div>
<span data-view="text"
data-overlay="center"
data-transform="format('$0%')"></span>
</div>
</div>
The format
transform takes a string value (in this case '$0%'
and replace the $0
part with the received value.
If we tap the plus button for long enough the value will get higher then 100
, we can prevent this with the limit
transform. Note that this only presents values outside of the limit range from being presented, the value of Tick will still be what you set to it.
<div class="tick"
data-value="45">
<div data-layout="overlay center"
data-transform="limit(0,100)"
style="max-width:5em">
<div data-view="line"
data-style="shape:circle; rail-color:#fff"
data-transform="fraction(0,100)"></div>
<span data-view="text"
data-overlay="center"
data-transform="format('$0%')"></span>
</div>
</div>
If you look closely you'll notice the data-transform
has been added to the layout presenter. Transforms can be added on every element and the transformed value will be passed on to the child presenters. This allows us to create complex transform structures.
Let's take a look. We'll move the fraction
transform to the layout presenter next to the limit
transform. We can chain transforms with an arrow ->
. Then we'll a arrive
transform which will interpolate between the current value and the next value using an arrival animation.
<div class="tick"
data-value="45">
<div data-layout="overlay center"
data-transform="limit(0,100) -> fraction(0,100) -> spring"
style="max-width:5em">
<div data-view="line"
data-style="shape:circle; rail-color:#fff"></div>
<span data-view="text"
data-overlay="center"
data-transform="format('$0%')"></span>
</div>
</div>
Our text
presenter is now totally out of control. It now presents a value between 0
and 1
and during the animation it just shows a crazy bunch of decimals. Let's correct this with the multiply
and round
transforms.
<div class="tick"
data-value="45">
<div data-layout="overlay center"
data-transform="limit(0,100) -> fraction(0,100) -> arrive"
style="max-width:5em">
<div data-view="line"
data-style="shape:circle; rail-color:#fff"></div>
<span data-view="text"
data-overlay="center"
data-transform="multiply(100) -> round(1) -> format('$0%')"></span>
</div>
</div>
The value received by the text
view is now multiplied by a 100
using the multiply
transform, then it's rounded to one decimal place using the round
transform. Last but not least, our format
transform adds the percentage sign.
Now our numbers are beautifully and nicely animated in between updates.
Tick ships with the following transform components:
abs
add
subtract
multiply
divide
modulus
round
ceil
floor
limit
fraction
percentage
arrive
spring
step
tween
input
upper
lower
substring
reverse
pad
number
replace
split
format
plural
delay
map
rotate
transform
keys
duration
value
That's quite a list, let's see what each of those does and what values they accept.
The table below shows the name of the transform, the input type(s) it accepts and the output type it produces. When chaining transforms keep in mind that the transforms should fit together like Domino's, the output type of the preceding transform should match the input type of the next transform. See the example below.
In this example we've set our data-value
to 4
, which Tick will automatically interpreted as of type number.
transform | value |
---|---|
4 | |
multiply(5) | 20 |
limit(0, 15) | 15 |
number | 15.000,00 |
split(',') | "15.000", "00" |
Name | Input | Output | Description |
---|---|---|---|
input | * | * |
Returns the value it receives.
|
value | * | * |
Returns a static value no matter what input value is received.
|
upper | string number | string |
Returns the value it receives in Uppercase.
|
lower | string number | string |
Returns the value it receives in Lowercase.
|
substring | string number | string |
Returns a part of the input value. Functions the same as JavaScript substring method.
|
abs | number | number |
Turns negative numbers into positive numbers.
|
add | number | number |
Adds a fixed value to the input value.
|
subtract | number | number |
Subtracts a fixed value to the input value.
|
multiply | number | number |
Multiply input value with a fixed value.
|
divide | number | number |
Divide input value with a fixed value.
|
modulus | number | number |
Returns what whole integer remains after dividing input value by given number.
|
round | number | number |
Round input value to a certain amount of decimal places.
|
floor | number | number |
Round down input value.
|
ceil | number | number |
Round up input value.
|
limit | number | number |
Limit value between
|
fraction | number | number |
Calculates fraction of input value between a
|
percentage | number | number |
Calculates percentage of input value between a
|
arrive | number | number |
Interpolates between the previous input value and the new input value. Slowly accelerates towards the new value when halfway starts decelerating. Can accept up to four parameters.
|
spring | number | number |
Interpolates between the previous input value and the new input value using spring physics.
|
step | number | number |
Interpolates between the previous input value and the new input value using a fixed step size.
|
tween | number | number |
Interpolates between the previous input value and the new input value over a given duration. Accepts three properties,
|
plural | number | string |
Outputs either value If input value is equal to
|
number | number | string |
Formats the input value as a number (currency). First arguments is decimal separator, second argument is thousands separator. The default values are Note that the output value is a string.
|
pad | string number | string |
Pads the input value with the given string from the right side. Note that the output value is a string.
|
replace | string number | string |
Replaces the supplied needle with the given replacement in the input value.
|
format | string number | string |
Replaces the
|
duration | number | array |
Turns input value into a duration in requested format.
|
split | string number | array |
Splits the input value with the given character. This is useful for feeding data to a repeater element or preparing it for a transform that only accepts an array as input.
|
reverse | array string number | array string |
Reverses the input value. This is useful for feeding data to a repeater element or preparing it for a transform that only accepts an array as input.
|
delay | array | array |
Holds previous value and slowly updates the old array with the values in the newly received array. The delay transform takes three parameters. Order defines the order in which the old array is updated with the new array. This can be
|
keys | array | object |
Applies keys to received array values.
|
map | array | array |
Runs a transform function on each value of the given array. Transforms should be given parenthesis when used as parameters.
|
rotate | array | array |
Runs a transform function on each value of the given array rotating the transform functions when the end of the array is reached. Transforms should be given parenthesis when used as parameters.
|
transform | * | * |
Runs a set of transform functions against the input value returning the return value Transforms separated by a comma will run in parallel and will cause the function to return an array. Transforms should be given parenthesis when used as parameters.
|
Transitions
Tick ships with a set of preset transitions, transforms and easing functions.
When configuring the presets and transforms you can use all CSS units (px, em, %, etc.) as you would when defining the transitions in CSS.
Transitions are available on the swap
and dots
view.
Presets
Preset transitions combine a in
and out
transform into an animation.
Every preset animation duration is 1 second by default. Preset animations take a animation duration factor parameter which can be used to reduce the default animation speed. For instance a factor of .5
makes the animation run in 500 milliseconds instead of 1 second.
The preset animations also take a delayIn
and delayOut
parameter which can be used to delay the intro and outro animations separately. Values are in seconds (1s) or milliseconds (1000ms), similar to how they are defined in CSS.
Tick ships with the following preset transitions:
crossfade
swap
revolve
The available presets can be combined in the transition
property. You can set one or multiple, all set presets will be run at the same time (of course set delays will be taken into account).
// single preset animation
transition: crossfade;
// multiple presets
transition: crossfade, swap;
// multiple presets with custom values
transition: crossfade(.5), swap(x);
The table below shows the available configuration options for each preset.
Name | Description |
---|---|
crossfade |
New value fades in, old value fades out. Takes 3 optional arguments:
|
|
|
swap |
New value moves into view (over x or y axis) from position Takes 5 optional arguments:
|
|
|
revolve |
New value rotates into view (over x, y or z axis) from Takes 5 optional arguments:
|
|
Transforms
Instead of using the preset transition
you can also build you're own animations using the transition-in
and transition-out
properties. These can be defined with the following transforms:
move
rotate
scale
fade
Please keep in mind that these transforms are not available for the transition
property, the transition
property only takes presets.
Like with presets you can supply multiple, comma separated, values to transition-in
and transition-out
. But unlike presets the transition properties take additional arguments like duration, ease function and delay.
The possible arguments (and order) for the transition in and out styles are shown below.
transition-in: transform | origin | duration | ease | delay;
An example of building a real intro transition:
// move from -20px to position 0
transition-in: move(-20px, 0);
// do it in 500 milliseconds
transition-in: move(-20px, 0) 500ms;
// with a cubic easing function
transition-in: move(-20px, 0) 500ms ease-in-cubic;
// wait 250 milliseconds before starting
transition-in: move(-20px, 0) 500ms ease-in-cubic 250ms;
// also fade in the new value
transition-in: move(-20px, 0) 500ms ease-in-cubic 250ms, fade(0, 1) 500ms;
If you want to rotate elements it's often handy to be able to set the transform origin of a transition. You can do so with the origin
argument.
// rotate element into view over z axis with the top right corner as the transform origin
transition-in: rotate(-45deg, 0, z) origin(top right) 500ms;
Name | Description |
---|---|
move |
The By default it transforms from |
|
|
rotate |
The By default it transforms from |
|
|
scale |
The By default it transforms from |
|
Easing
Transitions can make use of easing functions to make the animations look more natural. Tick ships with the following ease functions which are available everywhere an easing function can be set:
ease-linear
ease-in-sine
ease-out-sine
ease-in-out-sine
ease-in-cubic
ease-out-cubic
ease-in-out-cubic
ease-in-circ
ease-out-circ
ease-in-out-circ
ease-in-quad
ease-out-quad
ease-in-out-quad
ease-in-quart
ease-out-quart
ease-in-out-quart
ease-in-expo
ease-out-expo
ease-in-out-expo
ease-in-back
ease-out-back
ease-in-out-back
ease-out-elastic
ease-out-bounce
The website easings.net features a clear overview of these functions and their effect on a transition.