Skip to content

Commit

Permalink
Version bump to 5.2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ten1seven committed May 25, 2022
1 parent 1fa9216 commit 6a5e427
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 21 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,17 @@ _What Input_ works in all modern browsers.

## Changelog

### v5.2.12

- **Fixed:** Improved detection and respect for of `data-whatpersist` before `DOMContentLoaded`. Fix via [FanFataL](https://github.com/FanFataL).

### v5.2.11

- **Fixed:** Adds `useCapture` so events can be detected before `preventDefault` cancels them on local listeners (h/t [jojo080889](https://github.com/jojo080889)).

### v5.2.8 - 5.2.10

- **Added:** TypeScript definitions via @greypants
- **Added:** TypeScript definitions via [greypants](https://github.com/greypants).

### v5.2.7

Expand Down
2 changes: 1 addition & 1 deletion dist/what-input.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* what-input - A global utility for tracking the current input method (mouse, keyboard or touch).
* @version v5.2.11
* @version v5.2.12
* @link https://github.com/ten1seven/what-input
* @license MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/what-input.min.js

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

2 changes: 1 addition & 1 deletion dist/what-input.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "what-input",
"version": "5.2.11",
"version": "5.2.12",
"description": "A global utility for tracking the current input method (mouse, keyboard or touch).",
"main": "dist/what-input.js",
"types": "src/scripts/what-input.d.ts",
Expand Down
32 changes: 16 additions & 16 deletions src/scripts/what-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ module.exports = (() => {
}

// checks conditions before updating new input
const setInput = event => {
const setInput = (event) => {
const eventKey = event.which
let value = inputMap[event.type]

Expand Down Expand Up @@ -246,7 +246,7 @@ module.exports = (() => {
}

// updates the doc and `inputTypes` array with new input
const doUpdate = which => {
const doUpdate = (which) => {
docElem.setAttribute(
'data-what' + which,
which === 'input' ? currentInput : currentIntent
Expand All @@ -256,7 +256,7 @@ module.exports = (() => {
}

// updates input intent for `mousemove` and `pointermove`
const setIntent = event => {
const setIntent = (event) => {
let value = inputMap[event.type]

if (value === 'pointer') {
Expand All @@ -269,9 +269,9 @@ module.exports = (() => {
// only execute if scrolling isn't happening
if (
((!isScrolling && !validateTouch(value)) ||
((isScrolling && event.type === 'wheel') ||
event.type === 'mousewheel' ||
event.type === 'DOMMouseScroll')) &&
(isScrolling && event.type === 'wheel') ||
event.type === 'mousewheel' ||
event.type === 'DOMMouseScroll') &&
currentIntent !== value
) {
currentIntent = value
Expand All @@ -281,7 +281,7 @@ module.exports = (() => {
}
}

const setElement = event => {
const setElement = (event) => {
if (!event.target.nodeName) {
// If nodeName is undefined, clear the element
// This can happen if click inside an <svg> element.
Expand Down Expand Up @@ -321,7 +321,7 @@ module.exports = (() => {
* utilities
*/

const pointerType = event => {
const pointerType = (event) => {
if (typeof event.pointerType === 'number') {
return pointerMap[event.pointerType]
} else {
Expand All @@ -331,7 +331,7 @@ module.exports = (() => {
}

// prevent touch detection from being overridden by event execution order
const validateTouch = value => {
const validateTouch = (value) => {
const timestamp = Date.now()

const touchIsValid =
Expand Down Expand Up @@ -363,7 +363,7 @@ module.exports = (() => {
}

// runs callback functions
const fireFunctions = type => {
const fireFunctions = (type) => {
for (let i = 0, len = functionList.length; i < len; i++) {
if (functionList[i].type === type) {
functionList[i].fn.call(
Expand All @@ -375,15 +375,15 @@ module.exports = (() => {
}

// finds matching element in an object
const objPos = match => {
const objPos = (match) => {
for (let i = 0, len = functionList.length; i < len; i++) {
if (functionList[i].fn === match) {
return i
}
}
}

const detectScrolling = event => {
const detectScrolling = (event) => {
if (mousePos.x !== event.screenX || mousePos.y !== event.screenY) {
isScrolling = false

Expand Down Expand Up @@ -438,7 +438,7 @@ module.exports = (() => {
// opt: 'intent'|'input'
// 'input' (default): returns the same value as the `data-whatinput` attribute
// 'intent': includes `data-whatintent` value if it's different than `data-whatinput`
ask: opt => {
ask: (opt) => {
return opt === 'intent' ? currentIntent : currentInput
},

Expand All @@ -448,12 +448,12 @@ module.exports = (() => {
},

// overwrites ignored keys with provided array
ignoreKeys: arr => {
ignoreKeys: (arr) => {
ignoreMap = arr
},

// overwrites specific char keys to update on
specificKeys: arr => {
specificKeys: (arr) => {
specificMap = arr
},

Expand All @@ -467,7 +467,7 @@ module.exports = (() => {
})
},

unRegisterOnChange: fn => {
unRegisterOnChange: (fn) => {
const position = objPos(fn)

if (position || position === 0) {
Expand Down

0 comments on commit 6a5e427

Please sign in to comment.