|
@@ -9,7 +9,7 @@
|
|
|
// The idea is to have the base animation look "ok" without anything going on, but to also have things going on just fit mathmagically.
|
|
|
// Support to animations that contain the WHOLE of the events should be possible as to make it so we can make special animations for special circumstances. e.g. only encounter with the ogre
|
|
|
enum AnimationLayerLevel {
|
|
|
- BACKGROUND = 0,
|
|
|
+ BACKGROUND = 1,
|
|
|
MIDDLE = 150,
|
|
|
FRONT = 300
|
|
|
}
|
|
@@ -21,6 +21,7 @@ interface AnimationInstruction {
|
|
|
|
|
|
module Elements.AnimationHandler {
|
|
|
var container = document.getElementById("sceneAnimation");
|
|
|
+ var background = document.createElement("a");
|
|
|
var stop = true;
|
|
|
export var spriteSize = 200;
|
|
|
export var animations : Array<AnimationLayer> = [];
|
|
@@ -42,20 +43,30 @@ module Elements.AnimationHandler {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- export function addAnimation (name : string, layer = 0) {
|
|
|
+ export function addAnimation (name : string, layer = 1) {
|
|
|
let newAnim = new AnimationLayer(name, layer);
|
|
|
container.appendChild(newAnim.getElement());
|
|
|
animations.push(newAnim);
|
|
|
return newAnim;
|
|
|
}
|
|
|
|
|
|
+ export function setBackground (name : string) {
|
|
|
+ background.className = "";
|
|
|
+
|
|
|
+ background.classList.add("bg-" + name);
|
|
|
+ background.classList.add("sceneAnimation");
|
|
|
+ background.style.zIndex = "0";
|
|
|
+
|
|
|
+ container.appendChild(background);
|
|
|
+ }
|
|
|
+
|
|
|
export function beginAnimate (targetAnimationSpeed? : number) {
|
|
|
animationSpeed = targetAnimationSpeed == undefined ? 1500 : targetAnimationSpeed;
|
|
|
lastTime = (new Date()).getTime();
|
|
|
percentage = 0;
|
|
|
- fixVerticalPosition();
|
|
|
-
|
|
|
container.style.display = "";
|
|
|
+
|
|
|
+ fixVerticalPosition();
|
|
|
stop = false;
|
|
|
animate();
|
|
|
}
|
|
@@ -76,7 +87,7 @@ module Elements.AnimationHandler {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function fixVerticalPosition () {
|
|
|
+ export function fixVerticalPosition () {
|
|
|
spriteSize = getSize(true);
|
|
|
//container.style.marginBottom = (availHeight - 200) + "px";
|
|
|
container.style.width = spriteSize + "px";
|
|
@@ -85,7 +96,18 @@ module Elements.AnimationHandler {
|
|
|
|
|
|
animations.forEach((anim) => {
|
|
|
anim.updateSize();
|
|
|
- })
|
|
|
+ });
|
|
|
+
|
|
|
+ if (background.parentElement == container) {
|
|
|
+ background.style.transform = "";
|
|
|
+ let height = background.offsetHeight;
|
|
|
+ let width = background.offsetWidth;
|
|
|
+ if (height != 0 && width != 0) {
|
|
|
+ background.style.transform = "scale(" + (spriteSize / height) + ")";
|
|
|
+ background.style.marginLeft = (-width / 2) + "px";
|
|
|
+ background.style.marginTop = (-height / 2) + "px";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export function getSize (fixMin = true) {
|
|
@@ -103,4 +125,6 @@ module Elements.AnimationHandler {
|
|
|
getSize(false);
|
|
|
}
|
|
|
stopAnimate();
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+window.addEventListener("resize", () => { Elements.AnimationHandler.fixVerticalPosition(); });
|