@peter.naydenov/shortcuts 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Changelog.md CHANGED
@@ -1,13 +1,23 @@
1
1
  ## Release History
2
2
 
3
+
4
+
5
+ ### 1.1.1 (2023-09-30)
6
+ - [x] Mouse faster response when maxClicks achived. (maxClicks is automatically calculated according shortcut definitions);
7
+
8
+
9
+
3
10
  ### 1.1.0 (2023-09-30)
4
11
  - [x] Method `emit` was added. Not documented yet;
5
12
 
13
+
14
+
6
15
  ### 1.0.1 (2023-09-23)
7
16
  - [x] Mouse click: preventDefault();
8
17
  - [x] Dependencies update: @peter.naydenov/notice - v.2.2.1
9
18
 
10
19
 
20
+
11
21
  ### 1.0.0 (2023-08-14)
12
22
 
13
23
  - [x] Initial code;
package/README.md CHANGED
@@ -22,7 +22,7 @@ The shortcuts definition includes a context name and a set of rules(object). The
22
22
  // { context: { shortcutName: actionFunction } }
23
23
  // or
24
24
  // { context: { shortcutName: [ actionFunction1, actionFunction2 ] }}
25
- ```
25
+
26
26
  // Shortcut definition object:
27
27
  {
28
28
  contextName : {
@@ -40,6 +40,7 @@ The shortcuts definition includes a context name and a set of rules(object). The
40
40
  }
41
41
  }
42
42
  ```
43
+
43
44
  Load a shortcut definition by calling `load` method.
44
45
 
45
46
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peter.naydenov/shortcuts",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Context control of shortcuts based on keyboard and mouse events",
5
5
  "keywords": [
6
6
  "shortcut",
@@ -25,6 +25,7 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@vitejs/plugin-react": "^4.1.0",
28
+ "ask-for-promise": "^1.3.1",
28
29
  "chai": "^4.3.10",
29
30
  "cypress": "^13.3.0",
30
31
  "mocha": "^10.2.0",
package/src/listen.js CHANGED
@@ -100,14 +100,14 @@ function listen ( dependencies, options, currentContext ) { // Listen for inpu
100
100
  mouseIgnore = setTimeout ( () => mouseIgnore=null, mouseWait )
101
101
  return
102
102
  }
103
+ mouseTarget = findTarget (event.target, clickTarget )
104
+ mouseDomEvent = event
105
+ count++
103
106
  if ( count === options.maxClicks ) {
104
107
  mouseSequenceEnd ()
105
108
  mouseIgnore = setTimeout ( () => mouseIgnore=null, mouseWait )
106
109
  return
107
110
  }
108
- mouseTarget = findTarget (event.target, clickTarget )
109
- mouseDomEvent = event
110
- count++
111
111
  mouseTimer = setTimeout ( mouseSequenceEnd, mouseWait )
112
112
  })
113
113
 
@@ -119,14 +119,14 @@ function listen ( dependencies, options, currentContext ) { // Listen for inpu
119
119
  mouseIgnore = setTimeout ( () => mouseIgnore=null, mouseWait )
120
120
  return
121
121
  }
122
- if ( count === options.maxClicks ) {
122
+ mouseTarget = findTarget ( event.target, clickTarget )
123
+ mouseDomEvent = event
124
+ count++
125
+ if ( count >= options.maxClicks ) {
123
126
  mouseSequenceEnd ()
124
127
  mouseIgnore = setTimeout ( () => mouseIgnore=null, mouseWait )
125
128
  return
126
129
  }
127
- mouseTarget = findTarget ( event.target, clickTarget )
128
- mouseDomEvent = event
129
- count++
130
130
  mouseTimer = setTimeout ( mouseSequenceEnd, mouseWait )
131
131
  })
132
132
  } // listenMouse func.
@@ -32,7 +32,7 @@ it ( 'Simple shortcut', done => {
32
32
  let res = false;
33
33
  short.changeContext ( 'general' )
34
34
  cy.get('body').type ( '{shift}a' )
35
- cy.wait ( 100 ) // Default wait sequence timeout is 480 ms
35
+ cy.wait ( 30 ) // Default wait sequence timeout is 480 ms, but maxSequence is 1, so we don't need to wait for timeout
36
36
  .then ( () => {
37
37
  expect ( a ).to.be.true
38
38
  done ()
@@ -81,11 +81,10 @@ it ( 'Single mouse click', done => {
81
81
  })
82
82
  short.changeContext ( 'extra' )
83
83
  cy.get('#rspan').click ()
84
- cy.wait ( 350 ) // Default wait mouse timeout is 320 ms
85
- .then ( () => {
86
- expect ( a ).to.be.true
87
- done ()
88
- })
84
+ cy.wait ( 10 ) // Default wait mouse timeout is 320 ms, but maxClicks is 1, so we don't need to wait for timeout
85
+ .then ( () => expect ( a ).to.be.true )
86
+ cy.wait ( 300 ) // ...but mouseIgnore still active, so we better wait to not interfere with next test
87
+ .then ( () => done() )
89
88
  }) // it mouse click
90
89
 
91
90