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