Skip to content
This repository was archived by the owner on Jul 24, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions assets/scripts/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import modular from 'modujs';
import * as modules from './modules';
import globals from './globals';
import { html } from './utils/environment';
import { $html } from './utils/dom';
import config from './config';

const app = new modular({
modules: modules
Expand All @@ -28,8 +29,8 @@ function init() {

app.init(app);

html.classList.add('is-loaded');
html.classList.add('is-ready');
html.classList.remove('is-loading');
$html.classList.add(config.CLASS.LOADED);
$html.classList.add(config.CLASS.READY);
$html.classList.remove(config.CLASS.LOADING);
}

20 changes: 20 additions & 0 deletions assets/scripts/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const env = process.env.NODE_ENV

export default config = {

// App
APP_NAME: 'Boilerplate',
DATA_API_KEY: '.data-api',

// Env
ENV: env,
IS_PROD: env === 'production',
IS_DEV: env === 'development',

// Classnames
CLASS: {
LOADING: 'is-loading',
READY: 'is-ready',
LOADED: 'is-loaded',
},
}
27 changes: 16 additions & 11 deletions assets/scripts/modules/Load.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
import { module } from 'modujs';
import modularLoad from 'modularload';
import barba from '@barba/core';
import config from '../config'

export default class extends module {
constructor(m) {
super(m);
}

init() {
const load = new modularLoad({
enterDelay: 0,
transitions: {
customTransition: {}
}
});

load.on('loaded', (transition, oldContainer, newContainer) => {
this.call('destroy', oldContainer, 'app');
this.call('update', newContainer, 'app');
barba.init({
debug: config.IS_DEV,
schema: {
prefix: 'data-load',
},
transitions: [{
name: 'default-transition',
leave: (data) => {
this.call('destroy', data.current.container, 'app');
},
enter: (data) => {
this.call('update', data.next.container, 'app');
}
}]
});
}
}
4 changes: 4 additions & 0 deletions assets/scripts/utils/dom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const $html = document.documentElement;
const $body = document.body;

export { $html, $body };
8 changes: 0 additions & 8 deletions assets/scripts/utils/environment.js

This file was deleted.

3 changes: 1 addition & 2 deletions assets/scripts/utils/visibility.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { isFunction } from './is';
import { arrayContains, findByKeyValue, removeFromArray } from './array';
import { $document, $window, $html, $body } from './environment';

const CALLBACKS = {
hidden: [],
Expand All @@ -22,7 +21,7 @@ const PREFIX = 'v-';
let UUID = 0;

// Main event
$document.on('visibilitychange', function(event) {
document.addEventListener('visibilitychange', function(event) {
if (document.hidden) {
onDocumentChange('hidden');
} else {
Expand Down
50 changes: 39 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"build": "node --experimental-json-modules --no-warnings build/build.js"
},
"dependencies": {
"@barba/core": "^2.9.7",
"locomotive-scroll": "^4.1.4",
"modujs": "^1.4.2",
"modularload": "^1.2.6",
"normalize.css": "^8.0.1",
"svg4everybody": "^2.1.9"
},
Expand Down
Loading