{"id":15480284,"url":"https://github.com/andycall/calculagraph","last_synced_at":"2026-03-12T19:34:48.335Z","repository":{"id":29846946,"uuid":"33391772","full_name":"andycall/Calculagraph","owner":"andycall","description":"multifunctional calculagraph (多功能计时器)","archived":false,"fork":false,"pushed_at":"2015-05-26T05:32:29.000Z","size":181,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-26T13:03:06.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andycall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-04T02:36:50.000Z","updated_at":"2016-12-26T07:34:39.000Z","dependencies_parsed_at":"2022-08-24T03:10:58.481Z","dependency_job_id":null,"html_url":"https://github.com/andycall/Calculagraph","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycall%2FCalculagraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycall%2FCalculagraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycall%2FCalculagraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycall%2FCalculagraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andycall","download_url":"https://codeload.github.com/andycall/Calculagraph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250265368,"owners_count":21402083,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T04:41:24.521Z","updated_at":"2026-03-12T19:34:48.287Z","avatar_url":"https://github.com/andycall.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Calculagraph\n多功能计时器\n\nHere is an [English edition](README_US.md)\n\n##安装\n\n```bash\nnpm install calculagraph\n```\n\n\n\n## 使用\n\n### 准备\n\n+ Node.js\n\n    ```javascript\n    var Calculagraph = require('calculagraph');\n    ```\n\n+ Browser Global\n\n    ```javascript\n    console.log(Calculagraph);\n    ```\n\n+ RequireJS\n\n    ```javascript\n    define(['Calculagraph'], function(Calculagraph){\n        console.log(Calculagraph);\n    });\n    ```\n    \n### Step 1: 构建time对象\n\n```javascript\n\nvar time = new Calculagraph();\n \n```\n\n### Step 2: 设置起始时间\n如果没有设置， 则默认为0。 当起始时间为0的时候， 逆时计时会自动停止。\n\n```javascript\n\ntime.set(20); // 设置起始时间为20秒\n\n```\n\n\n### Step 3: 绑定计时器\n可以看下面的例子\n\n\n### API\n\n**increase**\n递增计时绑定\n\n+ 参数： \n    - callback 每一个时刻触发的回调函数\n    - interval 总运行时间\n    - tick     每一个时刻的时间间隔\n    - finish   完成之后触发的回调函数\n\n**descrease**\n递减计时绑定\n\n+ 参数： \n    - callback 每一个时刻触发的回调函数\n    - interval 总运行时间\n    - tick     每一个时刻的时间间隔\n    - finish   完成之后触发的回调函数\n\n\n**set**\n设置起始的时间， 需要在调用decrease或者increase时运行\n+ 参数:\n    - time : 设置的时间， 单位是秒\n    \n**stop**\n停止计时， 同时清空计时状态。\n\n**parse**\n暂停计时， 保留计时状态\n\n**restore**\n恢复上一次暂停时的计时状态\n\n**restart**\n重启计时，如果之前设置了起始时间， 则从起始时间开始运行。\n\n\n## AMD 加载器支持\n若检测到AMD加载器，暴露Calculagraph构造函数，且不再将Calculagraph暴露到全局下\n\n## Example\n\n### 逆时计时\n```javascript\n    \nvar time = new Calculagraph();\ntime.set(30);\ntime.decrease(function(time){\n    console.log(time);\n}, 30, 500, function(){\n    console.log('finishde');\n});\n\n```\n\n### 顺时计时\n``` javascript\n\nvar time = new Calculagraph();\ntime.set(15);\ntime.increase(function(time){\n    console.log(time);\n}, 20, 1000, function(){\n    console.log('finished');\n});\n\n```\n\n## 当前用户\n\n* 阿里妈妈MUX:[http://mux.alimama.com/event/2015mothersday/index.html](http://mux.alimama.com/event/2015mothersday/index.html)\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandycall%2Fcalculagraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandycall%2Fcalculagraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandycall%2Fcalculagraph/lists"}