This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const customObserver = (settings = {}) => { | |
const { target, callback, options, margin, thresholds, immediate, caller, debug } = settings; | |
if (!caller && debug) console.warn("arg.caller TYPE:String unset - unable to trace call origin") | |
if (!target) return console.warn("arg.target TYPE:HTML:Node required" + (caller ? ' caller: ' + caller : '')); | |
if (typeof callback !== "function") return console.warn("arg.callback TYPE:Function required" + (caller ? ' caller: ' + caller : '')); | |
const usedOptions = options || { | |
root: null, | |
rootMargin: margin || "0px", | |
threshold: thresholds || 0, | |
}; |