Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@three11/dom-helpers

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@three11/dom-helpers - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

14

dist/dom-helpers.js

@@ -13,3 +13,3 @@ (function (global, factory) {

}
})(this, function (_exports) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
"use strict";

@@ -24,10 +24,14 @@

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var D = document;

@@ -34,0 +38,0 @@ /**

@@ -1,2 +0,2 @@

(function(a,b){if("function"==typeof define&&define.amd)define(["exports"],b);else if("undefined"!=typeof exports)b(exports);else{var c={exports:{}};b(c.exports),a.domHelpers=c.exports}})(this,function(a){"use strict";function b(a){return e(a)||d(a)||c()}function c(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function d(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function e(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}Object.defineProperty(a,"__esModule",{value:!0}),a.trigger=a.insertBefore=a.insertAfter=a.toggleClass=a.removeClass=a.addClass=a.hasClass=a.getScrollPosition=a.isElementVisibleInViewport=a.enableListeners=a.$$=a.$=void 0;var f=void 0,g=document;a.$=function c(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:g;return b.querySelector(a)};a.$$=function d(a){var c=1<arguments.length&&arguments[1]!==void 0?arguments[1]:g;return b(c.querySelectorAll(a))};a.enableListeners=function a(){/**
(function(a,b){if("function"==typeof define&&define.amd)define(["exports"],b);else if("undefined"!=typeof exports)b(exports);else{var c={exports:{}};b(c.exports),a.domHelpers=c.exports}})("undefined"==typeof globalThis?"undefined"==typeof self?this:self:globalThis,function(a){"use strict";function b(a){return f(a)||e(a)||d(a)||c()}function c(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(a,b){if(a){if("string"==typeof a)return g(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?g(a,b):void 0}}function e(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function f(a){if(Array.isArray(a))return g(a)}function g(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}Object.defineProperty(a,"__esModule",{value:!0}),a.trigger=a.insertBefore=a.insertAfter=a.toggleClass=a.removeClass=a.addClass=a.hasClass=a.getScrollPosition=a.isElementVisibleInViewport=a.enableListeners=a.$$=a.$=void 0;var h=void 0,i=document;a.$=function $(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:i;return b.querySelector(a)};a.$$=function $$(a){var c=1<arguments.length&&arguments[1]!==void 0?arguments[1]:i;return b(c.querySelectorAll(a))};a.enableListeners=function enableListeners(){/**
* Add `on` method to Element

@@ -14,2 +14,2 @@ *

*/ // eslint-disable-next-line no-extend-native
Element.prototype.on=function(a,b){var c=!!(2<arguments.length&&arguments[2]!==void 0)&&arguments[2];f.addEventListener(a,b,c)},Array.prototype.on=function(a,b){var c=!!(2<arguments.length&&arguments[2]!==void 0)&&arguments[2];f.map(function(d){d instanceof Element&&d.addEventListener(a,b,c)})}};a.isElementVisibleInViewport=function k(a){var b=!!(1<arguments.length&&arguments[1]!==void 0)&&arguments[1],c=a.getBoundingClientRect(),d=c.top,e=c.right,f=c.bottom,g=c.left,h=window,i=h.innerWidth,j=h.innerHeight;return b?(0<d&&d<j||0<f&&f<j)&&(0<g&&g<i||0<e&&e<i):0<=d&&0<=g&&f<=j&&e<=i};a.getScrollPosition=function b(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:window;return{x:a.pageXOffset||a.scrollLeft,y:a.pageYOffset||a.scrollTop}};a.hasClass=function c(a,b){return a.classList.contains(b)};a.addClass=function c(a,b){return a.classList.add(b)};a.removeClass=function c(a,b){return a.classList.remove(b)};a.toggleClass=function d(a,b,c){return a.classList.toggle(b,c)};a.insertAfter=function c(a,b){return a.insertAdjacentHTML("afterend",b)};a.insertBefore=function c(a,b){return a.insertAdjacentHTML("beforebegin",b)};a.trigger=function d(a,b,c){return a.dispatchEvent(new CustomEvent(b,{detail:c}))}});
Element.prototype.on=function(a,b){var c=!!(2<arguments.length&&arguments[2]!==void 0)&&arguments[2];h.addEventListener(a,b,c)},Array.prototype.on=function(a,b){var c=!!(2<arguments.length&&arguments[2]!==void 0)&&arguments[2];h.map(function(d){d instanceof Element&&d.addEventListener(a,b,c)})}};a.isElementVisibleInViewport=function isElementVisibleInViewport(a){var b=!!(1<arguments.length&&arguments[1]!==void 0)&&arguments[1],c=a.getBoundingClientRect(),d=c.top,e=c.right,f=c.bottom,g=c.left,h=window,i=h.innerWidth,j=h.innerHeight;return b?(0<d&&d<j||0<f&&f<j)&&(0<g&&g<i||0<e&&e<i):0<=d&&0<=g&&f<=j&&e<=i};a.getScrollPosition=function getScrollPosition(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:window;return{x:a.pageXOffset||a.scrollLeft,y:a.pageYOffset||a.scrollTop}};a.hasClass=function hasClass(a,b){return a.classList.contains(b)};a.addClass=function addClass(a,b){return a.classList.add(b)};a.removeClass=function removeClass(a,b){return a.classList.remove(b)};a.toggleClass=function toggleClass(a,b,c){return a.classList.toggle(b,c)};a.insertAfter=function insertAfter(a,b){return a.insertAdjacentHTML("afterend",b)};a.insertBefore=function insertBefore(a,b){return a.insertAdjacentHTML("beforebegin",b)};a.trigger=function trigger(a,b,c){return a.dispatchEvent(new CustomEvent(b,{detail:c}))}});
{
"name": "@three11/dom-helpers",
"version": "1.0.0",
"version": "1.1.0",
"description": "Helper functions for faster DOM scripting",

@@ -44,17 +44,8 @@ "main": "dist/dom-helpers.js",

"devDependencies": {
"@babel/cli": "7.2.3",
"@babel/core": "7.2.2",
"@babel/plugin-proposal-class-properties": "7.2.3",
"@babel/plugin-proposal-decorators": "7.2.3",
"@babel/plugin-proposal-export-namespace-from": "7.2.0",
"@babel/plugin-proposal-function-sent": "7.2.0",
"@babel/plugin-proposal-json-strings": "7.2.0",
"@babel/plugin-proposal-numeric-separator": "7.2.0",
"@babel/plugin-proposal-throw-expressions": "7.2.0",
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/plugin-syntax-import-meta": "7.2.0",
"@babel/preset-env": "7.2.3",
"babel-loader": "8.0.5",
"babel-minify": "0.5.0"
"@babel/cli": "7.14.3",
"@babel/core": "7.14.3",
"@babel/plugin-transform-modules-umd": "7.14.0",
"@babel/preset-env": "7.14.2",
"babel-minify": "0.5.1"
}
}

@@ -81,3 +81,3 @@ [![GitHub release](https://img.shields.io/github/release/three11/dom-helpers.svg)](https://github.com/three11/dom-helpers/releases/latest)

-----
---

@@ -90,3 +90,3 @@ `$$` - queries the DOM and obtains a collection of elements

-----
---

@@ -99,15 +99,15 @@ `enableListeners` - enables the custom `on` method for attaching of event listeners

button.on('click', () => {
console.log('clicked a single button');
console.log('clicked a single button');
});
buttons.on('click', () => {
console.log('clicked a button in a collection');
console.log('clicked a button in a collection');
});
```
-----
---
`isElementVisibleInViewport` - accepts two arguments: DOM element and a boolean flag which states if the element should be partially visible. Returns boolean.
``` javascript
```javascript
const element = document.getElementById('element');

@@ -117,5 +117,5 @@ const isVisible = isElementVisibleInViewport(element, true);

-----
---
- `getScrollPosition` - returns the scroll position of the passed DOM Element
- `getScrollPosition` - returns the scroll position of the passed DOM Element

@@ -127,8 +127,8 @@ ```javascript

-----
---
- `hasClass` - Returns boolean true if the element has the specified class, false otherwise.
- `addClass` - Adds the specified class to an element
- `removeClass` - Removes the specified class from an element
- `toggleClass` - Toggles the specified class on an element
- `hasClass` - Returns boolean true if the element has the specified class, false otherwise.
- `addClass` - Adds the specified class to an element
- `removeClass` - Removes the specified class from an element
- `toggleClass` - Toggles the specified class on an element

@@ -148,9 +148,9 @@ ```javascript

*/
toggleClass(element, 'test', true)
toggleClass(element, 'test', true);
```
-----
---
- `insertAfter` - Insert the supplied HTML String after the element
- `insertBefore` - Insert the supplied HTML String before the element
- `insertAfter` - Insert the supplied HTML String after the element
- `insertBefore` - Insert the supplied HTML String before the element

@@ -164,5 +164,5 @@ ```javascript

-----
---
- `trigger` - Fires a custom (or built-in) event
- `trigger` - Fires a custom (or built-in) event

@@ -173,3 +173,3 @@ ```javascript

// The third argument is event data. Can be omitted
trigger(element, 'click', { data: true })
trigger(element, 'click', { data: true });
```

@@ -176,0 +176,0 @@

@@ -55,3 +55,4 @@ const D = document;

return isPartiallyVisible
? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) && ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) &&
((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
: top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;

@@ -58,0 +59,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc