-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wenqing
committed
Aug 16, 2023
1 parent
a9c89f8
commit 90009df
Showing
5 changed files
with
36 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"use strict";var d=Object.defineProperty;var p=(i,t,n)=>t in i?d(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var e=(i,t,n)=>(p(i,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=typeof window!="undefined";function m(i){return u?requestAnimationFrame(i):-1}function g(i){u&&cancelAnimationFrame(i)}const a=1e3,c=60*a,h=60*c,f=24*h;function T(i){const t=Math.floor(i/f),n=Math.floor(i%f/h),s=Math.floor(i%h/c),o=Math.floor(i%c/a),r=Math.floor(i%a);return{total:i,days:t,hours:n,minutes:s,seconds:o,milliseconds:r}}function M(i,t){return Math.floor(i/1e3)===Math.floor(t/1e3)}class l{constructor(t){e(this,"rafId",0);e(this,"endTime",0);e(this,"counting",!1);e(this,"remain",0);e(this,"options",{time:0,autoStart:!0});this.options=Object.assign(this.options,t),this.remain=this.options.time,this.options.autoStart&&this.start()}get current(){return T(this.remain)}getCurrentRemain(){return Math.max(this.endTime-Date.now(),0)}setRemain(t){var n,s,o,r;this.remain=t,(s=(n=this.options).onChange)==null||s.call(n,this.current),t===0&&(this.pause(),(r=(o=this.options).onFinish)==null||r.call(o)),this.render()}microTick(){this.rafId=m(()=>{this.counting&&(this.setRemain(this.getCurrentRemain()),this.remain>0&&this.microTick())})}macroTick(){this.rafId=m(()=>{if(this.counting){const t=this.getCurrentRemain();(!M(t,this.remain)||t===0)&&this.setRemain(t),this.remain>0&&this.macroTick()}})}tick(){u&&(this.options.millisecond?this.microTick():this.macroTick())}start(){this.counting||(this.endTime=Date.now()+this.remain,this.counting=!0,this.tick())}reset(t=this.options.time){this.pause(),this.remain=t}pause(){this.counting=!1,g(this.rafId)}generateHTML(){if(this.options.template)return this.options.template(this.current);let t=`${this.current.days}:${this.current.hours}:${this.current.minutes}:${this.current.seconds}`;return this.options.millisecond&&(t+=`:${this.current.milliseconds}`),`<span style="font-size:14px;color:#323233;">${t}</span>`}getContainer(){return typeof this.options.container=="string"?document.querySelector(this.options.container):this.options.container}render(){const t=this.getContainer();t&&(t.innerHTML=`${this.generateHTML()}`)}}const C=i=>new l(i);exports.CountdownBar=l;exports.createCountdownBar=C; | ||
"use strict";var d=Object.defineProperty;var p=(i,t,n)=>t in i?d(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var e=(i,t,n)=>(p(i,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("fourdom"),u=typeof window!="undefined";function m(i){return u?requestAnimationFrame(i):-1}function T(i){u&&cancelAnimationFrame(i)}const a=1e3,c=60*a,h=60*c,f=24*h;function M(i){const t=Math.floor(i/f),n=Math.floor(i%f/h),o=Math.floor(i%h/c),s=Math.floor(i%c/a),r=Math.floor(i%a);return{total:i,days:t,hours:n,minutes:o,seconds:s,milliseconds:r}}function C(i,t){return Math.floor(i/1e3)===Math.floor(t/1e3)}class l{constructor(t){e(this,"rafId",0);e(this,"endTime",0);e(this,"counting",!1);e(this,"remain",0);e(this,"options",{time:0,autoStart:!0,color:"#323233",fontSize:"14px"});this.options=Object.assign(this.options,t),this.remain=this.options.time,this.options.autoStart&&this.start()}get current(){return M(this.remain)}getCurrentRemain(){return Math.max(this.endTime-Date.now(),0)}setRemain(t){var n,o,s,r;this.remain=t,(o=(n=this.options).onChange)==null||o.call(n,this.current),t===0&&(this.pause(),(r=(s=this.options).onFinish)==null||r.call(s)),this.render()}microTick(){this.rafId=m(()=>{this.counting&&(this.setRemain(this.getCurrentRemain()),this.remain>0&&this.microTick())})}macroTick(){this.rafId=m(()=>{if(this.counting){const t=this.getCurrentRemain();(!C(t,this.remain)||t===0)&&this.setRemain(t),this.remain>0&&this.macroTick()}})}tick(){u&&(this.options.millisecond?this.microTick():this.macroTick())}start(){this.counting||(this.endTime=Date.now()+this.remain,this.counting=!0,this.tick())}reset(t=this.options.time){this.pause(),this.remain=t}pause(){this.counting=!1,T(this.rafId)}generateHTML(){if(this.options.template)return this.options.template(this.current);let t=`${this.current.days}:${this.current.hours}:${this.current.minutes}:${this.current.seconds}`;return this.options.millisecond&&(t+=`:${this.current.milliseconds}`),`<span>${t}</span>`}getContainer(){return typeof this.options.container=="string"?document.querySelector(this.options.container):this.options.container}render(){const t=this.getContainer();t&&(g.css(t,{"font-size":this.options.fontSize,color:this.options.color}),t.innerHTML=`${this.generateHTML()}`)}}const w=i=>new l(i);exports.CountdownBar=l;exports.createCountdownBar=w; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
(function(e,n){typeof exports=="object"&&typeof module!="undefined"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(e=typeof globalThis!="undefined"?globalThis:e||self,n(e.Countdownbar={}))})(this,function(e){"use strict";var C=Object.defineProperty;var w=(e,n,s)=>n in e?C(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var o=(e,n,s)=>(w(e,typeof n!="symbol"?n+"":n,s),s);const n=typeof window!="undefined";function s(i){return n?requestAnimationFrame(i):-1}function p(i){n&&cancelAnimationFrame(i)}const u=1e3,f=60*u,m=60*f,d=24*m;function g(i){const t=Math.floor(i/d),r=Math.floor(i%d/m),a=Math.floor(i%m/f),c=Math.floor(i%f/u),h=Math.floor(i%u);return{total:i,days:t,hours:r,minutes:a,seconds:c,milliseconds:h}}function T(i,t){return Math.floor(i/1e3)===Math.floor(t/1e3)}class l{constructor(t){o(this,"rafId",0);o(this,"endTime",0);o(this,"counting",!1);o(this,"remain",0);o(this,"options",{time:0,autoStart:!0});this.options=Object.assign(this.options,t),this.remain=this.options.time,this.options.autoStart&&this.start()}get current(){return g(this.remain)}getCurrentRemain(){return Math.max(this.endTime-Date.now(),0)}setRemain(t){var r,a,c,h;this.remain=t,(a=(r=this.options).onChange)==null||a.call(r,this.current),t===0&&(this.pause(),(h=(c=this.options).onFinish)==null||h.call(c)),this.render()}microTick(){this.rafId=s(()=>{this.counting&&(this.setRemain(this.getCurrentRemain()),this.remain>0&&this.microTick())})}macroTick(){this.rafId=s(()=>{if(this.counting){const t=this.getCurrentRemain();(!T(t,this.remain)||t===0)&&this.setRemain(t),this.remain>0&&this.macroTick()}})}tick(){n&&(this.options.millisecond?this.microTick():this.macroTick())}start(){this.counting||(this.endTime=Date.now()+this.remain,this.counting=!0,this.tick())}reset(t=this.options.time){this.pause(),this.remain=t}pause(){this.counting=!1,p(this.rafId)}generateHTML(){if(this.options.template)return this.options.template(this.current);let t=`${this.current.days}:${this.current.hours}:${this.current.minutes}:${this.current.seconds}`;return this.options.millisecond&&(t+=`:${this.current.milliseconds}`),`<span style="font-size:14px;color:#323233;">${t}</span>`}getContainer(){return typeof this.options.container=="string"?document.querySelector(this.options.container):this.options.container}render(){const t=this.getContainer();t&&(t.innerHTML=`${this.generateHTML()}`)}}const M=i=>new l(i);e.CountdownBar=l,e.createCountdownBar=M,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}); | ||
(function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("fourdom")):typeof define=="function"&&define.amd?define(["exports","fourdom"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.Countdownbar={},n.fourdom))})(this,function(n,e){"use strict";var w=Object.defineProperty;var S=(n,e,o)=>e in n?w(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o;var s=(n,e,o)=>(S(n,typeof e!="symbol"?e+"":e,o),o);const o=typeof window!="undefined";function d(i){return o?requestAnimationFrame(i):-1}function g(i){o&&cancelAnimationFrame(i)}const u=1e3,f=60*u,m=60*f,p=24*m;function T(i){const t=Math.floor(i/p),r=Math.floor(i%p/m),a=Math.floor(i%m/f),c=Math.floor(i%f/u),h=Math.floor(i%u);return{total:i,days:t,hours:r,minutes:a,seconds:c,milliseconds:h}}function M(i,t){return Math.floor(i/1e3)===Math.floor(t/1e3)}class l{constructor(t){s(this,"rafId",0);s(this,"endTime",0);s(this,"counting",!1);s(this,"remain",0);s(this,"options",{time:0,autoStart:!0,color:"#323233",fontSize:"14px"});this.options=Object.assign(this.options,t),this.remain=this.options.time,this.options.autoStart&&this.start()}get current(){return T(this.remain)}getCurrentRemain(){return Math.max(this.endTime-Date.now(),0)}setRemain(t){var r,a,c,h;this.remain=t,(a=(r=this.options).onChange)==null||a.call(r,this.current),t===0&&(this.pause(),(h=(c=this.options).onFinish)==null||h.call(c)),this.render()}microTick(){this.rafId=d(()=>{this.counting&&(this.setRemain(this.getCurrentRemain()),this.remain>0&&this.microTick())})}macroTick(){this.rafId=d(()=>{if(this.counting){const t=this.getCurrentRemain();(!M(t,this.remain)||t===0)&&this.setRemain(t),this.remain>0&&this.macroTick()}})}tick(){o&&(this.options.millisecond?this.microTick():this.macroTick())}start(){this.counting||(this.endTime=Date.now()+this.remain,this.counting=!0,this.tick())}reset(t=this.options.time){this.pause(),this.remain=t}pause(){this.counting=!1,g(this.rafId)}generateHTML(){if(this.options.template)return this.options.template(this.current);let t=`${this.current.days}:${this.current.hours}:${this.current.minutes}:${this.current.seconds}`;return this.options.millisecond&&(t+=`:${this.current.milliseconds}`),`<span>${t}</span>`}getContainer(){return typeof this.options.container=="string"?document.querySelector(this.options.container):this.options.container}render(){const t=this.getContainer();t&&(e.css(t,{"font-size":this.options.fontSize,color:this.options.color}),t.innerHTML=`${this.generateHTML()}`)}}const C=i=>new l(i);n.CountdownBar=l,n.createCountdownBar=C,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters