@oipage/core.js 0.1.0-alpha.0 → 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,7 +36,7 @@ import { animation } from "@oipage/core.js"
36
36
  当然,也可以单独引入:
37
37
 
38
38
  ```js
39
- import animation from "@oipage/core.js/src/animation/index"
39
+ import { animation } from "@oipage/core.js/src/animation/index"
40
40
  ```
41
41
 
42
42
  > 支持Typescript环境。
package/dist/corejs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @oipage/core.js v0.1.0-alpha.0
2
+ * @oipage/core.js v0.1.0-alpha.1
3
3
  * git+https://github.com/oi-contrib/core.js.git
4
4
  */
5
5
  (function (global, factory) {
@@ -23,7 +23,7 @@
23
23
  *
24
24
  * @returns {function} 返回一个函数,调用该函数,可以提前结束动画
25
25
  */
26
- function animation (doback, duration, callback) {
26
+ function animation(doback, duration, callback) {
27
27
  if (arguments.length < 2) duration = 400;
28
28
  if (arguments.length < 3) callback = function () { };
29
29
 
@@ -111,7 +111,7 @@
111
111
 
112
112
  }
113
113
 
114
- function throttle (callback, _option) {
114
+ function throttle(callback, _option) {
115
115
 
116
116
  // 缺省值
117
117
  var option = {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @oipage/core.js v0.1.0-alpha.0
2
+ * @oipage/core.js v0.1.0-alpha.1
3
3
  * git+https://github.com/oi-contrib/core.js.git
4
4
  */
5
5
  !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Corejs=e()}(this,(function(){"use strict";var t,e=[];var n={animation:function(n,i,r){arguments.length<2&&(i=400),arguments.length<3&&(r=function(){});var o={timer:function(t,n,i){if(!t)throw new Error("Tick is required!");var r=(new Date).valueOf()+"_"+(1e3*Math.random()).toFixed(0);return e.push({id:r,createTime:new Date,tick:t,duration:n,callback:i}),o.start(),r},start:function(){t||(t=setInterval(o.tick,13))},tick:function(){var t,n,i,r,a,u,f,l=e;for((e=[]).length=0,n=0;n<l.length;n++)t=(a=l[n]).createTime,i=a.tick,u=a.duration,r=a.callback,i(f=(f=(+(new Date).valueOf()-t.valueOf())/u)>1?1:f),f<1&&a.id?e.push(a):r(f);e.length<=0&&o.stop()},stop:function(){t&&(clearInterval(t),t=null)}},a=o.timer((function(t){n(t)}),i,r);return function(){var t;for(t in e)if(e[t].id==a)return void(e[t].id=void 0)}},throttle:function(t,e){var n={time:200,keep:!1,opportunity:"end"};if(e)for(var i in e)n[i]=e[i];var r,o=!1,a=!1,u=!1;return function(){const e=this;if(r=arguments,o)a=!0,u=!0;else{"end"!=n.opportunity&&t.apply(e,r),o=!0;var i=setInterval((()=>{a?n.keep||t.apply(e,r):("begin"!=n.opportunity&&(u||"end"==n.opportunity)&&t.apply(e,r),o=!1,u=!1,clearInterval(i)),a=!1}),n.time)}}}};return n}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oipage/core.js",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "0.1.0-alpha.1",
4
4
  "description": "前端开发常用基础&核心方法",
5
5
  "main": "dist/corejs.min.js",
6
6
  "typings": "./types/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "bugs": {
25
25
  "url": "https://github.com/oi-contrib/core.js/issues"
26
26
  },
27
- "homepage": "https://oi-contrib.github.io/core.js",
27
+ "homepage": "https://github.com/oi-contrib/core.js",
28
28
  "devDependencies": {
29
29
  "devby": "^0.7.0",
30
30
  "rollup": "^4.6.1",
@@ -5,6 +5,8 @@ interface animationFun {
5
5
  /**
6
6
  * 轮询动画,返回一个函数,调用该函数,可以提前结束动画
7
7
  */
8
- export default interface animationType {
8
+ export interface animationType {
9
9
  (doback: animationFun, duration?: number, callback?: animationFun): Function
10
- }
10
+ }
11
+
12
+ export let animation: animationType
@@ -13,7 +13,7 @@ var $timerId;
13
13
  *
14
14
  * @returns {function} 返回一个函数,调用该函数,可以提前结束动画
15
15
  */
16
- export default function (doback, duration, callback) {
16
+ export function animation(doback, duration, callback) {
17
17
  if (arguments.length < 2) duration = 400;
18
18
  if (arguments.length < 3) callback = function () { };
19
19
 
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import animation from "./animation/index.js";
2
- import throttle from "./throttle/index.js";
1
+ import { animation } from "./animation/index.js";
2
+ import { throttle } from "./throttle/index.js";
3
3
 
4
4
  export default {
5
5
  animation: animation,
@@ -24,6 +24,8 @@ export interface throttleOptionType {
24
24
  /**
25
25
  * 节流函数
26
26
  */
27
- export default interface throttle {
27
+ export interface throttleType {
28
28
  (callback: Function, option?: throttleOptionType): Function
29
- }
29
+ }
30
+
31
+ export let throttle: throttleType
@@ -1,4 +1,4 @@
1
- export default function (callback, _option) {
1
+ export function throttle(callback, _option) {
2
2
 
3
3
  // 缺省值
4
4
  var option = {
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import animationType from "../src/animation"
2
- import throttleType from "../src/throttle"
1
+ import { animationType } from "../src/animation"
2
+ import { throttleType } from "../src/throttle"
3
3
 
4
4
  export default class Corejs {
5
5
  static animation: animationType