Skip to content
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
merged 7 commits into from
Jun 13, 2022

Conversation

malangfox
Copy link
Contributor

Details

As #174 is applied, WheelInput always uses an animation to smooth out coordinate movement through the mouse wheel.
However, there are use cases where playing smooth animation is unnecessary and the coordinate change needs to be applied immediately.

This provides an option whether to use animation for the coordinate change of WheelInput.

}

/**
* @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>
Copy link
Member

Choose a reason for hiding this comment

The 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.

@@ -338,6 +338,19 @@ export class PanInput implements InputType {
});
}

protected _getVector(properties: number[], direction: boolean[]): number[] {
Copy link
Member

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?

Copy link
Contributor Author

@malangfox malangfox Jun 8, 2022

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.

Copy link
Member

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 suggest getOffsetVector or something.

Copy link
Contributor Author

@malangfox malangfox Jun 9, 2022

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 than getOffsetVector.
But I'm little bit concerned about using this name for the velocity calculation as well.

Copy link
Member

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.

Copy link
Member

@WoodNeck WoodNeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@daybrush daybrush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test the wheel with a trackpad. The functionality of useAnimation(true) is very unstable.

useAnimation is more likely to be used as false.

@malangfox malangfox merged commit eab8545 into naver:master Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants