Skip to content

Commit a9dd631

Browse files
JustinJustin
Justin
authored and
Justin
committed
cl
1 parent 439d670 commit a9dd631

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/Viewport.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ export class Viewport extends Container
194194
private _worldHeight?: number | null;
195195
private _disableOnContextMenu = (e: MouseEvent) => e.preventDefault();
196196

197+
public _wheelAxis?: 'all' | 'x' | 'y';
198+
197199
/**
198200
* @param {IViewportOptions} ViewportOptions
199201
* @param {number} [options.screenWidth=window.innerWidth]

src/plugins/ClampZoom.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,29 @@ export class ClampZoom extends Plugin
7878
if (this.options.minWidth !== null && width < this.options.minWidth)
7979
{
8080
const original = this.parent.scale.x;
81+
console.log('-- minwidth', this.parent._wheelAxis);
8182

8283
this.parent.fitWidth(this.options.minWidth, false, false, true);
83-
this.parent.scale.y *= this.parent.scale.x / original;
8484
width = this.parent.worldScreenWidth;
85-
height = this.parent.worldScreenHeight;
85+
86+
if (this.parent._wheelAxis && ['all', 'y'].includes(this.parent._wheelAxis)) {
87+
this.parent.scale.y *= this.parent.scale.x / original;
88+
height = this.parent.worldScreenHeight;
89+
}
8690
this.parent.emit('zoomed', { viewport: this.parent, type: 'clamp-zoom' });
8791
}
8892
if (this.options.maxWidth !== null && width > this.options.maxWidth)
8993
{
9094
const original = this.parent.scale.x;
95+
console.log('-- maxwidth', this.parent._wheelAxis);
9196

9297
this.parent.fitWidth(this.options.maxWidth, false, false, true);
93-
this.parent.scale.y *= this.parent.scale.x / original;
9498
width = this.parent.worldScreenWidth;
95-
height = this.parent.worldScreenHeight;
99+
100+
if (this.parent._wheelAxis && ['all', 'y'].includes(this.parent._wheelAxis)) {
101+
this.parent.scale.y *= this.parent.scale.x / original;
102+
height = this.parent.worldScreenHeight;
103+
}
96104
this.parent.emit('zoomed', { viewport: this.parent, type: 'clamp-zoom' });
97105
}
98106
if (this.options.minHeight !== null && height < this.options.minHeight)

src/plugins/Wheel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export class Wheel extends Plugin
110110
{
111111
super(parent);
112112
this.options = Object.assign({}, DEFAULT_WHEEL_OPTIONS, options);
113+
this.parent._wheelAxis = this.options.axis;
113114
this.keyIsPressed = false;
114115

115116
if (this.options.keyToPress)

0 commit comments

Comments
 (0)