Small fixes regarding pjax and animation
This commit is contained in:
@@ -27,10 +27,9 @@ const animation = (steps) => {
|
||||
}
|
||||
|
||||
const initDetails = (element, fromPjax) => {
|
||||
console.log('app');
|
||||
// if (fromPjax !== true) {
|
||||
// return;
|
||||
// }
|
||||
if (fromPjax !== true) {
|
||||
return;
|
||||
}
|
||||
|
||||
element.classList.add('animate');
|
||||
element.classList.add('animate--curtain');
|
||||
|
||||
@@ -2,7 +2,7 @@ import Vue from 'vue';
|
||||
import applyPjax from './pjax';
|
||||
|
||||
|
||||
const initFilter = element => {
|
||||
const initFilter = (element) => {
|
||||
const index = JSON.parse(element.getAttribute('data-index'));
|
||||
|
||||
const filter = new Vue({
|
||||
@@ -26,7 +26,7 @@ const initFilter = element => {
|
||||
return visibleItems.length > 0;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
mounted() {
|
||||
applyPjax();
|
||||
},
|
||||
updated() {
|
||||
|
||||
12
js/radar.js
12
js/radar.js
@@ -2,17 +2,17 @@ import filter from './filter';
|
||||
import details from './details';
|
||||
import applyPjax from './pjax';
|
||||
|
||||
const enhanceComponent = (selector, enhancer) => {
|
||||
const enhanceComponent = (selector, enhancer, fromPjax = false) => {
|
||||
const $filter = [].slice.call(document.querySelectorAll(selector));
|
||||
$filter.map(enhancer);
|
||||
$filter.map((e) => enhancer(e, fromPjax));
|
||||
}
|
||||
|
||||
const enhanceComponents = () => {
|
||||
enhanceComponent('.js--filter', filter);
|
||||
enhanceComponent('.js--details', details);
|
||||
const enhanceComponents = (fromPjax) => {
|
||||
enhanceComponent('.js--filter', filter, fromPjax);
|
||||
enhanceComponent('.js--details', details, fromPjax);
|
||||
}
|
||||
|
||||
applyPjax();
|
||||
|
||||
enhanceComponents();
|
||||
document.addEventListener("pjax:success", enhanceComponents);
|
||||
document.addEventListener("pjax:success", () => enhanceComponents(true));
|
||||
|
||||
Reference in New Issue
Block a user