levmyshkin/flipdown
Composer 安装命令:
composer require levmyshkin/flipdown
包简介
FlipDown is a lightweight and performant flip styled countdown clock.
README 文档
README
FlipDown
⏰ A lightweight and performant flip styled countdown clock.
Features
- 💡 Lightweight - No jQuery! <11KB minified bundle
- ⚡ Performant - Animations powered by CSS transitions
- 📱 Responsive - Works great on screens of all sizes
- 🎨 Themeable - Choose from built-in themes, or add your own
- 🌍 i18n - Customisable headings for your language
Example
Example live at: https://pbutcher.uk/flipdown/
Remix FlipDown on CodePen: https://codepen.io/PButcher/pen/dzvMzZ
Basic Usage
To get started, either clone this repo or install with npm install flipdown or yarn add flipdown.
For basic usage, FlipDown takes a unix timestamp (in seconds) as an argument.
new FlipDown(1538137672).start();
Include the CSS and JS in <head> and include the following line in your HTML.
<div id="flipdown" class="flipdown"></div>
See a full example here.
Multiple Instances
To use multiple instances of FlipDown on the same page, specify a DOM element ID as the second argument in FlipDown's constructor:
new FlipDown(1588017373, "registerBy").start(); new FlipDown(1593561600, "eventStart").start();
<div id="registerBy" class="flipdown"></div> <div id="eventStart" class="flipdown"></div>
Themes
FlipDown comes with 2 themes as standard:
- dark [default]
- light
To change the theme, you can supply the theme property in the opt object in the constructor with the theme name as a string:
{ theme: "light"; }
For example, to instantiate FlipDown using the light theme instead:
new FlipDown(1538137672, { theme: "light", }).start();
Custom Themes
Custom themes can be added by adding a new stylesheet using the FlipDown theme template.
FlipDown themes must have the class name prefix of: .flipdown__theme- followed by the name of your theme. For example, the standard theme class names are:
.flipdown__theme-dark.flipdown__theme-light
You can then load your theme by specifying the theme property in the opt object of the constructor (see Themes).
Headings
You can add your own rotor group headings by passing an array as part of the opt object. Bear in mind this won't change the functionality of the rotors (eg: the 'days' rotor won't magically start counting months because you passed it 'Months' as a heading).
Suggested use is for i18n. Usage as follows:
new FlipDown(1538137672, { headings: ["Nap", "Óra", "Perc", "Másodperc"], }).start();
Note that headings will default to English if not provided: ["Days", "Hours", "Minutes", "Seconds"]
API
FlipDown.prototype.constructor(uts, [el], [opts])
Create a new FlipDown instance.
Parameters
uts
Type: number
The unix timestamp to count down to (in seconds).
[el]
Optional
Type: string (default: flipdown)
The DOM element ID to attach this FlipDown instance to. Defaults to flipdown.
[opts]
Optional
Type: object (default: {})
Optionally specify additional configuration settings. Currently supported settings include:
FlipDown.prototype.start()
Start the countdown.
FlipDown.prototype.ifEnded(callback)
Call a function once the countdown has ended.
Parameters
callback
Type: function
Function to execute once the countdown has ended.
Example
var flipdown = new FlipDown(1538137672) // Start the countdown .start() // Do something when the countdown ends .ifEnded(() => { console.log("The countdown has ended!"); });
Acknowledgements
Thanks to the following people for their suggestions/fixes:
- @chuckbergeron for his help with making FlipDown responsive.
- @vasiliki-b for spotting and fixing the Safari backface-visibility issue.
- @joeinnes for adding i18n to rotor group headings.
levmyshkin/flipdown 适用场景与选型建议
levmyshkin/flipdown 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 5.79k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 02 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 levmyshkin/flipdown 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 levmyshkin/flipdown 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5.79k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-15