Skip to content

Commit

Permalink
aftc-modules v1.0.14
Browse files Browse the repository at this point in the history
aftc-modules v1.0.14
  • Loading branch information
DarceyLloyd committed Dec 4, 2019
1 parent b358bbe commit af636ff
Showing 1 changed file with 64 additions and 8 deletions.
72 changes: 64 additions & 8 deletions src/ES6/aftc-module.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// AFTC.JS ES6 Version 1.0.0
// AFTC.JS ES6 Version 1.0.14
// Author: Darcey@aftc.io


Expand All @@ -22,6 +22,29 @@ export function onReady(fn) {



export function getBrowserY(){
let supportPageOffset = window.pageXOffset !== undefined;
let isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");

// let x = supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft;
let y = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;

return y;
}


export function getBrowserX(){
let supportPageOffset = window.pageXOffset !== undefined;
let isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");

let x = supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft;
// let y = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;

return x;
}



export function normaliseRange(min, max, v) {
let range = max - min;
let step = 1 / range;
Expand All @@ -40,6 +63,8 @@ export function roundTo(v, dec) {


export function attachDebug(no) {
if (window.vDebug){ return false; }

window.vDebug = [];
let debugContainer = document.createElement("div");
debugContainer.id = "debug-container";
Expand All @@ -56,16 +81,28 @@ export function attachDebug(no) {
document.body.appendChild(debugContainer);
}

export function debug(index, msg) {
if (!window.vDebug){ return false; }
if (index > window.vDebug.length-1){ log("DEBUG INDEX [" + index + "] DOESNT EXIST!"); return false; }

window.vDebug[index].innerHTML = msg;
}



export function log(arg) {
console.log(arg);
}

export function debug(index, msg) {
if (!window.vDebug){ return false; }
if (index > window.vDebug.length-1){ log("DEBUG INDEX [" + index + "] DOESNT EXIST!"); return false; }
export function logTo(elementOrId,msg){
let ele = false;
if (typeof(elementOrId) == "string"){
ele = document.getElementById(elementOrId);
}

window.vDebug[index].innerHTML = msg;
if (ele){
ele.innerHTML = msg;
}
}


Expand All @@ -74,6 +111,26 @@ export function debug(index, msg) {



export function getElementPosition(el) {
let position = {
top: el.offsetTop,
left: el.offsetLeft
};

if (el.offsetParent) {
let parentPosition = {
top: el.offsetParent.offsetTop,
left: el.offsetParent.offsetLeft
};

position.top += parentPosition.top;
position.left += parentPosition.left;
}
return position;
}






Expand Down Expand Up @@ -115,9 +172,7 @@ export function argsToObject(fArgs, obj, strict) {
}
};

export function argsTo(args, obj, strict) {
this.argsToObject(args, obj, strict);
}


export function isElement(o) {
let answer = (
Expand Down Expand Up @@ -290,6 +345,7 @@ export function getRandomThatsNot(min,max,not){
}

export function getRandomFloat(min, max) {
// let r = from + (Math.random()* (to*2));
return (Math.random() * (max - min) + min);
};

Expand Down

0 comments on commit af636ff

Please sign in to comment.