* Wrapper for defined play method. * Play component by adding tick behavior and calling user's play method. * * @param {function} playMethod * @returns {function}
(playMethod)
| 738 | * @returns {function} |
| 739 | */ |
| 740 | function wrapPlay (playMethod) { |
| 741 | return function play () { |
| 742 | var sceneEl = this.el.sceneEl; |
| 743 | var shouldPlay = this.el.isPlaying && !this.isPlaying; |
| 744 | if (!this.initialized || !shouldPlay) { return; } |
| 745 | playMethod.call(this); |
| 746 | this.isPlaying = true; |
| 747 | this.eventsAttach(); |
| 748 | // Add tick behavior. |
| 749 | if (!hasBehavior(this)) { return; } |
| 750 | sceneEl.addBehavior(this); |
| 751 | }; |
| 752 | } |
| 753 | |
| 754 | function isObject (value) { |
| 755 | return value && value.constructor === Object && !(value instanceof window.HTMLElement); |
no test coverage detected