| 791 | } |
| 792 | |
| 793 | class FlipBatch { |
| 794 | constructor(id) { |
| 795 | this.id = id; |
| 796 | this.actions = []; |
| 797 | this._kill = []; |
| 798 | this._final = []; |
| 799 | this._abs = []; |
| 800 | this._run = []; |
| 801 | this.data = {}; |
| 802 | this.state = new FlipState(); |
| 803 | this.timeline = gsap.timeline(); |
| 804 | } |
| 805 | |
| 806 | add(config) { |
| 807 | let result = this.actions.filter(action => action.vars === config); |
| 808 | if (result.length) { |
| 809 | return result[0]; |
| 810 | } |
| 811 | result = new FlipAction(typeof(config) === "function" ? {animate: config} : config, this); |
| 812 | this.actions.push(result); |
| 813 | return result; |
| 814 | } |
| 815 | |
| 816 | remove(action) { |
| 817 | let i = this.actions.indexOf(action); |
| 818 | i >= 0 && this.actions.splice(i, 1); |
| 819 | return this; |
| 820 | } |
| 821 | |
| 822 | getState(merge) { |
| 823 | let prevBatch = _batch, |
| 824 | prevAction = _batchAction; |
| 825 | _batch = this; |
| 826 | this.state.clear(); |
| 827 | this._kill.length = 0; |
| 828 | this.actions.forEach(action => { |
| 829 | if (action.vars.getState) { |
| 830 | action.states.length = 0; |
| 831 | _batchAction = action; |
| 832 | action.state = action.vars.getState(action); |
| 833 | } |
| 834 | merge && action.states.forEach(s => this.state.add(s)); |
| 835 | }); |
| 836 | _batchAction = prevAction; |
| 837 | _batch = prevBatch; |
| 838 | this.killConflicts(); |
| 839 | return this; |
| 840 | } |
| 841 | |
| 842 | animate() { |
| 843 | let prevBatch = _batch, |
| 844 | tl = this.timeline, |
| 845 | i = this.actions.length, |
| 846 | finalStates, endTime; |
| 847 | _batch = this; |
| 848 | tl.clear(); |
| 849 | this._abs.length = this._final.length = this._run.length = 0; |
| 850 | this.actions.forEach(a => { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…