-
Notifications
You must be signed in to change notification settings - Fork 110
Feature/longpress #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| } | ||
|
|
||
| registerKeyupHandler(keyhandler){ | ||
| this._keyupListener = e => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily a style issue, but I'd prefer this arrow function to have () around arguments.
src/application/Application.mjs
Outdated
| } | ||
|
|
||
| /** | ||
| * register and starts a timer for the pressed key. Timer will be cleared when the key is released |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: Registers and starts (...)
src/application/Application.mjs
Outdated
| * before the timer goes off. | ||
| * | ||
| * If key is not release (keyup) the longpress handler will be fired. | ||
| * configuration can be via the Components template: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: Configuration
src/application/Application.mjs
Outdated
| const focusPath = this.__getFocusPath(); | ||
| const consumer = focusPath.pop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I it possible to use this.focusPath instead to avoid recalculation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, we can indeed grab the current calculated focus path
src/application/Application.mjs
Outdated
| this._updateAttachedFlag(); | ||
| this._updateEnabledFlag(); | ||
|
|
||
| if (this.__keypressTimers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this.__keypressTimers is a Map object created in constructor and never reassigned, this will always yield true. You may also want to call this._keypressTimers.clear() to get rid of dangling references.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valid point, changed the condition to validate map size and clear the map
tests/keyhandler/test.keyhandler.js
Outdated
| class TestApp extends lng.Application { | ||
| static _template(){ | ||
| return { | ||
| A:{type: ComponentA} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: missing space after A:
tests/keyhandler/test.keyhandler.js
Outdated
| }); | ||
|
|
||
| describe('Component', function() { | ||
| it('should handle keydown', function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: missing space after ()
tests/keyhandler/test.keyhandler.js
Outdated
| chai.assert(a.handled.indexOf("_handleUp") !== -1); | ||
| }); | ||
|
|
||
| it('should handle keyup', function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
tests/keyhandler/test.keyhandler.js
Outdated
| chai.assert(a.handled.indexOf("_handleUpRelease") !== -1); | ||
| }); | ||
|
|
||
| it('should handle captureKey', function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
| static _template(){ | ||
| return { | ||
| A:{ | ||
| type: ComponentA, | ||
| // configuration how long a key should be pressed before it's longpress counterpart fires | ||
| longpress:{up:700, down:600, left:800, right:900} | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent styling.
|
Code style updated |
src/application/Application.mjs
Outdated
|
|
||
| this.updateFocusPath(); | ||
|
|
||
| const consumer = [...path].pop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't path[path.length - 1] simpler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, is updated now
|
|
||
| before(() => { | ||
| class TestApp extends lng.Application { | ||
| static _template(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: missing space before {
| }); | ||
|
|
||
| describe('Component', function() { | ||
| const repeat = (iterations)=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: missing spaces before and after =>
|
|
||
| describe('Component', function() { | ||
| const repeat = (iterations)=>{ | ||
| return new Promise((resolve)=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
tests/keyhandler/test.keyhandler.js
Outdated
| } | ||
| } | ||
|
|
||
| class ComponentA extends lng.Component{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: missing space before {
src/application/Application.mjs
Outdated
| if (config[lookup]) { | ||
| const timeout = config[lookup]; | ||
| if (!Utils.isNumber(timeout)) { | ||
| element._throwError("config value for longpress must be a number") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: Missing ;
src/application/Application.mjs
Outdated
| if (!Utils.isNumber(timeout)) { | ||
| element._throwError("config value for longpress must be a number") | ||
| } else { | ||
| this.__keypressTimers.set(key,setTimeout(()=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: missing spaces between and after =>
| window.addEventListener('keydown', this._keydownListener); | ||
| } | ||
|
|
||
| registerKeyupHandler(keyhandler){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: missing space before {
|
|
||
| class ComponentA extends lng.Component { | ||
| static _template() { | ||
| return {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: missing ;
g-zachar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated comments
Resolve #48