Skip to content

Commit

Permalink
Update dependencies (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptex authored May 25, 2021
1 parent a3d5da7 commit 4af7057
Show file tree
Hide file tree
Showing 10 changed files with 370 additions and 1,125 deletions.
13 changes: 1 addition & 12 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
{
"presets": ["@babel/env"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
["@babel/plugin-proposal-class-properties", { "loose": false }],
"@babel/plugin-proposal-json-strings",
"@babel/plugin-transform-modules-umd"
]
"plugins": ["@babel/plugin-transform-modules-umd"]
}
35 changes: 17 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@
name: Build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
build:
runs-on: ubuntu-latest

runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- run: yarn build
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- run: yarn build
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ yarn.lock

# Config
.babelrc
.github
.whitesource
renovate.json
webpack.config.js
2 changes: 1 addition & 1 deletion .whitesource
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"issueSettings": {
"minSeverityLevel": "LOW"
}
}
}
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,54 +78,54 @@ See functions list below:
const button = $('#button');
```

-----
---

`$$` - queries the DOM and obtains a collection of elements

```javascript
const buttons = $$('#button');
```

-----
---

`enableListeners` - enables the custom `on` method for attaching of event listeners

```javascript
enableListeners();

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');
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

```javascript
const element = document.getElementById('element');
const scrollPosition = getScrollPosition(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
- `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

```javascript
const element = document.getElementById('element');
Expand All @@ -140,13 +140,13 @@ removeClass(element, 'test');
* if false it will be removed.
* If omitted, the classname will be toggled
*/
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

```javascript
const element = document.getElementById('element');
Expand All @@ -155,15 +155,15 @@ insertAfter(element, '<div>Test</div>');
insertBefore(element, '<div>Test</div>');
```

-----
---

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

```javascript
const element = document.getElementById('element');

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

## License
Expand Down
14 changes: 9 additions & 5 deletions dist/dom-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.domHelpers = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
"use strict";

Object.defineProperty(_exports, "__esModule", {
Expand All @@ -20,13 +20,17 @@

var _this = void 0;

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;
/**
Expand Down
4 changes: 2 additions & 2 deletions dist/dom-helpers.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@three11/dom-helpers",
"version": "1.0.0",
"version": "1.1.0",
"description": "Helper functions for faster DOM scripting",
"main": "dist/dom-helpers.js",
"scripts": {
Expand Down Expand Up @@ -43,17 +43,8 @@
"devDependencies": {
"@babel/cli": "7.14.3",
"@babel/core": "7.14.3",
"@babel/plugin-proposal-class-properties": "7.13.0",
"@babel/plugin-proposal-decorators": "7.14.2",
"@babel/plugin-proposal-export-namespace-from": "7.14.2",
"@babel/plugin-proposal-function-sent": "7.12.13",
"@babel/plugin-proposal-json-strings": "7.14.2",
"@babel/plugin-proposal-numeric-separator": "7.14.2",
"@babel/plugin-proposal-throw-expressions": "7.12.13",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/plugin-syntax-import-meta": "7.10.4",
"@babel/plugin-transform-modules-umd": "7.14.0",
"@babel/preset-env": "7.14.2",
"babel-loader": "8.2.2",
"babel-minify": "0.5.1"
}
}
3 changes: 2 additions & 1 deletion src/dom-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export const isElementVisibleInViewport = (el, isPartiallyVisible = false) => {
const { innerWidth, innerHeight } = window;

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;
};

Expand Down
Loading

0 comments on commit 4af7057

Please sign in to comment.