Comments (4)
It's used to create an easier way to apply a certain transform to a value.
This is the handler for the abs
transform.
export default () => (value, cb) => cb(Math.abs(value));
This is the handler for the preset
transform.
export default (...presets) => (value, cb, instance) =>
cb(
value.map(
(v, index) => instance.getPreset(presets[index])(v, instance.getConstants(), instance)
)
);
- It receives all the defined presets in the transform (for example
'd', 'h', 'm', 's'
). - Then in the order of the value array it'll get the preset for that value from the Tick instance preset array.
The value would be something like [0, 11, 3, 20] where 0
is days, 11
is hours, etc.
It'll thus load preset 'd'
for 0
, which is this preset:
d:(value, constants) => (
transformDurationUnit(
value,
constants.DAY_SINGULAR,
constants.DAY_PLURAL,
365
)
),
The value returned is passed on to the next node.
You can add your own presets with setPreset(key, value)
and then you can use it in your tick template.
Honestly the preset/constant functions were only added to make creating date timers more easy. So that's kinda why they're not documented at this point.
from flip.
Thanks, it seems preset
is specific to how flip is handling date timers. I was looking for documentation because example file is using preset(d, h, m, s)
and for my project I just needed hour, minute and second. I removed d
and it didn't work, so I tried to the docs and found nothing. Only after reading about option object format: ['h', 'm', 's']
I managed to make it work.
from flip.
@adas172002 Yes it maps directly to the format, so both should have the same keys.
from flip.
Great, I hope others will benefit from this information.
Closing the issue, thanks.
from flip.
Related Issues (20)
- flip demo add data-style="flip-duration:500ms" not working HOT 2
- returning the timestamp and then working fine
- t.shift is not a function HOT 1
- Counter occasionally displays incorrect value... HOT 17
- @pqina/flip for Nuxtjs not working HOT 1
- Layout of "horizontal fill" does not seem to work with the API
- Singular with zero
- Import error in next js HOT 1
- remove last comma ,00 in counter number and the way to custom comma HOT 2
- Flip clock with hours flipper with no leading 0 and centered HOT 1
- Upper and lower half of numbers not aligned
- Shein documentary... HOT 1
- How does data-did-init work with vue? HOT 1
- How to set flip panel mode? HOT 3
- Flip card differs in height HOT 3
- Animation problem in mobile HOT 4
- Feature: is there a way to play sound on animation HOT 3
- If you load the website in a separate tab, the animation does not run HOT 4
- Getting a 1 pixel shift occasionally during flipping HOT 2
- how to set new value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flip.