Fix small warning in app.js + Add useful methods to html.js + Add maths.js to utils + Build
This commit is contained in:
@@ -10,6 +10,6 @@ const app = new modular({
|
||||
app.init(app);
|
||||
globals();
|
||||
|
||||
html.classList.add('is-loaded is-ready');
|
||||
html.classList.add('is-loaded', 'is-ready');
|
||||
html.classList.remove('is-loading');
|
||||
|
||||
|
||||
@@ -94,3 +94,48 @@ export function getData(data) {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all the parent nodes of the given node
|
||||
* @param {object} node
|
||||
* @return {array} parent nodes
|
||||
*/
|
||||
export function getParents(elem) {
|
||||
// Set up a parent array
|
||||
let parents = [];
|
||||
|
||||
// Push each parent element to the array
|
||||
for ( ; elem && elem !== document; elem = elem.parentNode ) {
|
||||
parents.push(elem);
|
||||
}
|
||||
|
||||
// Return our parent array
|
||||
return parents;
|
||||
}
|
||||
|
||||
// https://gomakethings.com/how-to-get-the-closest-parent-element-with-a-matching-selector-using-vanilla-javascript/
|
||||
export function queryClosestParent(elem, selector) {
|
||||
|
||||
// Element.matches() polyfill
|
||||
if (!Element.prototype.matches) {
|
||||
Element.prototype.matches =
|
||||
Element.prototype.matchesSelector ||
|
||||
Element.prototype.mozMatchesSelector ||
|
||||
Element.prototype.msMatchesSelector ||
|
||||
Element.prototype.oMatchesSelector ||
|
||||
Element.prototype.webkitMatchesSelector ||
|
||||
function(s) {
|
||||
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
|
||||
i = matches.length;
|
||||
while (--i >= 0 && matches.item(i) !== this) {}
|
||||
return i > -1;
|
||||
};
|
||||
}
|
||||
|
||||
// Get the closest matching element
|
||||
for ( ; elem && elem !== document; elem = elem.parentNode ) {
|
||||
if ( elem.matches( selector ) ) return elem;
|
||||
}
|
||||
return null;
|
||||
|
||||
};
|
||||
|
||||
3
assets/scripts/utils/maths.js
Normal file
3
assets/scripts/utils/maths.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export function lerp(start, end, amt){
|
||||
return (1 - amt) * start + amt * end
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function e(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),t}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function c(t,e,n){return(c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=i(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}var t,n,a=function(){function t(){r(this,t),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return e(t,[{key:"addEventListener",value:function(t,e){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push(e)}},{key:"removeEventListener",value:function(t,e){if(t in this.listeners)for(var n=this.listeners[t],r=0,o=n.length;r<o;r++)if(n[r]===e)return void n.splice(r,1)}},{key:"dispatchEvent",value:function(e){var n=this;if(e.type in this.listeners){for(var t=function(t){setTimeout(function(){return t.call(n,e)})},r=this.listeners[e.type],o=0,i=r.length;o<i;o++)t(r[o]);return!e.defaultPrevented}}}]),t}(),f=function(t){function n(){var t,e;return r(this,n),(t=!(e=i(n).call(this))||"object"!=typeof e&&"function"!=typeof e?u(this):e).listeners||a.call(u(t)),Object.defineProperty(u(t),"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(u(t),"onabort",{value:null,writable:!0,configurable:!0}),t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&l(t,e)}(n,a),e(n,[{key:"toString",value:function(){return"[object AbortSignal]"}},{key:"dispatchEvent",value:function(t){"abort"===t.type&&(this.aborted=!0,"function"==typeof this.onabort&&this.onabort.call(this,t)),c(i(n.prototype),"dispatchEvent",this).call(this,t)}}]),n}(),s=function(){function t(){r(this,t),Object.defineProperty(this,"signal",{value:new f,writable:!0,configurable:!0})}return e(t,[{key:"abort",value:function(){var e;try{e=new Event("abort")}catch(t){"undefined"!=typeof document?document.createEvent?(e=document.createEvent("Event")).initEvent("abort",!1,!1):(e=document.createEventObject()).type="abort":e={type:"abort",bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(e)}},{key:"toString",value:function(){return"[object AbortController]"}}]),t}();"undefined"!=typeof Symbol&&Symbol.toStringTag&&(s.prototype[Symbol.toStringTag]="AbortController",f.prototype[Symbol.toStringTag]="AbortSignal"),((n=t="undefined"!=typeof self?self:global).__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),1):"function"==typeof n.Request&&!n.Request.prototype.hasOwnProperty("signal")||!n.AbortController)&&(t.AbortController=s,t.AbortSignal=f)});
|
||||
!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function e(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),t}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function c(t,e,n){return(c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=i(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}var t,n,a=function(){function t(){r(this,t),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return e(t,[{key:"addEventListener",value:function(t,e){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push(e)}},{key:"removeEventListener",value:function(t,e){if(t in this.listeners)for(var n=this.listeners[t],r=0,o=n.length;r<o;r++)if(n[r]===e)return void n.splice(r,1)}},{key:"dispatchEvent",value:function(e){var n=this;if(e.type in this.listeners){for(var t=function(t){setTimeout(function(){return t.call(n,e)})},r=this.listeners[e.type],o=0,i=r.length;o<i;o++)t(r[o]);return!e.defaultPrevented}}}]),t}(),f=function(t){function n(){var t,e;return r(this,n),(t=!(e=i(n).call(this))||"object"!=typeof e&&"function"!=typeof e?u(this):e).listeners||a.call(u(t)),Object.defineProperty(u(t),"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(u(t),"onabort",{value:null,writable:!0,configurable:!0}),t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&l(t,e)}(n,a),e(n,[{key:"toString",value:function(){return"[object AbortSignal]"}},{key:"dispatchEvent",value:function(t){"abort"===t.type&&(this.aborted=!0,"function"==typeof this.onabort&&this.onabort.call(this,t)),c(i(n.prototype),"dispatchEvent",this).call(this,t)}}]),n}(),s=function(){function t(){r(this,t),Object.defineProperty(this,"signal",{value:new f,writable:!0,configurable:!0})}return e(t,[{key:"abort",value:function(){var e;try{e=new Event("abort")}catch(t){"undefined"!=typeof document?document.createEvent?(e=document.createEvent("Event")).initEvent("abort",!1,!1):(e=document.createEventObject()).type="abort":e={type:"abort",bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(e)}},{key:"toString",value:function(){return"[object AbortController]"}}]),t}();"undefined"!=typeof Symbol&&Symbol.toStringTag&&(s.prototype[Symbol.toStringTag]="AbortController",f.prototype[Symbol.toStringTag]="AbortSignal"),((n=t="undefined"!=typeof self?self:global).__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),1):"function"==typeof n.Request&&!n.Request.prototype.hasOwnProperty("signal")||!n.AbortController)&&(t.AbortController=s,t.AbortSignal=f)});
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
3
www/assets/scripts/jquery-3.4.1.min.js
vendored
3
www/assets/scripts/jquery-3.4.1.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user