| 27 | import { version } from '../package.json'; |
| 28 | |
| 29 | export class Css implements IBarbaPlugin<{}> { |
| 30 | public name = '@barba/css'; |
| 31 | public version = version; |
| 32 | public barba: Core; |
| 33 | public logger: Logger; |
| 34 | |
| 35 | public prefix: string = 'barba'; |
| 36 | public callbacks: ICssCallbacks = {}; |
| 37 | public cb: any; |
| 38 | |
| 39 | // Check if transition property applied |
| 40 | private _hasTransition: boolean = false; |
| 41 | |
| 42 | /** |
| 43 | * Plugin installation. |
| 44 | */ |
| 45 | public install(barba: Core) { |
| 46 | this.logger = new barba.Logger(this.name); |
| 47 | this.logger.info(this.version); |
| 48 | this.barba = barba; |
| 49 | this._once = this._once.bind(this); |
| 50 | this._leave = this._leave.bind(this); |
| 51 | this._enter = this._enter.bind(this); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Plugin installation. |
| 56 | */ |
| 57 | public init() { |
| 58 | // Register hooks to get prefix |
| 59 | this.barba.hooks.before(this._getPrefix, this); |
| 60 | this.barba.hooks.beforeOnce(this._getPrefix, this); |
| 61 | |
| 62 | // Register hook for CSS classes |
| 63 | this.barba.hooks.beforeOnce(this._beforeOnce, this); |
| 64 | this.barba.hooks.afterOnce(this._afterOnce, this); |
| 65 | this.barba.hooks.beforeLeave(this._beforeLeave, this); |
| 66 | this.barba.hooks.afterLeave(this._afterLeave, this); |
| 67 | this.barba.hooks.beforeEnter(this._beforeEnter, this); |
| 68 | this.barba.hooks.afterEnter(this._afterEnter, this); |
| 69 | |
| 70 | // Override main transitions |
| 71 | this.barba.transitions.once = this._once; |
| 72 | this.barba.transitions.leave = this._leave; |
| 73 | this.barba.transitions.enter = this._enter; |
| 74 | |
| 75 | // Add empty default transition (force prepend) |
| 76 | /* istanbul ignore next */ |
| 77 | this.barba.transitions.store.all.unshift({ |
| 78 | name: 'barba', |
| 79 | once() {}, // tslint:disable-line:no-empty |
| 80 | leave() {}, // tslint:disable-line:no-empty |
| 81 | enter() {}, // tslint:disable-line:no-empty |
| 82 | }); |
| 83 | this.barba.transitions.store.update(); |
| 84 | } |
| 85 | |
| 86 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected