Improved button group stacking behaviour if ThrowPropsPlugin is not loaded.
This commit is contained in:
Vendored
+28
-22
@@ -2963,8 +2963,8 @@
|
||||
* or a Theme object.
|
||||
* @param {number} [opts.minWidth=44] - Button: The minimum width of one button.
|
||||
* @param {number} [opts.minHeight=44] - Button: The minimum height of one button.
|
||||
* @param {number} [opts.maxWidth] - The maximum width of the button group. If the buttons are wider than the maximum width, the buttons get stacked. Note: The buttons can only be stacked if margin is not zero.
|
||||
* @param {number} [opts.maxHeight] - The maximum height of the button group. If the buttons are higher than the maximum height, the buttons get stacked. Note: The buttons can only be stacked if margin is not zero.
|
||||
* @param {number} [opts.maxWidth] - The maximum width of the button group. If the buttons are wider than the maximum width, the buttons get stacked. Note: The buttons can only be stacked if margin is not zero. Note 2: Load the Greensock ThrowPropsPlugin for smoother animations.
|
||||
* @param {number} [opts.maxHeight] - The maximum height of the button group. If the buttons are higher than the maximum height, the buttons get stacked. Note: The buttons can only be stacked if margin is not zero. Note 2: Load the Greensock ThrowPropsPlugin for smoother animations.
|
||||
* @param {number} [opts.stackPadding=10] - The padding for stacked buttons.
|
||||
* @param {PIXI.Application} [opts.app] - The PixiJS Application. Must be set if you want to use the mousewheel to scroll your button group. Only used when the buttons are stacked (with maxWidth or maxHeight).
|
||||
* @param {number} [opts.padding=Theme.padding] - Button: The inner spacing (distance from icon and/or label) the the border.
|
||||
@@ -3377,27 +3377,27 @@
|
||||
|
||||
this.capture(event);
|
||||
|
||||
if (typeof ThrowPropsPlugin != 'undefined') {
|
||||
const throwProps = { x: { velocity: 'auto' }, y: { velocity: 'auto' } };
|
||||
const throwProps = { x: { velocity: 'auto' }, y: { velocity: 'auto' } };
|
||||
|
||||
if (this.opts.orientation === 'horizontal') {
|
||||
const distanceToLeft = this.container.x;
|
||||
const distanceToRight = this.opts.maxWidth - this.container.x - this.__initWidth;
|
||||
if (distanceToLeft > 0 && distanceToLeft > distanceToRight) {
|
||||
throwProps.x.end = 0;
|
||||
} else if (distanceToRight > 0 && distanceToRight > distanceToLeft) {
|
||||
throwProps.x.end = this.opts.maxWidth - this.__initWidth;
|
||||
}
|
||||
} else {
|
||||
const distanceToTop = this.container.y;
|
||||
const distanceToBottom = this.opts.maxHeight - this.container.y - this.container.height;
|
||||
if (distanceToTop > 0 && distanceToTop > distanceToBottom) {
|
||||
throwProps.y.end = 0;
|
||||
} else if (distanceToBottom > 0 && distanceToBottom > distanceToTop) {
|
||||
throwProps.y.end = this.opts.maxHeight - this.container.height;
|
||||
}
|
||||
if (this.opts.orientation === 'horizontal') {
|
||||
const distanceToLeft = this.container.x;
|
||||
const distanceToRight = this.opts.maxWidth - this.container.x - this.__initWidth;
|
||||
if (distanceToLeft > 0 && distanceToLeft > distanceToRight) {
|
||||
throwProps.x.end = 0;
|
||||
} else if (distanceToRight > 0 && distanceToRight > distanceToLeft) {
|
||||
throwProps.x.end = this.opts.maxWidth - this.__initWidth;
|
||||
}
|
||||
} else {
|
||||
const distanceToTop = this.container.y;
|
||||
const distanceToBottom = this.opts.maxHeight - this.container.y - this.container.height;
|
||||
if (distanceToTop > 0 && distanceToTop > distanceToBottom) {
|
||||
throwProps.y.end = 0;
|
||||
} else if (distanceToBottom > 0 && distanceToBottom > distanceToTop) {
|
||||
throwProps.y.end = this.opts.maxHeight - this.container.height;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof ThrowPropsPlugin != 'undefined') {
|
||||
ThrowPropsPlugin.to(
|
||||
this.container.position,
|
||||
{
|
||||
@@ -3409,6 +3409,12 @@
|
||||
0.8,
|
||||
0.4
|
||||
);
|
||||
} else {
|
||||
if (this.opts.orientation === 'horizontal' && throwProps.x.end != null) {
|
||||
TweenMax.to(this.container.position, 0.3, { x: throwProps.x.end, onUpdate: this.stack.bind(this) });
|
||||
} else if (this.opts.orientation === 'vertical' && throwProps.y.end != null) {
|
||||
TweenMax.to(this.container.position, 0.3, { y: throwProps.y.end, onUpdate: this.stack.bind(this) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3462,7 +3468,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
_stackHorizontal() {
|
||||
const sorted = [];
|
||||
@@ -3510,7 +3516,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
_stackVertical() {
|
||||
const sorted = [];
|
||||
|
||||
Reference in New Issue
Block a user