slideshow: Code refactoring for Split Transition based on transition type
Signed-off-by: Javiya Vivekkumar Dineshbhai <vivek.javiya@collabora.com> Change-Id: I227923a1dd27bc01ec3140ba542d17d88f12157b
This commit is contained in:
parent
58b8a69e25
commit
aa17f575c5
3 changed files with 39 additions and 37 deletions
|
@ -111,10 +111,6 @@ SlideShow.PerformTransition = function (
|
|||
image2: HTMLImageElement,
|
||||
slideInfo: SlideInfo,
|
||||
) {
|
||||
let subTypeIndex = 1;
|
||||
const transitionSubType =
|
||||
stringToTransitionSubTypeMap[slideInfo.transitionSubtype];
|
||||
|
||||
switch (stringToTransitionTypeMap[slideInfo.transitionType]) {
|
||||
case TransitionType.FADE:
|
||||
new SlideShow.FadeTransition(canvas, image1, image2, slideInfo).start();
|
||||
|
@ -180,33 +176,7 @@ SlideShow.PerformTransition = function (
|
|||
break;
|
||||
|
||||
case TransitionType.BARNDOORWIPE:
|
||||
if (
|
||||
slideInfo.transitionSubtype &&
|
||||
slideInfo.transitionSubtype.length > 0
|
||||
) {
|
||||
if (
|
||||
transitionSubType == TransitionSubType.HORIZONTAL &&
|
||||
slideInfo.transitionDirection == false
|
||||
) {
|
||||
subTypeIndex = 1;
|
||||
} else if (
|
||||
transitionSubType == TransitionSubType.HORIZONTAL &&
|
||||
slideInfo.transitionDirection == true
|
||||
) {
|
||||
subTypeIndex = 2;
|
||||
} else if (
|
||||
transitionSubType == TransitionSubType.VERTICAL &&
|
||||
slideInfo.transitionDirection == false
|
||||
) {
|
||||
subTypeIndex = 3;
|
||||
} else if (
|
||||
transitionSubType == TransitionSubType.VERTICAL &&
|
||||
slideInfo.transitionDirection == true
|
||||
) {
|
||||
subTypeIndex = 4;
|
||||
}
|
||||
}
|
||||
new SlideShow.SplitTransition(canvas, image1, image2).start(subTypeIndex);
|
||||
new SlideShow.SplitTransition(canvas, image1, image2, slideInfo).start();
|
||||
break;
|
||||
|
||||
case TransitionType.WATERFALLWIPE:
|
||||
|
|
|
@ -10,16 +10,26 @@
|
|||
|
||||
declare var SlideShow: any;
|
||||
|
||||
enum SplitSubType {
|
||||
HORIZONTALIN,
|
||||
HORIZONTALOUT,
|
||||
VERTICALIN,
|
||||
VERTICALOUT,
|
||||
}
|
||||
|
||||
class SplitTransition extends Transition2d {
|
||||
private direction: number = 0;
|
||||
private slideInfo: SlideInfo;
|
||||
constructor(
|
||||
canvas: HTMLCanvasElement,
|
||||
image1: HTMLImageElement,
|
||||
image2: HTMLImageElement,
|
||||
slideInfo: SlideInfo,
|
||||
) {
|
||||
super(canvas, image1, image2);
|
||||
this.prepareTransition();
|
||||
this.animationTime = 2000;
|
||||
this.slideInfo = slideInfo;
|
||||
}
|
||||
|
||||
public renderUniformValue(): void {
|
||||
|
@ -29,8 +39,31 @@ class SplitTransition extends Transition2d {
|
|||
);
|
||||
}
|
||||
|
||||
public start(direction: number): void {
|
||||
this.direction = direction;
|
||||
public start(): void {
|
||||
const transitionSubType =
|
||||
stringToTransitionSubTypeMap[this.slideInfo.transitionSubtype];
|
||||
|
||||
if (
|
||||
transitionSubType == TransitionSubType.HORIZONTAL &&
|
||||
this.slideInfo.transitionDirection == false
|
||||
) {
|
||||
this.direction = SplitSubType.HORIZONTALIN;
|
||||
} else if (
|
||||
transitionSubType == TransitionSubType.HORIZONTAL &&
|
||||
this.slideInfo.transitionDirection == true
|
||||
) {
|
||||
this.direction = SplitSubType.HORIZONTALOUT;
|
||||
} else if (
|
||||
transitionSubType == TransitionSubType.VERTICAL &&
|
||||
this.slideInfo.transitionDirection == false
|
||||
) {
|
||||
this.direction = SplitSubType.VERTICALIN;
|
||||
} else if (
|
||||
transitionSubType == TransitionSubType.VERTICAL &&
|
||||
this.slideInfo.transitionDirection == true
|
||||
) {
|
||||
this.direction = SplitSubType.VERTICALOUT;
|
||||
}
|
||||
this.startTransition();
|
||||
}
|
||||
|
||||
|
@ -67,16 +100,16 @@ class SplitTransition extends Transition2d {
|
|||
|
||||
vec2 dist = abs(uv - center);
|
||||
|
||||
float size = (direction == 2 || direction == 4) ? progress * 1.5 : (1.0 - progress * 1.5);
|
||||
float size = (direction == 1 || direction == 3) ? progress * 1.5 : (1.0 - progress * 1.5);
|
||||
|
||||
float mask = (direction == 1 || direction == 2 ) ? step(dist.y, size / 2.0) : step(dist.x, size / 2.0);
|
||||
float mask = (direction == 0 || direction == 1 ) ? step(dist.y, size / 2.0) : step(dist.x, size / 2.0);
|
||||
|
||||
mask = min(mask, 1.0);
|
||||
|
||||
vec4 color1 = texture(leavingSlideTexture, uv);
|
||||
vec4 color2 = texture(enteringSlideTexture, uv);
|
||||
|
||||
outColor = (direction == 2 || direction == 4) ? mix(color1, color2, mask) : mix(color2, color1, mask);
|
||||
outColor = (direction == 1 || direction == 3) ? mix(color1, color2, mask) : mix(color2, color1, mask);
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ class UncoverTransition extends Transition2d {
|
|||
}
|
||||
|
||||
public start(): void {
|
||||
// this.direction = direction;
|
||||
const transitionSubType =
|
||||
stringToTransitionSubTypeMap[this.slideInfo.transitionSubtype];
|
||||
|
||||
|
|
Loading…
Reference in a new issue