Fixed flipeffect bug.

This commit is contained in:
Sebastian Kupke 2019-10-02 15:00:08 +02:00
parent 7dd7142455
commit ce25b1dbae
5 changed files with 24 additions and 9 deletions

5
dist/iwmlib.js vendored
View File

@ -5038,9 +5038,13 @@
} }
start({ targetCenter = null } = {}) { start({ targetCenter = null } = {}) {
console.log('start');
this.flippable.showFront();
if (this.preloadBack) { if (this.preloadBack) {
console.log('preloadBack');
this.flippable.start({ duration: this.flipDuration, targetCenter }); this.flippable.start({ duration: this.flipDuration, targetCenter });
} else { } else {
console.log('no back preload');
let back = this.cardWrapper.querySelector('.back'); let back = this.cardWrapper.querySelector('.back');
let flippable = this.flippable; let flippable = this.flippable;
this.backLoader.load(back).then(loader => { this.backLoader.load(back).then(loader => {
@ -5248,6 +5252,7 @@
start({ targetCenter = null } = {}) { start({ targetCenter = null } = {}) {
this.bringToFront(); this.bringToFront();
console.log('flippable start', this.flipped);
if (!this.flipped) { if (!this.flipped) {
this.startX = this.element._gsTransform.x; this.startX = this.element._gsTransform.x;
this.startY = this.element._gsTransform.y; this.startY = this.element._gsTransform.y;

11
dist/iwmlib.pixi.js vendored
View File

@ -8336,9 +8336,13 @@
} }
start({ targetCenter = null } = {}) { start({ targetCenter = null } = {}) {
console.log('start');
this.flippable.showFront();
if (this.preloadBack) { if (this.preloadBack) {
console.log('preloadBack');
this.flippable.start({ duration: this.flipDuration, targetCenter }); this.flippable.start({ duration: this.flipDuration, targetCenter });
} else { } else {
console.log('no back preload');
let back = this.cardWrapper.querySelector('.back'); let back = this.cardWrapper.querySelector('.back');
let flippable = this.flippable; let flippable = this.flippable;
this.backLoader.load(back).then(loader => { this.backLoader.load(back).then(loader => {
@ -8546,6 +8550,7 @@
start({ targetCenter = null } = {}) { start({ targetCenter = null } = {}) {
this.bringToFront(); this.bringToFront();
console.log('flippable start', this.flipped);
if (!this.flipped) { if (!this.flipped) {
this.startX = this.element._gsTransform.x; this.startX = this.element._gsTransform.x;
this.startY = this.element._gsTransform.y; this.startY = this.element._gsTransform.y;
@ -10564,7 +10569,9 @@
let canvas = globalScatterLoaderCanvas; let canvas = globalScatterLoaderCanvas;
canvas.width = w; canvas.width = w;
canvas.height = h; canvas.height = h;
let renderer = new PIXI.Renderer(w, h, { let renderer = new PIXI.Renderer({
width: w,
height: h,
view: canvas, view: canvas,
resolution: resolution resolution: resolution
}); });
@ -10645,7 +10652,6 @@
domFlip.centerAt(center); domFlip.centerAt(center);
domFlip.zoom(this.scatter.scale); domFlip.zoom(this.scatter.scale);
let target = this.constraintFlipCenter(center, loader); let target = this.constraintFlipCenter(center, loader);
console.log('FlipEffect.startFlip', target, loader);
domFlip.start({ targetCenter: target }); domFlip.start({ targetCenter: target });
}); });
} }
@ -10668,7 +10674,6 @@
constraintFlipCenter(center, loader) { constraintFlipCenter(center, loader) {
let w = loader.wantedWidth; let w = loader.wantedWidth;
let h = loader.wantedHeight; let h = loader.wantedHeight;
console.log('constraintFlipCenter', w, h);
let canvas = app.renderer.view; let canvas = app.renderer.view;
let x = center.x; let x = center.x;
let y = center.y; let y = center.y;

View File

@ -332,9 +332,13 @@ export class DOMFlip {
} }
start({ targetCenter = null } = {}) { start({ targetCenter = null } = {}) {
console.log('start')
this.flippable.showFront()
if (this.preloadBack) { if (this.preloadBack) {
console.log('preloadBack')
this.flippable.start({ duration: this.flipDuration, targetCenter }) this.flippable.start({ duration: this.flipDuration, targetCenter })
} else { } else {
console.log('no back preload')
let back = this.cardWrapper.querySelector('.back') let back = this.cardWrapper.querySelector('.back')
let flippable = this.flippable let flippable = this.flippable
this.backLoader.load(back).then(loader => { this.backLoader.load(back).then(loader => {
@ -542,6 +546,7 @@ export class DOMFlippable {
start({ targetCenter = null } = {}) { start({ targetCenter = null } = {}) {
this.bringToFront() this.bringToFront()
console.log('flippable start', this.flipped)
if (!this.flipped) { if (!this.flipped) {
this.startX = this.element._gsTransform.x this.startX = this.element._gsTransform.x
this.startY = this.element._gsTransform.y this.startY = this.element._gsTransform.y

View File

@ -80,13 +80,13 @@
setup() { setup() {
super.setup() super.setup()
let urls = ['../examples/women.jpeg', '../examples/king.jpeg'] let urls = ['../examples/women.jpeg', '../examples/king.jpeg']
PIXI.Loader.shared.add(urls).load(loader => { PIXI.Loader.shared.add(urls).load((loader, resources) => {
// We need a loader because the size of the sprite must be known // We need a loader because the size of the sprite must be known
// when the scatter is defined // when the scatter is defined
let x = 30 let x = 30
let y = 30 let y = 30
for (let url in loader.resources) { for (const url of urls) {
let sprite = PIXI.Sprite.from(url) const sprite = PIXI.Sprite.from(resources[url].texture)
sprite.interactive = true sprite.interactive = true
let scatter = new DisplayObjectScatter(sprite, this.renderer, { let scatter = new DisplayObjectScatter(sprite, this.renderer, {
x: x, x: x,

View File

@ -43,7 +43,9 @@ export class ScatterLoader extends CardLoader {
let canvas = globalScatterLoaderCanvas let canvas = globalScatterLoaderCanvas
canvas.width = w canvas.width = w
canvas.height = h canvas.height = h
let renderer = new PIXI.Renderer(w, h, { let renderer = new PIXI.Renderer({
width: w,
height: h,
view: canvas, view: canvas,
resolution: resolution resolution: resolution
}) })
@ -124,7 +126,6 @@ export default class FlipEffect {
domFlip.centerAt(center) domFlip.centerAt(center)
domFlip.zoom(this.scatter.scale) domFlip.zoom(this.scatter.scale)
let target = this.constraintFlipCenter(center, loader) let target = this.constraintFlipCenter(center, loader)
console.log('FlipEffect.startFlip', target, loader)
domFlip.start({ targetCenter: target }) domFlip.start({ targetCenter: target })
}) })
} }
@ -147,7 +148,6 @@ export default class FlipEffect {
constraintFlipCenter(center, loader) { constraintFlipCenter(center, loader) {
let w = loader.wantedWidth let w = loader.wantedWidth
let h = loader.wantedHeight let h = loader.wantedHeight
console.log('constraintFlipCenter', w, h)
let canvas = app.renderer.view let canvas = app.renderer.view
let x = center.x let x = center.x
let y = center.y let y = center.y