2018-02-05 15:17:39 -05:00
|
|
|
import { APP_NAME, $document, $html, $body, isDebug, $pjaxWrapper } from '../utils/environment';
|
|
|
|
|
|
2018-05-10 11:12:05 -04:00
|
|
|
import { EVENT as TransitionEvent } from './TransitionManager'
|
2018-02-01 16:14:35 -05:00
|
|
|
|
|
|
|
|
export default class {
|
|
|
|
|
constructor(options) {
|
|
|
|
|
|
|
|
|
|
this.options = options;
|
|
|
|
|
this.wrapper = options.wrapper;
|
|
|
|
|
this.overrideClass = options.overrideClass ? options.overrideClass : '';
|
2018-02-05 15:17:39 -05:00
|
|
|
this.clickedLink = options.clickedLink;
|
2018-02-01 16:14:35 -05:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
launch() {
|
2018-02-05 15:17:39 -05:00
|
|
|
if(isDebug) {
|
|
|
|
|
console.log("---- Launch transition 👊 -----");
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-01 16:14:35 -05:00
|
|
|
$html
|
2018-04-30 17:26:13 -04:00
|
|
|
.removeClass('has-dom-loaded has-dom-animated ')
|
|
|
|
|
.addClass(`has-dom-loading ${this.overrideClass}`);
|
2018-02-01 16:14:35 -05:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-05 15:17:39 -05:00
|
|
|
hideView(oldView, newView) {
|
|
|
|
|
if(isDebug) {
|
|
|
|
|
console.log('----- ❌ [VIEW]:hide - ', oldView.getAttribute('data-template'));
|
|
|
|
|
}
|
2018-11-22 11:58:31 -05:00
|
|
|
|
2018-02-05 15:17:39 -05:00
|
|
|
// launch it at the end (animations...)
|
|
|
|
|
$document.triggerHandler({
|
2018-11-22 11:58:31 -05:00
|
|
|
type:TransitionEvent.READYTOAPPEND,
|
2018-02-05 15:17:39 -05:00
|
|
|
oldView: oldView,
|
|
|
|
|
newView: newView
|
|
|
|
|
});
|
2018-02-01 16:14:35 -05:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-05 15:17:39 -05:00
|
|
|
|
2018-02-01 16:14:35 -05:00
|
|
|
displayView(view) {
|
|
|
|
|
|
2018-02-05 15:17:39 -05:00
|
|
|
if(isDebug) {
|
|
|
|
|
console.log('----- ✅ [VIEW]:display :', view.getAttribute('data-template'));
|
|
|
|
|
}
|
2018-02-02 09:34:24 -05:00
|
|
|
|
|
|
|
|
$html.attr('data-template', view.getAttribute('data-template'));
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
2018-04-30 17:26:13 -04:00
|
|
|
|
2018-02-01 16:14:35 -05:00
|
|
|
$html
|
2018-04-30 17:26:13 -04:00
|
|
|
.addClass('has-dom-loaded')
|
|
|
|
|
.removeClass('has-dom-loading');
|
2018-02-01 16:14:35 -05:00
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
$html
|
|
|
|
|
.removeClass(this.overrideClass)
|
2018-04-30 17:26:13 -04:00
|
|
|
.addClass('has-dom-animated');
|
2018-02-01 16:14:35 -05:00
|
|
|
}, 1000);
|
|
|
|
|
|
2018-02-05 15:17:39 -05:00
|
|
|
// launch it at the end (animations...)
|
|
|
|
|
$document.triggerHandler({
|
2018-05-03 13:50:48 -04:00
|
|
|
type:TransitionEvent.READYTODESTROY
|
2018-02-05 15:17:39 -05:00
|
|
|
});
|
|
|
|
|
|
2018-02-01 16:14:35 -05:00
|
|
|
},1000);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-30 17:26:13 -04:00
|
|
|
|
2018-02-01 16:14:35 -05:00
|
|
|
destroy() {
|
2018-02-05 15:17:39 -05:00
|
|
|
if(isDebug) {
|
|
|
|
|
console.log("---- ❌ [transition]:destroy -----");
|
|
|
|
|
}
|
2018-02-01 16:14:35 -05:00
|
|
|
}
|
|
|
|
|
}
|