Removed Greensock ThrowPropsPlugin as an dependency.

This commit is contained in:
Sebastian Kupke 2019-03-29 09:11:21 +01:00
parent fe36b66dc5
commit 6c2ae3b433
3 changed files with 82 additions and 23 deletions

78
dist/iwmlib.pixi.js vendored
View File

@ -11306,8 +11306,8 @@
* @param {*} text
* @param {*} style
* @param {*} width
* @returns
* @memberof Hypenate
* @returns {string}
*/
static splitLines(text, style, width) {
const pixiStyle = new PIXI.TextStyle(style);
@ -11322,6 +11322,47 @@
}
}
class TextLabel extends PIXI.Text {
/**
*Creates an instance of TextLabel.
* @param {string} text - The string that you would like the text to display
* @param {object|PIXI.TextStyle} [style] - The style parameters
* @param {canvas}
* @memberof TextLabel
*/
constructor(text, style=null, canvas=null, { minZoom = 0.1, maxZoom = 10} = {}) {
super(text, style, canvas );
this.normFontSize = this.style.fontSize;
this.minZoom = minZoom;
this.maxZoom = maxZoom;
}
zoom(factor) {
let oldValue = parseFloat(this.style.fontSize) / this.normFontSize;
let value = oldValue * factor;
this.setZoom(value);
}
setZoom(value) {
let oldValue = parseFloat(this.style.fontSize) / this.normFontSize;
if (value > this.maxZoom) {
value = this.maxZoom;
}
if (value < this.minZoom) {
value = this.minZoom;
}
if (value != oldValue) {
this.style.fontSize = Math.max(value * this.normFontSize, 1);
}
}
setZoomAndScale(scale) {
this.scale.set(1 / scale);
this.setZoom(scale);
}
}
/**
* A specialization of the PIXI.Graphics class that allows to
* resuse and place labels across different layout variants
@ -11343,7 +11384,7 @@
}
_createText(label, fontInfo) {
return new PIXI.Text(label, fontInfo)
return new TextLabel(label, fontInfo)
}
@ -11360,7 +11401,7 @@
* maxHeight: {number} truncates text that needs more space and adds ellipsis
* maxWidth: {number} word wraps text using hyphenation if possible
* @param {*} [fontInfo=FontInfo.normal] - Defines PIXI.TextStyle attributes
* @returns {PIXI.Text} instance
* @returns {PIXI.Text} - instance
* @memberof LabeledGraphics
*/
ensureLabel(key, label, attrs = {}, fontInfo = FontInfo.normal) {
@ -11429,7 +11470,7 @@
* @param {*} text
* @param {*} style
* @param {*} [maxLines=Infinity]
* @returns
* @returns {string}
* @memberof LabeledGraphics
*/
truncateLabel(text, style, maxLines = Infinity) {
@ -11465,7 +11506,7 @@
* Returns the label for the given key.
*
* @param {*} key
* @returns
* @returns {Object}
* @memberof LabeledGraphics
*/
getLabel(key) {
@ -12195,7 +12236,9 @@
this.killTweens();
this.deltas = [];
this.validScroll();
ThrowPropsPlugin.track(this, 'delta');
if (typeof ThrowPropsPlugin != "undefined") {
ThrowPropsPlugin.track(this, 'delta');
}
}
onMove(event, interaction) {
@ -12212,8 +12255,11 @@
}
onEnd(event, interaction) {
let vel = ThrowPropsPlugin.getVelocity(this, 'delta');
ThrowPropsPlugin.untrack(this);
if (typeof ThrowPropsPlugin != "undefined") {
let vel = ThrowPropsPlugin.getVelocity(this, 'delta');
ThrowPropsPlugin.untrack(this);
}
this.killTweens();
this.redraw();
@ -13863,7 +13909,9 @@
};
TweenLite.killTweensOf(this.container.position, {x: true, y: true});
ThrowPropsPlugin.track(this.container.position, 'x,y');
if (typeof ThrowPropsPlugin != "undefined") {
ThrowPropsPlugin.track(this.container.position, 'x,y');
}
}
/**
@ -13917,11 +13965,13 @@
};
}
ThrowPropsPlugin.to(this.container.position, {
throwProps,
ease: Strong.easeOut,
onComplete: () => ThrowPropsPlugin.untrack(this.container.position)
}, .8, .4);
if (typeof ThrowPropsPlugin != "undefined") {
ThrowPropsPlugin.to(this.container.position, {
throwProps,
ease: Strong.easeOut,
onComplete: () => ThrowPropsPlugin.untrack(this.container.position)
}, .8, .4);
}
}
}

View File

@ -258,7 +258,9 @@ export default class List extends PIXI.Container {
}
TweenLite.killTweensOf(this.container.position, {x: true, y: true})
ThrowPropsPlugin.track(this.container.position, 'x,y')
if (typeof ThrowPropsPlugin != "undefined") {
ThrowPropsPlugin.track(this.container.position, 'x,y')
}
}
/**
@ -312,11 +314,13 @@ export default class List extends PIXI.Container {
}
}
ThrowPropsPlugin.to(this.container.position, {
throwProps,
ease: Strong.easeOut,
onComplete: () => ThrowPropsPlugin.untrack(this.container.position)
}, .8, .4)
if (typeof ThrowPropsPlugin != "undefined") {
ThrowPropsPlugin.to(this.container.position, {
throwProps,
ease: Strong.easeOut,
onComplete: () => ThrowPropsPlugin.untrack(this.container.position)
}, .8, .4)
}
}
}

View File

@ -745,7 +745,9 @@ export default class Timeline extends BitmapLabeledGraphics {
this.killTweens()
this.deltas = []
this.validScroll()
ThrowPropsPlugin.track(this, 'delta')
if (typeof ThrowPropsPlugin != "undefined") {
ThrowPropsPlugin.track(this, 'delta')
}
}
onMove(event, interaction) {
@ -762,8 +764,11 @@ export default class Timeline extends BitmapLabeledGraphics {
}
onEnd(event, interaction) {
let vel = ThrowPropsPlugin.getVelocity(this, 'delta')
ThrowPropsPlugin.untrack(this)
if (typeof ThrowPropsPlugin != "undefined") {
let vel = ThrowPropsPlugin.getVelocity(this, 'delta')
ThrowPropsPlugin.untrack(this)
}
this.killTweens()
this.redraw()