-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js.map
1 lines (1 loc) · 4.83 KB
/
index.js.map
1
{"version":3,"file":"index.js","sources":["src/index.js"],"sourcesContent":["import karas from 'karas';\nimport { version } from '../package.json';\n\nclass Sprite extends karas.Component {\n constructor(props) {\n super(props);\n this.count = 0;\n this.times = 0;\n this.playbackRate = props.playbackRate || 1;\n }\n\n componentDidMount() {\n let { nw, nh, delay = 0, duration = 1000, iterations = 1, fill, autoPlay } = this.props;\n let total = nw * nh;\n let sr = this.shadowRoot;\n let cb = this.cb = diff => {\n this.count += diff * this.playbackRate;\n if(this.times === 0 && this.count < delay) {\n return;\n }\n let time = this.times ? this.count : (this.count - delay);\n if(time >= duration) {\n this.times++;\n if(this.times >= iterations) {\n sr.removeFrameAnimate(cb);\n let backgroundPosition = ['forwards', 'both'].indexOf(fill) > -1 ? '100% 100%' : '1000% 1000%';\n sr.updateStyle({\n backgroundPosition,\n });\n return;\n }\n this.count = time - duration;\n }\n let i = Math.floor(time * total / duration);\n sr.updateStyle({\n backgroundPositionX: i % nw / (nw - 1) * 100 + '%',\n backgroundPositionY: Math.floor(i / nw) / (nh - 1) * 100 + '%',\n });\n };\n if(autoPlay !== false) {\n sr.frameAnimate(cb);\n }\n }\n\n play() {\n this.count = 0;\n this.times = 0;\n this.resume();\n }\n\n pause() {\n this.shadowRoot.removeFrameAnimate(this.cb);\n }\n\n resume() {\n this.shadowRoot.frameAnimate(this.cb);\n }\n\n render() {\n let nw = this.props.nw, nh = this.props.nh, fill = this.props.fill;\n let backgroundPosition = ['backwards', 'both'].indexOf(fill) > -1 ? '0 0' : '1000% 1000%';\n return <div style={{\n backgroundRepeat: 'no-repeat',\n backgroundPosition,\n backgroundSize: `${nw * 100}% ${nh * 100}%`,\n }}/>;\n }\n}\n\nSprite.version = version;\n\nexport default Sprite;\n"],"names":["Sprite","props","count","times","playbackRate","nw","nh","delay","duration","iterations","fill","autoPlay","total","sr","shadowRoot","cb","diff","time","removeFrameAnimate","backgroundPosition","indexOf","updateStyle","i","Math","floor","backgroundPositionX","backgroundPositionY","frameAnimate","resume","karas","backgroundRepeat","backgroundSize","Component","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAGMA;;;;;EACJ,kBAAYC,KAAZ,EAAmB;EAAA;;EAAA;;EACjB,8BAAMA,KAAN;EACA,UAAKC,KAAL,GAAa,CAAb;EACA,UAAKC,KAAL,GAAa,CAAb;EACA,UAAKC,YAAL,GAAoBH,KAAK,CAACG,YAAN,IAAsB,CAA1C;EAJiB;EAKlB;;;;aAED,6BAAoB;EAAA;;EAClB,wBAA6E,KAAKH,KAAlF;EAAA,UAAMI,EAAN,eAAMA,EAAN;EAAA,UAAUC,EAAV,eAAUA,EAAV;EAAA,0CAAcC,KAAd;EAAA,UAAcA,KAAd,kCAAsB,CAAtB;EAAA,6CAAyBC,QAAzB;EAAA,UAAyBA,QAAzB,qCAAoC,IAApC;EAAA,8CAA0CC,UAA1C;EAAA,UAA0CA,UAA1C,sCAAuD,CAAvD;EAAA,UAA0DC,IAA1D,eAA0DA,IAA1D;EAAA,UAAgEC,QAAhE,eAAgEA,QAAhE;EACA,UAAIC,KAAK,GAAGP,EAAE,GAAGC,EAAjB;EACA,UAAIO,EAAE,GAAG,KAAKC,UAAd;;EACA,UAAIC,EAAE,GAAG,KAAKA,EAAL,GAAU,UAAAC,IAAI,EAAI;EACzB,QAAA,MAAI,CAACd,KAAL,IAAcc,IAAI,GAAG,MAAI,CAACZ,YAA1B;;EACA,YAAG,MAAI,CAACD,KAAL,KAAe,CAAf,IAAoB,MAAI,CAACD,KAAL,GAAaK,KAApC,EAA2C;EACzC;EACD;;EACD,YAAIU,IAAI,GAAG,MAAI,CAACd,KAAL,GAAa,MAAI,CAACD,KAAlB,GAA2B,MAAI,CAACA,KAAL,GAAaK,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