DOM

Utils for DOM

Classes

KeyboardManager
MouseManager
Particles

Namespaces

Device

Members

(static, constant) exports.KeyboardManagerInstance

(static, constant) exports.KEYS

Keys code for the keyboard

(static, constant) exports.MouseButton

Mouse button keys

(static, constant) exports.MouseManagerInstance

Example
const { x, y } = MouseManagerInstance;
console.log(x, y);

(static, constant) exports.ParticlesInstance

Methods

(static) deleteAllChildDom(domElement)

Eliminate all child elements of a choice parent element. For example: delete all dom

  • from a
      .

  • Parameters:
    NameTypeDescription
    domElementHTMLElement

    The HTML element to exclude all children

    (static) exports.exportFile(data, filename, type) → {void}

    Create a file and auto downloads the file to user computer

    Parameters:
    NameTypeDescription
    dataany

    the content to export

    filenamestring

    the name of the exported file

    typestring

    type of the exported file like "txt"

    Returns:
    Type: 
    void

    (static) getUrlParameter(key) → {string}

    Get a value from a query parameter from the current URL

    Parameters:
    NameTypeDescription
    keystring

    The key of the query parameter

    Returns:

    Returns the value of the key

    Type: 
    string
    Example
    URL: http://localhost:8080/?name=Silva
    getUrlParameter("name"); // Silva

    (static) notification(options) → {void}

    Display a pop up im the DOM with the given text

    Example: https://codesandbox.io/s/201flaviosilva-utils-notification-g3nk0v

    Parameters:
    NameTypeDescription
    optionsObject

    The options for the pop up

    Properties
    NameTypeDescription
    textstring

    display text in the pop up

    animatedboolean

    if the animation should be animated

    animationTimenumber

    time for the animation

    closeButtonboolean

    if the pop up have the button to close or not

    endPositionnumber

    position to stop the animation (top)

    styleObject

    the style for the wrapper

    textStyleObject

    the style for the text (span)

    buttonStyleObject

    the style for the close button

    parentHTMLElement

    parent to create the pop up

    Returns:
    Type: 
    void
    Examples
    notification({ text: "notification" });
    notification({
    	text: "My nice text",
    	animated: false,
    	animationTime: 5,
    	closeButton: true,
    	endPosition: 250,
    	style: { border: "10px solid rgb(0, 255, 100)", },
    	textStyle: { textTransform: "uppercase", },
    	buttonStyle: { backgroundColor: "red" },
    });

    (static) printObjectInDOM(object, parentopt)

    Print JavaScript Object In HTML Dom

    Parameters:
    NameTypeAttributesDefaultDescription
    objectObject

    JavaScript Object to print in the dom

    parentHTMLElement<optional>
    document.body

    DOM element to print

    See
    • https://jsfiddle.net/201flaviosilva/mbnz3p7y/
    Example
    const myObject = {
    	name: "Sistema Solar",
    	numberStarts: 1,
    	terra: {
    		speed: 29.783,
    		moons: ["Lua"],
    		temperature: {
    			min: 93.2,
    			max: 57.8,
    			average: 14,
    		}
    	},
    };
    printObjectInDOM(myObject, document.getElementById("myDomElement"));

    (static) toggleFullScreen(element) → {void}

    • If a given element is not in full screen, starts the full-screen mode and focus on the element.
    • If the document is already in full screen mode, stop.
    Parameters:
    NameTypeDescription
    elementHTMLElement

    the DOM element to put in full screen

    Returns:
    Type: 
    void
    Examples
    toggleFullScreen();
    toggleFullScreen(document.getElementById("myElement"));
    ```html
    <!--- html --->
    <button id="toggle">Toggle</button>
    ```
    
    ```js
    // js
    import { toggleFullScreen } from "201flaviosilva-utils";
    document.getElementById("toggle").addEventListener("click", () => {
    	toggleFullScreen(document.getElementById("toggle"));
    });
    ```