* performAsync * Promisified version of `perform` that can support eased edits in a transition. * This version of `perform` accepts a single Action function argument. * If the Action is marked as being "transitionable", run it multiple times with * eased time parameter from 0..1 to cre
(action)
| 313 | * @return {Promise} Promise fulfilled when the transition is completed |
| 314 | */ |
| 315 | performAsync(action) { |
| 316 | d3_select(document).interrupt('editTransition'); // complete any transition already in progress |
| 317 | |
| 318 | if (typeof action !== 'function') { |
| 319 | return Promise.reject(); |
| 320 | } |
| 321 | |
| 322 | if (!action.transitionable) { |
| 323 | this._perform([action], 1); |
| 324 | this._updateChanges(); |
| 325 | return Promise.resolve(); |
| 326 | } |
| 327 | |
| 328 | const DURATION = 150; |
| 329 | |
| 330 | return new Promise(resolve => { |
| 331 | d3_select(document) |
| 332 | .transition('editTransition') |
| 333 | .duration(DURATION) |
| 334 | .ease(d3_easeLinear) |
| 335 | .tween('edit.tween', () => { |
| 336 | return (t) => { |
| 337 | if (t < 1) { |
| 338 | this._replaceStaging(); |
| 339 | this._perform([action], t); |
| 340 | this._updateChanges(); |
| 341 | } |
| 342 | }; |
| 343 | }) |
| 344 | .on('start', () => { |
| 345 | this._inTransition = true; |
| 346 | this._replaceStaging(); |
| 347 | this._perform([action], 0); |
| 348 | this._updateChanges(); |
| 349 | }) |
| 350 | .on('end interrupt', () => { |
| 351 | this._replaceStaging(); |
| 352 | this._perform([action], 1); |
| 353 | this._updateChanges(); |
| 354 | this._inTransition = false; |
| 355 | resolve(); |
| 356 | }); |
| 357 | }); |
| 358 | } |
| 359 | |
| 360 | |
| 361 | /** |
no test coverage detected