-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat: add useAnimation option to WheelInput #189
Merged
malangfox
merged 7 commits into
naver:master
from
malangfox:feat-wheelinput-useanimation
Jun 13, 2022
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1db2a64
feat: add useAnimation option to WheelInput
malangfox 9f9b02a
fix: remove inappropriate inline functions
malangfox 6a70c89
refactor: change access modifier and name of applyScale
malangfox 144d828
skip: apply reviews
malangfox caaefb3
test: update manual test
malangfox 144429d
chore: set default value of useAnimation to false
malangfox 7c2677f
test: update mouse wheel test
malangfox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,16 @@ export interface WheelInputOption { | |
scale?: number; | ||
releaseDelay?: number; | ||
useNormalized?: boolean; | ||
useAnimation?: boolean; | ||
} | ||
|
||
/** | ||
* @typedef {Object} WheelInputOption The option object of the eg.Axes.WheelInput module | ||
* @ko eg.Axes.WheelInput 모듈의 옵션 객체 | ||
* @param {Number} [scale=1] Coordinate scale that a user can move<ko>사용자의 동작으로 이동하는 좌표의 배율</ko> | ||
* @param {Number} [releaseDelay=300] Millisecond that trigger release event after last input<ko>마지막 입력 이후 release 이벤트가 트리거되기까지의 밀리초</ko> | ||
* @param {Boolean} [useNormalized=true] Whether to calculate scroll speed the same in all browsers<ko>모든 브라우저에서 스크롤 속도를 동일하게 처리할지 여부</ko> | ||
* @param {Boolean} [useAnimation=true] Whether to process coordinate changes through the mouse wheel as a continuous animation<ko>마우스 휠을 통한 좌표 변화를 연속적인 애니메이션으로 처리할지 여부</ko> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Magic mouse users should feel like a magic mouse, and a normal mouse should feel like a magic mouse. This option will behave strangely for either a Magic Mouse user or a regular mouse. |
||
**/ | ||
|
||
/** | ||
|
@@ -50,6 +53,7 @@ export class WheelInput implements InputType { | |
scale: 1, | ||
releaseDelay: 300, | ||
useNormalized: true, | ||
useAnimation: true, | ||
}, | ||
...options, | ||
}; | ||
|
@@ -127,7 +131,12 @@ export class WheelInput implements InputType { | |
(event.deltaY > 0 ? -1 : 1) * | ||
this.options.scale * | ||
(this.options.useNormalized ? 1 : Math.abs(event.deltaY)); | ||
this._observer.change(this, event, toAxis(this.axes, [offset]), true); | ||
this._observer.change( | ||
this, | ||
event, | ||
toAxis(this.axes, [offset]), | ||
this.options.useAnimation | ||
); | ||
clearTimeout(this._timer); | ||
|
||
this._timer = setTimeout(() => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think while
_applyScale
shows what it actually does with its name (at least a part of it),_getVector
does not reveal what's happening inside.Why did you change its name like this?
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.
It was a function which applies direction and scale to the given offset and velocity.
It originally had the name
getOffset
, but the name was changed while calculating the velocity other than the offset.Meanwhile, the class that inherits PanInput from view360 also overrides this. It don't just use scale and direction and use other calculations.
Instead of
applyScale
, I decided to name it getting a vector which meaning both velocity and offset.We'll be using these names in
RotationPanInput
at view360 as well. Any good suggestions will be welcome.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.
The name
Vector
is too general, I mean, vector of what is not included.If you want to use the term
vector
, I would suggestgetOffsetVector
or something.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.
The original name
getOffset
looks better thangetOffsetVector
.But I'm little bit concerned about using this name for the velocity calculation as well.
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 think you can consider what would be better, and choose it yourself.
Just remember to choose self-representative names for it.