From 886712cc8e1126fd14b1342ea71e70400aa8b3b4 Mon Sep 17 00:00:00 2001 From: Gabriele Cirulli Date: Wed, 12 Mar 2014 15:40:49 +0100 Subject: [PATCH] add basic css transform positions --- style/main.css | 206 ++++++++++++++++++++++++------------------------ style/main.scss | 17 ++-- 2 files changed, 115 insertions(+), 108 deletions(-) diff --git a/style/main.css b/style/main.css index c28f9be..d76fc08 100644 --- a/style/main.css +++ b/style/main.css @@ -227,69 +227,69 @@ hr { height: 106.25px; line-height: 116.25px; } .tile.tile-position-1-1 { - position: absolute; - left: 0px; - top: 0px; } + -webkit-transform: translate(0px, 0px); + -moz-transform: translate(0px, 0px); + transform: translate(0px, 0px); } .tile.tile-position-1-2 { - position: absolute; - left: 0px; - top: 121px; } + -webkit-transform: translate(0px, 121px); + -moz-transform: translate(0px, 121px); + transform: translate(0px, 121px); } .tile.tile-position-1-3 { - position: absolute; - left: 0px; - top: 243px; } + -webkit-transform: translate(0px, 243px); + -moz-transform: translate(0px, 243px); + transform: translate(0px, 243px); } .tile.tile-position-1-4 { - position: absolute; - left: 0px; - top: 364px; } + -webkit-transform: translate(0px, 364px); + -moz-transform: translate(0px, 364px); + transform: translate(0px, 364px); } .tile.tile-position-2-1 { - position: absolute; - left: 121px; - top: 0px; } + -webkit-transform: translate(121px, 0px); + -moz-transform: translate(121px, 0px); + transform: translate(121px, 0px); } .tile.tile-position-2-2 { - position: absolute; - left: 121px; - top: 121px; } + -webkit-transform: translate(121px, 121px); + -moz-transform: translate(121px, 121px); + transform: translate(121px, 121px); } .tile.tile-position-2-3 { - position: absolute; - left: 121px; - top: 243px; } + -webkit-transform: translate(121px, 243px); + -moz-transform: translate(121px, 243px); + transform: translate(121px, 243px); } .tile.tile-position-2-4 { - position: absolute; - left: 121px; - top: 364px; } + -webkit-transform: translate(121px, 364px); + -moz-transform: translate(121px, 364px); + transform: translate(121px, 364px); } .tile.tile-position-3-1 { - position: absolute; - left: 243px; - top: 0px; } + -webkit-transform: translate(243px, 0px); + -moz-transform: translate(243px, 0px); + transform: translate(243px, 0px); } .tile.tile-position-3-2 { - position: absolute; - left: 243px; - top: 121px; } + -webkit-transform: translate(243px, 121px); + -moz-transform: translate(243px, 121px); + transform: translate(243px, 121px); } .tile.tile-position-3-3 { - position: absolute; - left: 243px; - top: 243px; } + -webkit-transform: translate(243px, 243px); + -moz-transform: translate(243px, 243px); + transform: translate(243px, 243px); } .tile.tile-position-3-4 { - position: absolute; - left: 243px; - top: 364px; } + -webkit-transform: translate(243px, 364px); + -moz-transform: translate(243px, 364px); + transform: translate(243px, 364px); } .tile.tile-position-4-1 { - position: absolute; - left: 364px; - top: 0px; } + -webkit-transform: translate(364px, 0px); + -moz-transform: translate(364px, 0px); + transform: translate(364px, 0px); } .tile.tile-position-4-2 { - position: absolute; - left: 364px; - top: 121px; } + -webkit-transform: translate(364px, 121px); + -moz-transform: translate(364px, 121px); + transform: translate(364px, 121px); } .tile.tile-position-4-3 { - position: absolute; - left: 364px; - top: 243px; } + -webkit-transform: translate(364px, 243px); + -moz-transform: translate(364px, 243px); + transform: translate(364px, 243px); } .tile.tile-position-4-4 { - position: absolute; - left: 364px; - top: 364px; } + -webkit-transform: translate(364px, 364px); + -moz-transform: translate(364px, 364px); + transform: translate(364px, 364px); } .tile { border-radius: 3px; @@ -297,11 +297,13 @@ hr { text-align: center; font-weight: bold; z-index: 10; + position: absolute; font-size: 55px; -webkit-transition: 100ms ease-in-out; -moz-transition: 100ms ease-in-out; - -webkit-transition-property: top, left; - -moz-transition-property: top, left; } + -webkit-transition-property: -webkit-transform; + -moz-transition-property: -moz-transform; + transition-property: transform; } .tile.tile-2 { background: #eee4da; box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0); } @@ -397,8 +399,8 @@ hr { .tile-new { -webkit-animation: appear 200ms ease 100ms; -moz-animation: appear 200ms ease 100ms; - -webkit-animation-fill-mode: both; - -moz-animation-fill-mode: both; } + -webkit-animation-fill-mode: backwards; + -moz-animation-fill-mode: backwards; } @-webkit-keyframes pop { 0% { @@ -443,8 +445,8 @@ hr { z-index: 20; -webkit-animation: pop 200ms ease 100ms; -moz-animation: pop 200ms ease 100ms; - -webkit-animation-fill-mode: both; - -moz-animation-fill-mode: both; } + -webkit-animation-fill-mode: backwards; + -moz-animation-fill-mode: backwards; } .game-intro { margin-bottom: 0; } @@ -562,69 +564,69 @@ hr { height: 57.5px; line-height: 67.5px; } .tile.tile-position-1-1 { - position: absolute; - left: 0px; - top: 0px; } + -webkit-transform: translate(0px, 0px); + -moz-transform: translate(0px, 0px); + transform: translate(0px, 0px); } .tile.tile-position-1-2 { - position: absolute; - left: 0px; - top: 68px; } + -webkit-transform: translate(0px, 68px); + -moz-transform: translate(0px, 68px); + transform: translate(0px, 68px); } .tile.tile-position-1-3 { - position: absolute; - left: 0px; - top: 135px; } + -webkit-transform: translate(0px, 135px); + -moz-transform: translate(0px, 135px); + transform: translate(0px, 135px); } .tile.tile-position-1-4 { - position: absolute; - left: 0px; - top: 203px; } + -webkit-transform: translate(0px, 203px); + -moz-transform: translate(0px, 203px); + transform: translate(0px, 203px); } .tile.tile-position-2-1 { - position: absolute; - left: 68px; - top: 0px; } + -webkit-transform: translate(68px, 0px); + -moz-transform: translate(68px, 0px); + transform: translate(68px, 0px); } .tile.tile-position-2-2 { - position: absolute; - left: 68px; - top: 68px; } + -webkit-transform: translate(68px, 68px); + -moz-transform: translate(68px, 68px); + transform: translate(68px, 68px); } .tile.tile-position-2-3 { - position: absolute; - left: 68px; - top: 135px; } + -webkit-transform: translate(68px, 135px); + -moz-transform: translate(68px, 135px); + transform: translate(68px, 135px); } .tile.tile-position-2-4 { - position: absolute; - left: 68px; - top: 203px; } + -webkit-transform: translate(68px, 203px); + -moz-transform: translate(68px, 203px); + transform: translate(68px, 203px); } .tile.tile-position-3-1 { - position: absolute; - left: 135px; - top: 0px; } + -webkit-transform: translate(135px, 0px); + -moz-transform: translate(135px, 0px); + transform: translate(135px, 0px); } .tile.tile-position-3-2 { - position: absolute; - left: 135px; - top: 68px; } + -webkit-transform: translate(135px, 68px); + -moz-transform: translate(135px, 68px); + transform: translate(135px, 68px); } .tile.tile-position-3-3 { - position: absolute; - left: 135px; - top: 135px; } + -webkit-transform: translate(135px, 135px); + -moz-transform: translate(135px, 135px); + transform: translate(135px, 135px); } .tile.tile-position-3-4 { - position: absolute; - left: 135px; - top: 203px; } + -webkit-transform: translate(135px, 203px); + -moz-transform: translate(135px, 203px); + transform: translate(135px, 203px); } .tile.tile-position-4-1 { - position: absolute; - left: 203px; - top: 0px; } + -webkit-transform: translate(203px, 0px); + -moz-transform: translate(203px, 0px); + transform: translate(203px, 0px); } .tile.tile-position-4-2 { - position: absolute; - left: 203px; - top: 68px; } + -webkit-transform: translate(203px, 68px); + -moz-transform: translate(203px, 68px); + transform: translate(203px, 68px); } .tile.tile-position-4-3 { - position: absolute; - left: 203px; - top: 135px; } + -webkit-transform: translate(203px, 135px); + -moz-transform: translate(203px, 135px); + transform: translate(203px, 135px); } .tile.tile-position-4-4 { - position: absolute; - left: 203px; - top: 203px; } + -webkit-transform: translate(203px, 203px); + -moz-transform: translate(203px, 203px); + transform: translate(203px, 203px); } .game-container { margin-top: 20px; } diff --git a/style/main.scss b/style/main.scss index b5e2609..68db1c4 100644 --- a/style/main.scss +++ b/style/main.scss @@ -282,9 +282,11 @@ hr { @for $x from 1 through $grid-row-cells { @for $y from 1 through $grid-row-cells { &.tile-position-#{$x}-#{$y} { - position: absolute; - left: round(($tile-size + $grid-spacing) * ($x - 1)); - top: round(($tile-size + $grid-spacing) * ($y - 1)); + $xPos: round(($tile-size + $grid-spacing) * ($x - 1)); + $yPos: round(($tile-size + $grid-spacing) * ($y - 1)); + -webkit-transform: translate($xPos, $yPos); + -moz-transform: translate($xPos, $yPos); + transform: translate($xPos, $yPos); } } } @@ -301,11 +303,14 @@ hr { text-align: center; font-weight: bold; z-index: 10; + position: absolute; font-size: 55px; @include transition($transition-speed ease-in-out); - @include transition-property(top, left); + -webkit-transition-property: -webkit-transform; + -moz-transition-property: -moz-transform; + transition-property: transform; $base: 2; $exponent: 1; @@ -394,7 +399,7 @@ hr { .tile-new { @include animation(appear 200ms ease $transition-speed); - @include animation-fill-mode(both); + @include animation-fill-mode(backwards); } @include keyframes(pop) { @@ -417,7 +422,7 @@ hr { .tile-merged { z-index: 20; @include animation(pop 200ms ease $transition-speed); - @include animation-fill-mode(both); + @include animation-fill-mode(backwards); } .game-intro { -- GitLab