1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434 |
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ProgressBar = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
- ;(function () {
- var root = this || Function('return this')();
- var Tweenable = (function () {
- 'use strict';
-
- var formula;
-
- var DEFAULT_SCHEDULE_FUNCTION;
- var DEFAULT_EASING = 'linear';
- var DEFAULT_DURATION = 500;
- var UPDATE_TIME = 1000 / 60;
- var _now = Date.now
- ? Date.now
- : function () {return +new Date();};
- var now = typeof SHIFTY_DEBUG_NOW !== 'undefined' ? SHIFTY_DEBUG_NOW : _now;
- if (typeof window !== 'undefined') {
-
-
- DEFAULT_SCHEDULE_FUNCTION = window.requestAnimationFrame
- || window.webkitRequestAnimationFrame
- || window.oRequestAnimationFrame
- || window.msRequestAnimationFrame
- || (window.mozCancelRequestAnimationFrame
- && window.mozRequestAnimationFrame)
- || setTimeout;
- } else {
- DEFAULT_SCHEDULE_FUNCTION = setTimeout;
- }
- function noop () {
-
- }
-
- function each (obj, fn) {
- var key;
- for (key in obj) {
- if (Object.hasOwnProperty.call(obj, key)) {
- fn(key);
- }
- }
- }
-
- function shallowCopy (targetObj, srcObj) {
- each(srcObj, function (prop) {
- targetObj[prop] = srcObj[prop];
- });
- return targetObj;
- }
-
- function defaults (target, src) {
- each(src, function (prop) {
- if (typeof target[prop] === 'undefined') {
- target[prop] = src[prop];
- }
- });
- }
-
- function tweenProps (forPosition, currentState, originalState, targetState,
- duration, timestamp, easing) {
- var normalizedPosition =
- forPosition < timestamp ? 0 : (forPosition - timestamp) / duration;
- var prop;
- var easingObjectProp;
- var easingFn;
- for (prop in currentState) {
- if (currentState.hasOwnProperty(prop)) {
- easingObjectProp = easing[prop];
- easingFn = typeof easingObjectProp === 'function'
- ? easingObjectProp
- : formula[easingObjectProp];
- currentState[prop] = tweenProp(
- originalState[prop],
- targetState[prop],
- easingFn,
- normalizedPosition
- );
- }
- }
- return currentState;
- }
-
- function tweenProp (start, end, easingFunc, position) {
- return start + (end - start) * easingFunc(position);
- }
-
- function applyFilter (tweenable, filterName) {
- var filters = Tweenable.prototype.filter;
- var args = tweenable._filterArgs;
- each(filters, function (name) {
- if (typeof filters[name][filterName] !== 'undefined') {
- filters[name][filterName].apply(tweenable, args);
- }
- });
- }
- var timeoutHandler_endTime;
- var timeoutHandler_currentTime;
- var timeoutHandler_isEnded;
- var timeoutHandler_offset;
-
- function timeoutHandler (tweenable, timestamp, delay, duration, currentState,
- originalState, targetState, easing, step, schedule,
- opt_currentTimeOverride) {
- timeoutHandler_endTime = timestamp + delay + duration;
- timeoutHandler_currentTime =
- Math.min(opt_currentTimeOverride || now(), timeoutHandler_endTime);
- timeoutHandler_isEnded =
- timeoutHandler_currentTime >= timeoutHandler_endTime;
- timeoutHandler_offset = duration - (
- timeoutHandler_endTime - timeoutHandler_currentTime);
- if (tweenable.isPlaying()) {
- if (timeoutHandler_isEnded) {
- step(targetState, tweenable._attachment, timeoutHandler_offset);
- tweenable.stop(true);
- } else {
- tweenable._scheduleId =
- schedule(tweenable._timeoutHandler, UPDATE_TIME);
- applyFilter(tweenable, 'beforeTween');
-
-
-
- if (timeoutHandler_currentTime < (timestamp + delay)) {
- tweenProps(1, currentState, originalState, targetState, 1, 1, easing);
- } else {
- tweenProps(timeoutHandler_currentTime, currentState, originalState,
- targetState, duration, timestamp + delay, easing);
- }
- applyFilter(tweenable, 'afterTween');
- step(currentState, tweenable._attachment, timeoutHandler_offset);
- }
- }
- }
-
- function composeEasingObject (fromTweenParams, easing) {
- var composedEasing = {};
- var typeofEasing = typeof easing;
- if (typeofEasing === 'string' || typeofEasing === 'function') {
- each(fromTweenParams, function (prop) {
- composedEasing[prop] = easing;
- });
- } else {
- each(fromTweenParams, function (prop) {
- if (!composedEasing[prop]) {
- composedEasing[prop] = easing[prop] || DEFAULT_EASING;
- }
- });
- }
- return composedEasing;
- }
-
- function Tweenable (opt_initialState, opt_config) {
- this._currentState = opt_initialState || {};
- this._configured = false;
- this._scheduleFunction = DEFAULT_SCHEDULE_FUNCTION;
-
-
-
- if (typeof opt_config !== 'undefined') {
- this.setConfig(opt_config);
- }
- }
-
- Tweenable.prototype.tween = function (opt_config) {
- if (this._isTweening) {
- return this;
- }
-
-
- if (opt_config !== undefined || !this._configured) {
- this.setConfig(opt_config);
- }
- this._timestamp = now();
- this._start(this.get(), this._attachment);
- return this.resume();
- };
-
- Tweenable.prototype.setConfig = function (config) {
- config = config || {};
- this._configured = true;
-
-
- this._attachment = config.attachment;
-
- this._pausedAtTime = null;
- this._scheduleId = null;
- this._delay = config.delay || 0;
- this._start = config.start || noop;
- this._step = config.step || noop;
- this._finish = config.finish || noop;
- this._duration = config.duration || DEFAULT_DURATION;
- this._currentState = shallowCopy({}, config.from) || this.get();
- this._originalState = this.get();
- this._targetState = shallowCopy({}, config.to) || this.get();
- var self = this;
- this._timeoutHandler = function () {
- timeoutHandler(self,
- self._timestamp,
- self._delay,
- self._duration,
- self._currentState,
- self._originalState,
- self._targetState,
- self._easing,
- self._step,
- self._scheduleFunction
- );
- };
-
- var currentState = this._currentState;
- var targetState = this._targetState;
-
- defaults(targetState, currentState);
- this._easing = composeEasingObject(
- currentState, config.easing || DEFAULT_EASING);
- this._filterArgs =
- [currentState, this._originalState, targetState, this._easing];
- applyFilter(this, 'tweenCreated');
- return this;
- };
-
- Tweenable.prototype.get = function () {
- return shallowCopy({}, this._currentState);
- };
-
- Tweenable.prototype.set = function (state) {
- this._currentState = state;
- };
-
- Tweenable.prototype.pause = function () {
- this._pausedAtTime = now();
- this._isPaused = true;
- return this;
- };
-
- Tweenable.prototype.resume = function () {
- if (this._isPaused) {
- this._timestamp += now() - this._pausedAtTime;
- }
- this._isPaused = false;
- this._isTweening = true;
- this._timeoutHandler();
- return this;
- };
-
- Tweenable.prototype.seek = function (millisecond) {
- millisecond = Math.max(millisecond, 0);
- var currentTime = now();
- if ((this._timestamp + millisecond) === 0) {
- return this;
- }
- this._timestamp = currentTime - millisecond;
- if (!this.isPlaying()) {
- this._isTweening = true;
- this._isPaused = false;
-
-
- timeoutHandler(this,
- this._timestamp,
- this._delay,
- this._duration,
- this._currentState,
- this._originalState,
- this._targetState,
- this._easing,
- this._step,
- this._scheduleFunction,
- currentTime
- );
- this.pause();
- }
- return this;
- };
-
- Tweenable.prototype.stop = function (gotoEnd) {
- this._isTweening = false;
- this._isPaused = false;
- this._timeoutHandler = noop;
- (root.cancelAnimationFrame ||
- root.webkitCancelAnimationFrame ||
- root.oCancelAnimationFrame ||
- root.msCancelAnimationFrame ||
- root.mozCancelRequestAnimationFrame ||
- root.clearTimeout)(this._scheduleId);
- if (gotoEnd) {
- applyFilter(this, 'beforeTween');
- tweenProps(
- 1,
- this._currentState,
- this._originalState,
- this._targetState,
- 1,
- 0,
- this._easing
- );
- applyFilter(this, 'afterTween');
- applyFilter(this, 'afterTweenEnd');
- this._finish.call(this, this._currentState, this._attachment);
- }
- return this;
- };
-
- Tweenable.prototype.isPlaying = function () {
- return this._isTweening && !this._isPaused;
- };
-
- Tweenable.prototype.setScheduleFunction = function (scheduleFunction) {
- this._scheduleFunction = scheduleFunction;
- };
-
- Tweenable.prototype.dispose = function () {
- var prop;
- for (prop in this) {
- if (this.hasOwnProperty(prop)) {
- delete this[prop];
- }
- }
- };
-
- Tweenable.prototype.filter = {};
-
- Tweenable.prototype.formula = {
- linear: function (pos) {
- return pos;
- }
- };
- formula = Tweenable.prototype.formula;
- shallowCopy(Tweenable, {
- 'now': now
- ,'each': each
- ,'tweenProps': tweenProps
- ,'tweenProp': tweenProp
- ,'applyFilter': applyFilter
- ,'shallowCopy': shallowCopy
- ,'defaults': defaults
- ,'composeEasingObject': composeEasingObject
- });
-
-
- if (typeof SHIFTY_DEBUG_NOW === 'function') {
- root.timeoutHandler = timeoutHandler;
- }
-
- if (typeof exports === 'object') {
-
- module.exports = Tweenable;
- } else if (typeof define === 'function' && define.amd) {
-
- define(function () {return Tweenable;});
- } else if (typeof root.Tweenable === 'undefined') {
-
- root.Tweenable = Tweenable;
- }
- return Tweenable;
- } ());
- ;(function () {
- Tweenable.shallowCopy(Tweenable.prototype.formula, {
- easeInQuad: function (pos) {
- return Math.pow(pos, 2);
- },
- easeOutQuad: function (pos) {
- return -(Math.pow((pos - 1), 2) - 1);
- },
- easeInOutQuad: function (pos) {
- if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,2);}
- return -0.5 * ((pos -= 2) * pos - 2);
- },
- easeInCubic: function (pos) {
- return Math.pow(pos, 3);
- },
- easeOutCubic: function (pos) {
- return (Math.pow((pos - 1), 3) + 1);
- },
- easeInOutCubic: function (pos) {
- if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,3);}
- return 0.5 * (Math.pow((pos - 2),3) + 2);
- },
- easeInQuart: function (pos) {
- return Math.pow(pos, 4);
- },
- easeOutQuart: function (pos) {
- return -(Math.pow((pos - 1), 4) - 1);
- },
- easeInOutQuart: function (pos) {
- if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,4);}
- return -0.5 * ((pos -= 2) * Math.pow(pos,3) - 2);
- },
- easeInQuint: function (pos) {
- return Math.pow(pos, 5);
- },
- easeOutQuint: function (pos) {
- return (Math.pow((pos - 1), 5) + 1);
- },
- easeInOutQuint: function (pos) {
- if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,5);}
- return 0.5 * (Math.pow((pos - 2),5) + 2);
- },
- easeInSine: function (pos) {
- return -Math.cos(pos * (Math.PI / 2)) + 1;
- },
- easeOutSine: function (pos) {
- return Math.sin(pos * (Math.PI / 2));
- },
- easeInOutSine: function (pos) {
- return (-0.5 * (Math.cos(Math.PI * pos) - 1));
- },
- easeInExpo: function (pos) {
- return (pos === 0) ? 0 : Math.pow(2, 10 * (pos - 1));
- },
- easeOutExpo: function (pos) {
- return (pos === 1) ? 1 : -Math.pow(2, -10 * pos) + 1;
- },
- easeInOutExpo: function (pos) {
- if (pos === 0) {return 0;}
- if (pos === 1) {return 1;}
- if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(2,10 * (pos - 1));}
- return 0.5 * (-Math.pow(2, -10 * --pos) + 2);
- },
- easeInCirc: function (pos) {
- return -(Math.sqrt(1 - (pos * pos)) - 1);
- },
- easeOutCirc: function (pos) {
- return Math.sqrt(1 - Math.pow((pos - 1), 2));
- },
- easeInOutCirc: function (pos) {
- if ((pos /= 0.5) < 1) {return -0.5 * (Math.sqrt(1 - pos * pos) - 1);}
- return 0.5 * (Math.sqrt(1 - (pos -= 2) * pos) + 1);
- },
- easeOutBounce: function (pos) {
- if ((pos) < (1 / 2.75)) {
- return (7.5625 * pos * pos);
- } else if (pos < (2 / 2.75)) {
- return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
- } else if (pos < (2.5 / 2.75)) {
- return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
- } else {
- return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
- }
- },
- easeInBack: function (pos) {
- var s = 1.70158;
- return (pos) * pos * ((s + 1) * pos - s);
- },
- easeOutBack: function (pos) {
- var s = 1.70158;
- return (pos = pos - 1) * pos * ((s + 1) * pos + s) + 1;
- },
- easeInOutBack: function (pos) {
- var s = 1.70158;
- if ((pos /= 0.5) < 1) {
- return 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s));
- }
- return 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
- },
- elastic: function (pos) {
-
- return -1 * Math.pow(4,-8 * pos) * Math.sin((pos * 6 - 1) * (2 * Math.PI) / 2) + 1;
- },
- swingFromTo: function (pos) {
- var s = 1.70158;
- return ((pos /= 0.5) < 1) ?
- 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s)) :
- 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
- },
- swingFrom: function (pos) {
- var s = 1.70158;
- return pos * pos * ((s + 1) * pos - s);
- },
- swingTo: function (pos) {
- var s = 1.70158;
- return (pos -= 1) * pos * ((s + 1) * pos + s) + 1;
- },
- bounce: function (pos) {
- if (pos < (1 / 2.75)) {
- return (7.5625 * pos * pos);
- } else if (pos < (2 / 2.75)) {
- return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
- } else if (pos < (2.5 / 2.75)) {
- return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
- } else {
- return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
- }
- },
- bouncePast: function (pos) {
- if (pos < (1 / 2.75)) {
- return (7.5625 * pos * pos);
- } else if (pos < (2 / 2.75)) {
- return 2 - (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
- } else if (pos < (2.5 / 2.75)) {
- return 2 - (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
- } else {
- return 2 - (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
- }
- },
- easeFromTo: function (pos) {
- if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,4);}
- return -0.5 * ((pos -= 2) * Math.pow(pos,3) - 2);
- },
- easeFrom: function (pos) {
- return Math.pow(pos,4);
- },
- easeTo: function (pos) {
- return Math.pow(pos,0.25);
- }
- });
- }());
- ;(function () {
-
- function cubicBezierAtTime(t,p1x,p1y,p2x,p2y,duration) {
- var ax = 0,bx = 0,cx = 0,ay = 0,by = 0,cy = 0;
- function sampleCurveX(t) {
- return ((ax * t + bx) * t + cx) * t;
- }
- function sampleCurveY(t) {
- return ((ay * t + by) * t + cy) * t;
- }
- function sampleCurveDerivativeX(t) {
- return (3.0 * ax * t + 2.0 * bx) * t + cx;
- }
- function solveEpsilon(duration) {
- return 1.0 / (200.0 * duration);
- }
- function solve(x,epsilon) {
- return sampleCurveY(solveCurveX(x, epsilon));
- }
- function fabs(n) {
- if (n >= 0) {
- return n;
- } else {
- return 0 - n;
- }
- }
- function solveCurveX(x, epsilon) {
- var t0,t1,t2,x2,d2,i;
- for (t2 = x, i = 0; i < 8; i++) {
- x2 = sampleCurveX(t2) - x;
- if (fabs(x2) < epsilon) {
- return t2;
- }
- d2 = sampleCurveDerivativeX(t2);
- if (fabs(d2) < 1e-6) {
- break;
- }
- t2 = t2 - x2 / d2;
- }
- t0 = 0.0;
- t1 = 1.0;
- t2 = x;
- if (t2 < t0) {
- return t0;
- }
- if (t2 > t1) {
- return t1;
- }
- while (t0 < t1) {
- x2 = sampleCurveX(t2);
- if (fabs(x2 - x) < epsilon) {
- return t2;
- }
- if (x > x2) {
- t0 = t2;
- }else {
- t1 = t2;
- }
- t2 = (t1 - t0) * 0.5 + t0;
- }
- return t2;
- }
- cx = 3.0 * p1x;
- bx = 3.0 * (p2x - p1x) - cx;
- ax = 1.0 - cx - bx;
- cy = 3.0 * p1y;
- by = 3.0 * (p2y - p1y) - cy;
- ay = 1.0 - cy - by;
- return solve(t, solveEpsilon(duration));
- }
-
- function getCubicBezierTransition (x1, y1, x2, y2) {
- return function (pos) {
- return cubicBezierAtTime(pos,x1,y1,x2,y2,1);
- };
- }
-
-
- Tweenable.setBezierFunction = function (name, x1, y1, x2, y2) {
- var cubicBezierTransition = getCubicBezierTransition(x1, y1, x2, y2);
- cubicBezierTransition.displayName = name;
- cubicBezierTransition.x1 = x1;
- cubicBezierTransition.y1 = y1;
- cubicBezierTransition.x2 = x2;
- cubicBezierTransition.y2 = y2;
- return Tweenable.prototype.formula[name] = cubicBezierTransition;
- };
-
- Tweenable.unsetBezierFunction = function (name) {
- delete Tweenable.prototype.formula[name];
- };
- })();
- ;(function () {
- function getInterpolatedValues (
- from, current, targetState, position, easing, delay) {
- return Tweenable.tweenProps(
- position, current, from, targetState, 1, delay, easing);
- }
-
-
-
- var mockTweenable = new Tweenable();
- mockTweenable._filterArgs = [];
-
- Tweenable.interpolate = function (
- from, targetState, position, easing, opt_delay) {
- var current = Tweenable.shallowCopy({}, from);
- var delay = opt_delay || 0;
- var easingObject = Tweenable.composeEasingObject(
- from, easing || 'linear');
- mockTweenable.set({});
-
- var filterArgs = mockTweenable._filterArgs;
- filterArgs.length = 0;
- filterArgs[0] = current;
- filterArgs[1] = from;
- filterArgs[2] = targetState;
- filterArgs[3] = easingObject;
-
- Tweenable.applyFilter(mockTweenable, 'tweenCreated');
- Tweenable.applyFilter(mockTweenable, 'beforeTween');
- var interpolatedValues = getInterpolatedValues(
- from, current, targetState, position, easingObject, delay);
-
- Tweenable.applyFilter(mockTweenable, 'afterTween');
- return interpolatedValues;
- };
- }());
- ;(function (Tweenable) {
-
- var formatManifest;
-
- var R_NUMBER_COMPONENT = /(\d|\-|\.)/;
- var R_FORMAT_CHUNKS = /([^\-0-9\.]+)/g;
- var R_UNFORMATTED_VALUES = /[0-9.\-]+/g;
- var R_RGB = new RegExp(
- 'rgb\\(' + R_UNFORMATTED_VALUES.source +
- (/,\s*/.source) + R_UNFORMATTED_VALUES.source +
- (/,\s*/.source) + R_UNFORMATTED_VALUES.source + '\\)', 'g');
- var R_RGB_PREFIX = /^.*\(/;
- var R_HEX = /#([0-9]|[a-f]){3,6}/gi;
- var VALUE_PLACEHOLDER = 'VAL';
-
-
- function getFormatChunksFrom (rawValues, prefix) {
- var accumulator = [];
- var rawValuesLength = rawValues.length;
- var i;
- for (i = 0; i < rawValuesLength; i++) {
- accumulator.push('_' + prefix + '_' + i);
- }
- return accumulator;
- }
-
- function getFormatStringFrom (formattedString) {
- var chunks = formattedString.match(R_FORMAT_CHUNKS);
- if (!chunks) {
-
-
-
- chunks = ['', ''];
-
-
-
- } else if (chunks.length === 1 ||
-
-
- formattedString[0].match(R_NUMBER_COMPONENT)) {
-
-
- chunks.unshift('');
- }
- return chunks.join(VALUE_PLACEHOLDER);
- }
-
- function sanitizeObjectForHexProps (stateObject) {
- Tweenable.each(stateObject, function (prop) {
- var currentProp = stateObject[prop];
- if (typeof currentProp === 'string' && currentProp.match(R_HEX)) {
- stateObject[prop] = sanitizeHexChunksToRGB(currentProp);
- }
- });
- }
-
- function sanitizeHexChunksToRGB (str) {
- return filterStringChunks(R_HEX, str, convertHexToRGB);
- }
-
- function convertHexToRGB (hexString) {
- var rgbArr = hexToRGBArray(hexString);
- return 'rgb(' + rgbArr[0] + ',' + rgbArr[1] + ',' + rgbArr[2] + ')';
- }
- var hexToRGBArray_returnArray = [];
-
- function hexToRGBArray (hex) {
- hex = hex.replace(/#/, '');
-
-
- if (hex.length === 3) {
- hex = hex.split('');
- hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
- }
- hexToRGBArray_returnArray[0] = hexToDec(hex.substr(0, 2));
- hexToRGBArray_returnArray[1] = hexToDec(hex.substr(2, 2));
- hexToRGBArray_returnArray[2] = hexToDec(hex.substr(4, 2));
- return hexToRGBArray_returnArray;
- }
-
- function hexToDec (hex) {
- return parseInt(hex, 16);
- }
-
- function filterStringChunks (pattern, unfilteredString, filter) {
- var pattenMatches = unfilteredString.match(pattern);
- var filteredString = unfilteredString.replace(pattern, VALUE_PLACEHOLDER);
- if (pattenMatches) {
- var pattenMatchesLength = pattenMatches.length;
- var currentChunk;
- for (var i = 0; i < pattenMatchesLength; i++) {
- currentChunk = pattenMatches.shift();
- filteredString = filteredString.replace(
- VALUE_PLACEHOLDER, filter(currentChunk));
- }
- }
- return filteredString;
- }
-
- function sanitizeRGBChunks (formattedString) {
- return filterStringChunks(R_RGB, formattedString, sanitizeRGBChunk);
- }
-
- function sanitizeRGBChunk (rgbChunk) {
- var numbers = rgbChunk.match(R_UNFORMATTED_VALUES);
- var numbersLength = numbers.length;
- var sanitizedString = rgbChunk.match(R_RGB_PREFIX)[0];
- for (var i = 0; i < numbersLength; i++) {
- sanitizedString += parseInt(numbers[i], 10) + ',';
- }
- sanitizedString = sanitizedString.slice(0, -1) + ')';
- return sanitizedString;
- }
-
- function getFormatManifests (stateObject) {
- var manifestAccumulator = {};
- Tweenable.each(stateObject, function (prop) {
- var currentProp = stateObject[prop];
- if (typeof currentProp === 'string') {
- var rawValues = getValuesFrom(currentProp);
- manifestAccumulator[prop] = {
- 'formatString': getFormatStringFrom(currentProp)
- ,'chunkNames': getFormatChunksFrom(rawValues, prop)
- };
- }
- });
- return manifestAccumulator;
- }
-
- function expandFormattedProperties (stateObject, formatManifests) {
- Tweenable.each(formatManifests, function (prop) {
- var currentProp = stateObject[prop];
- var rawValues = getValuesFrom(currentProp);
- var rawValuesLength = rawValues.length;
- for (var i = 0; i < rawValuesLength; i++) {
- stateObject[formatManifests[prop].chunkNames[i]] = +rawValues[i];
- }
- delete stateObject[prop];
- });
- }
-
- function collapseFormattedProperties (stateObject, formatManifests) {
- Tweenable.each(formatManifests, function (prop) {
- var currentProp = stateObject[prop];
- var formatChunks = extractPropertyChunks(
- stateObject, formatManifests[prop].chunkNames);
- var valuesList = getValuesList(
- formatChunks, formatManifests[prop].chunkNames);
- currentProp = getFormattedValues(
- formatManifests[prop].formatString, valuesList);
- stateObject[prop] = sanitizeRGBChunks(currentProp);
- });
- }
-
- function extractPropertyChunks (stateObject, chunkNames) {
- var extractedValues = {};
- var currentChunkName, chunkNamesLength = chunkNames.length;
- for (var i = 0; i < chunkNamesLength; i++) {
- currentChunkName = chunkNames[i];
- extractedValues[currentChunkName] = stateObject[currentChunkName];
- delete stateObject[currentChunkName];
- }
- return extractedValues;
- }
- var getValuesList_accumulator = [];
-
- function getValuesList (stateObject, chunkNames) {
- getValuesList_accumulator.length = 0;
- var chunkNamesLength = chunkNames.length;
- for (var i = 0; i < chunkNamesLength; i++) {
- getValuesList_accumulator.push(stateObject[chunkNames[i]]);
- }
- return getValuesList_accumulator;
- }
-
- function getFormattedValues (formatString, rawValues) {
- var formattedValueString = formatString;
- var rawValuesLength = rawValues.length;
- for (var i = 0; i < rawValuesLength; i++) {
- formattedValueString = formattedValueString.replace(
- VALUE_PLACEHOLDER, +rawValues[i].toFixed(4));
- }
- return formattedValueString;
- }
-
- function getValuesFrom (formattedString) {
- return formattedString.match(R_UNFORMATTED_VALUES);
- }
-
- function expandEasingObject (easingObject, tokenData) {
- Tweenable.each(tokenData, function (prop) {
- var currentProp = tokenData[prop];
- var chunkNames = currentProp.chunkNames;
- var chunkLength = chunkNames.length;
- var easing = easingObject[prop];
- var i;
- if (typeof easing === 'string') {
- var easingChunks = easing.split(' ');
- var lastEasingChunk = easingChunks[easingChunks.length - 1];
- for (i = 0; i < chunkLength; i++) {
- easingObject[chunkNames[i]] = easingChunks[i] || lastEasingChunk;
- }
- } else {
- for (i = 0; i < chunkLength; i++) {
- easingObject[chunkNames[i]] = easing;
- }
- }
- delete easingObject[prop];
- });
- }
-
- function collapseEasingObject (easingObject, tokenData) {
- Tweenable.each(tokenData, function (prop) {
- var currentProp = tokenData[prop];
- var chunkNames = currentProp.chunkNames;
- var chunkLength = chunkNames.length;
- var firstEasing = easingObject[chunkNames[0]];
- var typeofEasings = typeof firstEasing;
- if (typeofEasings === 'string') {
- var composedEasingString = '';
- for (var i = 0; i < chunkLength; i++) {
- composedEasingString += ' ' + easingObject[chunkNames[i]];
- delete easingObject[chunkNames[i]];
- }
- easingObject[prop] = composedEasingString.substr(1);
- } else {
- easingObject[prop] = firstEasing;
- }
- });
- }
- Tweenable.prototype.filter.token = {
- 'tweenCreated': function (currentState, fromState, toState, easingObject) {
- sanitizeObjectForHexProps(currentState);
- sanitizeObjectForHexProps(fromState);
- sanitizeObjectForHexProps(toState);
- this._tokenData = getFormatManifests(currentState);
- },
- 'beforeTween': function (currentState, fromState, toState, easingObject) {
- expandEasingObject(easingObject, this._tokenData);
- expandFormattedProperties(currentState, this._tokenData);
- expandFormattedProperties(fromState, this._tokenData);
- expandFormattedProperties(toState, this._tokenData);
- },
- 'afterTween': function (currentState, fromState, toState, easingObject) {
- collapseFormattedProperties(currentState, this._tokenData);
- collapseFormattedProperties(fromState, this._tokenData);
- collapseFormattedProperties(toState, this._tokenData);
- collapseEasingObject(easingObject, this._tokenData);
- }
- };
- } (Tweenable));
- }).call(null);
- },{}],2:[function(require,module,exports){
- var Shape = require('./shape');
- var utils = require('./utils');
- var Circle = function Circle(container, options) {
-
-
- this._pathTemplate =
- 'M 50,50 m 0,-{radius}' +
- ' a {radius},{radius} 0 1 1 0,{2radius}' +
- ' a {radius},{radius} 0 1 1 0,-{2radius}';
- this.containerAspectRatio = 1;
- Shape.apply(this, arguments);
- };
- Circle.prototype = new Shape();
- Circle.prototype.constructor = Circle;
- Circle.prototype._pathString = function _pathString(opts) {
- var widthOfWider = opts.strokeWidth;
- if (opts.trailWidth && opts.trailWidth > opts.strokeWidth) {
- widthOfWider = opts.trailWidth;
- }
- var r = 50 - widthOfWider / 2;
- return utils.render(this._pathTemplate, {
- radius: r,
- '2radius': r * 2
- });
- };
- Circle.prototype._trailString = function _trailString(opts) {
- return this._pathString(opts);
- };
- module.exports = Circle;
- },{"./shape":7,"./utils":8}],3:[function(require,module,exports){
- var Shape = require('./shape');
- var utils = require('./utils');
- var Line = function Line(container, options) {
- this._pathTemplate = 'M 0,{center} L 100,{center}';
- Shape.apply(this, arguments);
- };
- Line.prototype = new Shape();
- Line.prototype.constructor = Line;
- Line.prototype._initializeSvg = function _initializeSvg(svg, opts) {
- svg.setAttribute('viewBox', '0 0 100 ' + opts.strokeWidth);
- svg.setAttribute('preserveAspectRatio', 'none');
- };
- Line.prototype._pathString = function _pathString(opts) {
- return utils.render(this._pathTemplate, {
- center: opts.strokeWidth / 2
- });
- };
- Line.prototype._trailString = function _trailString(opts) {
- return this._pathString(opts);
- };
- module.exports = Line;
- },{"./shape":7,"./utils":8}],4:[function(require,module,exports){
- module.exports = {
-
- Line: require('./line'),
- Circle: require('./circle'),
- SemiCircle: require('./semicircle'),
-
- Path: require('./path'),
-
-
-
- Shape: require('./shape'),
-
- utils: require('./utils')
- };
- },{"./circle":2,"./line":3,"./path":5,"./semicircle":6,"./shape":7,"./utils":8}],5:[function(require,module,exports){
- var Tweenable = require('shifty');
- var utils = require('./utils');
- var EASING_ALIASES = {
- easeIn: 'easeInCubic',
- easeOut: 'easeOutCubic',
- easeInOut: 'easeInOutCubic'
- };
- var Path = function Path(path, opts) {
-
- if (!(this instanceof Path)) {
- throw new Error('Constructor was called without new keyword');
- }
-
- opts = utils.extend({
- duration: 800,
- easing: 'linear',
- from: {},
- to: {},
- step: function() {}
- }, opts);
- var element;
- if (utils.isString(path)) {
- element = document.querySelector(path);
- } else {
- element = path;
- }
-
- this.path = element;
- this._opts = opts;
- this._tweenable = null;
-
- var length = this.path.getTotalLength();
- this.path.style.strokeDasharray = length + ' ' + length;
- this.set(0);
- };
- Path.prototype.value = function value() {
- var offset = this._getComputedDashOffset();
- var length = this.path.getTotalLength();
- var progress = 1 - offset / length;
-
-
- return parseFloat(progress.toFixed(6), 10);
- };
- Path.prototype.set = function set(progress) {
- this.stop();
- this.path.style.strokeDashoffset = this._progressToOffset(progress);
- var step = this._opts.step;
- if (utils.isFunction(step)) {
- var easing = this._easing(this._opts.easing);
- var values = this._calculateTo(progress, easing);
- var reference = this._opts.shape || this;
- step(values, reference, this._opts.attachment);
- }
- };
- Path.prototype.stop = function stop() {
- this._stopTween();
- this.path.style.strokeDashoffset = this._getComputedDashOffset();
- };
- Path.prototype.animate = function animate(progress, opts, cb) {
- opts = opts || {};
- if (utils.isFunction(opts)) {
- cb = opts;
- opts = {};
- }
- var passedOpts = utils.extend({}, opts);
-
- var defaultOpts = utils.extend({}, this._opts);
- opts = utils.extend(defaultOpts, opts);
- var shiftyEasing = this._easing(opts.easing);
- var values = this._resolveFromAndTo(progress, shiftyEasing, passedOpts);
- this.stop();
-
-
- this.path.getBoundingClientRect();
- var offset = this._getComputedDashOffset();
- var newOffset = this._progressToOffset(progress);
- var self = this;
- this._tweenable = new Tweenable();
- this._tweenable.tween({
- from: utils.extend({ offset: offset }, values.from),
- to: utils.extend({ offset: newOffset }, values.to),
- duration: opts.duration,
- easing: shiftyEasing,
- step: function(state) {
- self.path.style.strokeDashoffset = state.offset;
- var reference = opts.shape || self;
- opts.step(state, reference, opts.attachment);
- },
- finish: function(state) {
- if (utils.isFunction(cb)) {
- cb();
- }
- }
- });
- };
- Path.prototype._getComputedDashOffset = function _getComputedDashOffset() {
- var computedStyle = window.getComputedStyle(this.path, null);
- return parseFloat(computedStyle.getPropertyValue('stroke-dashoffset'), 10);
- };
- Path.prototype._progressToOffset = function _progressToOffset(progress) {
- var length = this.path.getTotalLength();
- return length - progress * length;
- };
- Path.prototype._resolveFromAndTo = function _resolveFromAndTo(progress, easing, opts) {
- if (opts.from && opts.to) {
- return {
- from: opts.from,
- to: opts.to
- };
- }
- return {
- from: this._calculateFrom(easing),
- to: this._calculateTo(progress, easing)
- };
- };
- Path.prototype._calculateFrom = function _calculateFrom(easing) {
- return Tweenable.interpolate(this._opts.from, this._opts.to, this.value(), easing);
- };
- Path.prototype._calculateTo = function _calculateTo(progress, easing) {
- return Tweenable.interpolate(this._opts.from, this._opts.to, progress, easing);
- };
- Path.prototype._stopTween = function _stopTween() {
- if (this._tweenable !== null) {
- this._tweenable.stop();
- this._tweenable = null;
- }
- };
- Path.prototype._easing = function _easing(easing) {
- if (EASING_ALIASES.hasOwnProperty(easing)) {
- return EASING_ALIASES[easing];
- }
- return easing;
- };
- module.exports = Path;
- },{"./utils":8,"shifty":1}],6:[function(require,module,exports){
- var Shape = require('./shape');
- var Circle = require('./circle');
- var utils = require('./utils');
- var SemiCircle = function SemiCircle(container, options) {
-
-
- this._pathTemplate =
- 'M 50,50 m -{radius},0' +
- ' a {radius},{radius} 0 1 1 {2radius},0';
- this.containerAspectRatio = 2;
- Shape.apply(this, arguments);
- };
- SemiCircle.prototype = new Shape();
- SemiCircle.prototype.constructor = SemiCircle;
- SemiCircle.prototype._initializeSvg = function _initializeSvg(svg, opts) {
- svg.setAttribute('viewBox', '0 0 100 50');
- };
- SemiCircle.prototype._initializeTextContainer = function _initializeTextContainer(
- opts,
- container,
- textContainer
- ) {
- if (opts.text.style) {
-
- textContainer.style.top = 'auto';
- textContainer.style.bottom = '0';
- if (opts.text.alignToBottom) {
- utils.setStyle(textContainer, 'transform', 'translate(-50%, 0)');
- } else {
- utils.setStyle(textContainer, 'transform', 'translate(-50%, 50%)');
- }
- }
- };
- SemiCircle.prototype._pathString = Circle.prototype._pathString;
- SemiCircle.prototype._trailString = Circle.prototype._trailString;
- module.exports = SemiCircle;
- },{"./circle":2,"./shape":7,"./utils":8}],7:[function(require,module,exports){
- var Path = require('./path');
- var utils = require('./utils');
- var DESTROYED_ERROR = 'Object is destroyed';
- var Shape = function Shape(container, opts) {
-
-
- if (!(this instanceof Shape)) {
- throw new Error('Constructor was called without new keyword');
- }
-
-
-
-
-
-
- if (arguments.length === 0) {
- return;
- }
-
- this._opts = utils.extend({
- color: '#555',
- strokeWidth: 1.0,
- trailColor: null,
- trailWidth: null,
- fill: null,
- text: {
- style: {
- color: null,
- position: 'absolute',
- left: '50%',
- top: '50%',
- padding: 0,
- margin: 0,
- transform: {
- prefix: true,
- value: 'translate(-50%, -50%)'
- }
- },
- autoStyleContainer: true,
- alignToBottom: true,
- value: null,
- className: 'progressbar-text'
- },
- svgStyle: {
- display: 'block',
- width: '100%'
- },
- warnings: false
- }, opts, true);
-
-
- if (utils.isObject(opts) && opts.svgStyle !== undefined) {
- this._opts.svgStyle = opts.svgStyle;
- }
- if (utils.isObject(opts) && utils.isObject(opts.text) && opts.text.style !== undefined) {
- this._opts.text.style = opts.text.style;
- }
- var svgView = this._createSvgView(this._opts);
- var element;
- if (utils.isString(container)) {
- element = document.querySelector(container);
- } else {
- element = container;
- }
- if (!element) {
- throw new Error('Container does not exist: ' + container);
- }
- this._container = element;
- this._container.appendChild(svgView.svg);
- if (this._opts.warnings) {
- this._warnContainerAspectRatio(this._container);
- }
- if (this._opts.svgStyle) {
- utils.setStyles(svgView.svg, this._opts.svgStyle);
- }
-
- this.svg = svgView.svg;
- this.path = svgView.path;
- this.trail = svgView.trail;
- this.text = null;
- var newOpts = utils.extend({
- attachment: undefined,
- shape: this
- }, this._opts);
- this._progressPath = new Path(svgView.path, newOpts);
- if (utils.isObject(this._opts.text) && this._opts.text.value !== null) {
- this.setText(this._opts.text.value);
- }
- };
- Shape.prototype.animate = function animate(progress, opts, cb) {
- if (this._progressPath === null) {
- throw new Error(DESTROYED_ERROR);
- }
- this._progressPath.animate(progress, opts, cb);
- };
- Shape.prototype.stop = function stop() {
- if (this._progressPath === null) {
- throw new Error(DESTROYED_ERROR);
- }
-
- if (this._progressPath === undefined) {
- return;
- }
- this._progressPath.stop();
- };
- Shape.prototype.destroy = function destroy() {
- if (this._progressPath === null) {
- throw new Error(DESTROYED_ERROR);
- }
- this.stop();
- this.svg.parentNode.removeChild(this.svg);
- this.svg = null;
- this.path = null;
- this.trail = null;
- this._progressPath = null;
- if (this.text !== null) {
- this.text.parentNode.removeChild(this.text);
- this.text = null;
- }
- };
- Shape.prototype.set = function set(progress) {
- if (this._progressPath === null) {
- throw new Error(DESTROYED_ERROR);
- }
- this._progressPath.set(progress);
- };
- Shape.prototype.value = function value() {
- if (this._progressPath === null) {
- throw new Error(DESTROYED_ERROR);
- }
- if (this._progressPath === undefined) {
- return 0;
- }
- return this._progressPath.value();
- };
- Shape.prototype.setText = function setText(newText) {
- if (this._progressPath === null) {
- throw new Error(DESTROYED_ERROR);
- }
- if (this.text === null) {
-
- this.text = this._createTextContainer(this._opts, this._container);
- this._container.appendChild(this.text);
- }
-
- if (utils.isObject(newText)) {
- utils.removeChildren(this.text);
- this.text.appendChild(newText);
- } else {
- this.text.innerHTML = newText;
- }
- };
- Shape.prototype._createSvgView = function _createSvgView(opts) {
- var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
- this._initializeSvg(svg, opts);
- var trailPath = null;
-
-
- if (opts.trailColor || opts.trailWidth) {
- trailPath = this._createTrail(opts);
- svg.appendChild(trailPath);
- }
- var path = this._createPath(opts);
- svg.appendChild(path);
- return {
- svg: svg,
- path: path,
- trail: trailPath
- };
- };
- Shape.prototype._initializeSvg = function _initializeSvg(svg, opts) {
- svg.setAttribute('viewBox', '0 0 100 100');
- };
- Shape.prototype._createPath = function _createPath(opts) {
- var pathString = this._pathString(opts);
- return this._createPathElement(pathString, opts);
- };
- Shape.prototype._createTrail = function _createTrail(opts) {
-
- var pathString = this._trailString(opts);
-
- var newOpts = utils.extend({}, opts);
-
- if (!newOpts.trailColor) {
- newOpts.trailColor = '#eee';
- }
- if (!newOpts.trailWidth) {
- newOpts.trailWidth = newOpts.strokeWidth;
- }
- newOpts.color = newOpts.trailColor;
- newOpts.strokeWidth = newOpts.trailWidth;
-
-
- newOpts.fill = null;
- return this._createPathElement(pathString, newOpts);
- };
- Shape.prototype._createPathElement = function _createPathElement(pathString, opts) {
- var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
- path.setAttribute('d', pathString);
- path.setAttribute('stroke', opts.color);
- path.setAttribute('stroke-width', opts.strokeWidth);
- if (opts.fill) {
- path.setAttribute('fill', opts.fill);
- } else {
- path.setAttribute('fill-opacity', '0');
- }
- return path;
- };
- Shape.prototype._createTextContainer = function _createTextContainer(opts, container) {
- var textContainer = document.createElement('div');
- textContainer.className = opts.text.className;
- var textStyle = opts.text.style;
- if (textStyle) {
- if (opts.text.autoStyleContainer) {
- container.style.position = 'relative';
- }
- utils.setStyles(textContainer, textStyle);
-
- if (!textStyle.color) {
- textContainer.style.color = opts.color;
- }
- }
- this._initializeTextContainer(opts, container, textContainer);
- return textContainer;
- };
- Shape.prototype._initializeTextContainer = function(opts, container, element) {
-
-
- };
- Shape.prototype._pathString = function _pathString(opts) {
- throw new Error('Override this function for each progress bar');
- };
- Shape.prototype._trailString = function _trailString(opts) {
- throw new Error('Override this function for each progress bar');
- };
- Shape.prototype._warnContainerAspectRatio = function _warnContainerAspectRatio(container) {
- if (!this.containerAspectRatio) {
- return;
- }
- var computedStyle = window.getComputedStyle(container, null);
- var width = parseFloat(computedStyle.getPropertyValue('width'), 10);
- var height = parseFloat(computedStyle.getPropertyValue('height'), 10);
- if (!utils.floatEquals(this.containerAspectRatio, width / height)) {
- console.warn(
- 'Incorrect aspect ratio of container',
- '#' + container.id,
- 'detected:',
- computedStyle.getPropertyValue('width') + '(width)',
- '/',
- computedStyle.getPropertyValue('height') + '(height)',
- '=',
- width / height
- );
- console.warn(
- 'Aspect ratio of should be',
- this.containerAspectRatio
- );
- }
- };
- module.exports = Shape;
- },{"./path":5,"./utils":8}],8:[function(require,module,exports){
- var PREFIXES = 'Webkit Moz O ms'.split(' ');
- var FLOAT_COMPARISON_EPSILON = 0.001;
- function extend(destination, source, recursive) {
- destination = destination || {};
- source = source || {};
- recursive = recursive || false;
- for (var attrName in source) {
- if (source.hasOwnProperty(attrName)) {
- var destVal = destination[attrName];
- var sourceVal = source[attrName];
- if (recursive && isObject(destVal) && isObject(sourceVal)) {
- destination[attrName] = extend(destVal, sourceVal, recursive);
- } else {
- destination[attrName] = sourceVal;
- }
- }
- }
- return destination;
- }
- function render(template, vars) {
- var rendered = template;
- for (var key in vars) {
- if (vars.hasOwnProperty(key)) {
- var val = vars[key];
- var regExpString = '\\{' + key + '\\}';
- var regExp = new RegExp(regExpString, 'g');
- rendered = rendered.replace(regExp, val);
- }
- }
- return rendered;
- }
- function setStyle(element, style, value) {
- var elStyle = element.style;
- for (var i = 0; i < PREFIXES.length; ++i) {
- var prefix = PREFIXES[i];
- elStyle[prefix + capitalize(style)] = value;
- }
- elStyle[style] = value;
- }
- function setStyles(element, styles) {
- forEachObject(styles, function(styleValue, styleName) {
-
-
- if (styleValue === null || styleValue === undefined) {
- return;
- }
-
-
- if (isObject(styleValue) && styleValue.prefix === true) {
- setStyle(element, styleName, styleValue.value);
- } else {
- element.style[styleName] = styleValue;
- }
- });
- }
- function capitalize(text) {
- return text.charAt(0).toUpperCase() + text.slice(1);
- }
- function isString(obj) {
- return typeof obj === 'string' || obj instanceof String;
- }
- function isFunction(obj) {
- return typeof obj === 'function';
- }
- function isArray(obj) {
- return Object.prototype.toString.call(obj) === '[object Array]';
- }
- function isObject(obj) {
- if (isArray(obj)) {
- return false;
- }
- var type = typeof obj;
- return type === 'object' && !!obj;
- }
- function forEachObject(object, callback) {
- for (var key in object) {
- if (object.hasOwnProperty(key)) {
- var val = object[key];
- callback(val, key);
- }
- }
- }
- function floatEquals(a, b) {
- return Math.abs(a - b) < FLOAT_COMPARISON_EPSILON;
- }
- function removeChildren(el) {
- while (el.firstChild) {
- el.removeChild(el.firstChild);
- }
- }
- module.exports = {
- extend: extend,
- render: render,
- setStyle: setStyle,
- setStyles: setStyles,
- capitalize: capitalize,
- isString: isString,
- isFunction: isFunction,
- isObject: isObject,
- forEachObject: forEachObject,
- floatEquals: floatEquals,
- removeChildren: removeChildren
- };
- },{}]},{},[4])(4)
- });
|