-
Notifications
You must be signed in to change notification settings - Fork 184
Zoom along a single axis #470
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,21 +78,29 @@ export class ClampZoom extends Plugin | |
if (this.options.minWidth !== null && width < this.options.minWidth) | ||
{ | ||
const original = this.parent.scale.x; | ||
console.log('-- minwidth', this.parent._wheelAxis); | ||
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. can you please remove the console.log? |
||
|
||
this.parent.fitWidth(this.options.minWidth, false, false, true); | ||
this.parent.scale.y *= this.parent.scale.x / original; | ||
width = this.parent.worldScreenWidth; | ||
height = this.parent.worldScreenHeight; | ||
|
||
if (this.parent._wheelAxis && ['all', 'y'].includes(this.parent._wheelAxis)) { | ||
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. This is needlessly expensive. I'd switch this to a simple comparison. |
||
this.parent.scale.y *= this.parent.scale.x / original; | ||
height = this.parent.worldScreenHeight; | ||
} | ||
this.parent.emit('zoomed', { viewport: this.parent, type: 'clamp-zoom' }); | ||
} | ||
if (this.options.maxWidth !== null && width > this.options.maxWidth) | ||
{ | ||
const original = this.parent.scale.x; | ||
console.log('-- maxwidth', this.parent._wheelAxis); | ||
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. can you please remove the console.log? |
||
|
||
this.parent.fitWidth(this.options.maxWidth, false, false, true); | ||
this.parent.scale.y *= this.parent.scale.x / original; | ||
width = this.parent.worldScreenWidth; | ||
height = this.parent.worldScreenHeight; | ||
|
||
if (this.parent._wheelAxis && ['all', 'y'].includes(this.parent._wheelAxis)) { | ||
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. Also switch to simple comparison. |
||
this.parent.scale.y *= this.parent.scale.x / original; | ||
height = this.parent.worldScreenHeight; | ||
} | ||
this.parent.emit('zoomed', { viewport: this.parent, type: 'clamp-zoom' }); | ||
} | ||
if (this.options.minHeight !== null && height < this.options.minHeight) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,7 @@ export class Wheel extends Plugin | |
{ | ||
super(parent); | ||
this.options = Object.assign({}, DEFAULT_WHEEL_OPTIONS, options); | ||
this.parent._wheelAxis = this.options.axis; | ||
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. This does not have to be in the wheel at all as it's not a wheel-specific concept. |
||
this.keyIsPressed = false; | ||
|
||
if (this.options.keyToPress) | ||
|
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.
If it's public, why the underscore? Should also make it non-optional and always have a value of one of the three, defaulting to 'all'. Possibly rename to something more generic like
scaleAxis
since scaling is not solely done by wheel, and wheel is not a global concept in this file but is handled by a plugin.