Skip to content

Commit

Permalink
Firsts test with new animations
Browse files Browse the repository at this point in the history
For test in different devices
  • Loading branch information
pinaypunto committed May 29, 2013
1 parent 798e062 commit ef4ba15
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 116 deletions.
66 changes: 39 additions & 27 deletions example/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,63 @@

<body>

<!--
<aside id="a">
<header data-title="aside a"></header>
<article></article>
</aside>
<aside id="b">
<header data-title="aside b"></header>
<article></article>
</aside>
-->

<!-- <section id="zero" data-transition="slide" data-children="one" data-aside="a"> -->
<section id="zero" data-transition="slide" data-children="one">
<header data-title="Zero">
<!-- <nav class="left">
<button data-icon="list" data-view-aside="a"></button>
</nav> -->
<nav class="right">
<button data-icon="arrow-right" data-view-section="one"></button>
</nav>
</header>
<article id="zero-1"></article>
<article id="zero-1" class="indented scroll">
<p>START</p>
<p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero</p><p>END</p>
</article>
</section>

<!-- <section id="one" data-transition="slide" data-children="two" data-aside="b"> -->
<section id="one" data-transition="slide" data-children="two">
<header data-title="One" data-back="home">
<!-- <nav class="left">
<button data-icon="list" data-view-aside="b"></button>
</nav> -->
<nav class="right">
<button data-icon="arrow-right" data-view-section="two"></button>
</nav>
</header>
<article id="one-1"></article>
<article id="one-1">
<p>START</p>
<p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>one one one one one one one one one one one one one one one one</p><p>END</p>
</article>
</section>
<section id="two" data-transition="slide" data-children="three">
<header data-back="home" data-title="Two">
<nav class="right">
<button data-icon="arrow-right" data-view-section="three"></button>
</nav>
</header>
<article id="two-1"></article>
<article id="two-1" class="list scroll">
<ul>
<li>START</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>Lista</li>
<li>END</li>
</ul>
</article>
</section>

<section id="three" data-transition="slide" data-children="four">
Expand All @@ -72,15 +85,14 @@
<button data-icon="arrow-down" data-view-section="four"></button>
</nav>
</header>
<article id="three-1"></article>
<article id="three-1">Naena</article>
</section>

<!--
<section id="four" data-transition="cover">
<header data-back="home" data-title="Four"></header>
<article id="four-1"></article>
<article id="four-1">La cuarta</article>
</section>
-->

<!-- Lungo dependencies -->
<script src="components/quojs/quo.js"></script>
<script src="components/lungo.brownie/lungo.debug.js"></script>
Expand Down
73 changes: 38 additions & 35 deletions src/modules/Lungo.Router.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,36 @@ Handles the <sections> and <articles> to show
@author Guillermo Pascual <[email protected]> || @pasku1
###

Lungo.Router = do(lng = Lungo) ->
Lungo.Router = do (lng = Lungo) ->

C = lng.Constants
HASHTAG = "#"
ANIMATIONEND_EVENTS = ["animationend", "webkitAnimationEnd", "oanimationend", "MSAnimationEnd"]
_history = []

_outPage = undefined
_inPage = undefined
_animating = false

###
Navigate to a <section>.
@method section
@param {string} Id of the <section>
###
section = (section_id) ->
console.error "router section #{section_id}"
current = lng.Element.Cache.section
if _notCurrentTarget(current, section_id)
_outPage = lng.Element.Cache.section
if _notCurrentTarget(_outPage, section_id)
query = C.ELEMENT.SECTION + HASHTAG + section_id
target = if current then current.siblings(query) else lng.dom(query)
if target.length > 0
if lng.DEVICE is C.DEVICE.PHONE and current?

console.error current, target
current.addClass "moveToBack"
target.addClass "moveFromRight"
do _bindEnd
# current.siblings("#{C.ELEMENT.SECTION}.#{C.CLASS.LAST}").removeClass C.CLASS.LAST
# lng.Section.defineTransition target, current
# current.removeClass(C.CLASS.SHOW).addClass(C.CLASS.HIDE).addClass(C.CLASS.LAST)

lng.Section.show current, target
# lng.Router.step section_id
_inPage = if _outPage then _outPage.siblings(query) else lng.dom(query)
if _inPage.length > 0
if lng.DEVICE is C.DEVICE.PHONE and _outPage?
outClass = _inPage.data(C.ATTRIBUTE.TRANSITION) + "Out"
inClass = _inPage.data(C.ATTRIBUTE.TRANSITION) + "In"
_outPage.addClass(outClass).addClass("show")
_inPage.addClass(inClass).addClass("show")
do _bindAnimationEnd

lng.Section.show _outPage, _inPage
lng.Router.step section_id
do _url unless Lungo.Config.history is false
do _updateNavigationElements

Expand All @@ -49,20 +47,20 @@ Lungo.Router = do(lng = Lungo) ->
@method back
###
back = ->
_removeLast()
current = lng.Element.Cache.section
do _removeLast
_outPage = lng.Element.Cache.section
query = C.ELEMENT.SECTION + HASHTAG + history()
target = current.siblings(query)
_inPage = _outPage.siblings(query)
if lng.DEVICE is C.DEVICE.PHONE
lng.Aside.hide()
lng.Section.assignTransition target, target.data C.TRANSITION.ORIGIN
current.removeClass(C.CLASS.SHOW).addClass(C.CLASS.HIDING)
setTimeout (->
current.removeClass(C.CLASS.HIDING)
), C.TRANSITION.DURATION
if target.hasClass("aside") then lng.Aside.toggle()

lng.Section.show current, target
do lng.Aside.hide
outClass = _outPage.data(C.ATTRIBUTE.TRANSITION) + "OutBack"
inClass = _outPage.data(C.ATTRIBUTE.TRANSITION) + "InBack"
_outPage.addClass(outClass).addClass("show")
_inPage.addClass(inClass).addClass("show")
do _bindAnimationEnd
if _inPage.hasClass("aside") then lng.Aside.toggle()

lng.Section.show _outPage, _inPage
do _url unless Lungo.Config.history is false
do _updateNavigationElements

Expand Down Expand Up @@ -123,15 +121,20 @@ Lungo.Router = do(lng = Lungo) ->

_removeLast = -> _history.length -= 1

_bindEnd = ->
_bindAnimationEnd = ->
document.addEventListener(ev, _transitionEnd) for ev in ANIMATIONEND_EVENTS
_animating = true

_unbindEnd = ->
_unbindAnimationEnd = ->
document.removeEventListener(ev, _transitionEnd) for ev in ANIMATIONEND_EVENTS

_transitionEnd = ->
console.error 'Transition END!'
do _unbindEnd
_outPage.attr "class", ""
_inPage.attr "class", "show"
_outPage = undefined
_inPage = undefined
do _unbindAnimationEnd
_animating = false


section : section
Expand Down
2 changes: 1 addition & 1 deletion src/stylesheets/__init.styl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ASIDE_SMALL_ICON = 48px

DEFAULT_TRANSITION = easeOutSine
DEFAULT_TRANSITION = easeInCubic
TRANSITION_TIME = 400ms
TRANSITION_TIME = 1000ms

FONT_SIZE_TINY = 11px
FONT_SIZE_SMALL = 0.9em
Expand Down
24 changes: 24 additions & 0 deletions src/stylesheets/lungo.animation.back.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@import "__init.styl"

OPACITY = 0.3
TRANSLATE_Z = -300px
ROTATE_X = 20deg
ORIGIN = 100% 50%

.backIn
vendor(animation, backIn TRANSITION_TIME ease both)
.backOut
vendor(animation, backOut TRANSITION_TIME ease both)


@keyframes backIn
from {
transform: rotateX(ROTATE_X) translateZ(TRANSLATE_Z)
transform-origin: ORIGIN
}

@keyframes backOut
to {
transform: rotateX(ROTATE_X) translateZ(TRANSLATE_Z)
transform-origin: ORIGIN
}
36 changes: 36 additions & 0 deletions src/stylesheets/lungo.animation.cover.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@import "__init.styl"

TRANSLATE_Y = -18%
TRANSLATE_Z = -150px
ROTATE_X = 20deg

.coverIn
vendor(animation, coverIn TRANSITION_TIME ease both)
.coverOut
vendor(animation, coverOut TRANSITION_TIME ease both)
.coverInBack
vendor(animation, coverInBack TRANSITION_TIME ease both)
.coverOutBack
vendor(animation, coverOutBack TRANSITION_TIME ease both)


@keyframes coverIn
from {
transform: translateY(100%);
}

@keyframes coverOut
to {
transform: rotateX(ROTATE_X) translateZ(TRANSLATE_Z) translateY(TRANSLATE_Y)
}

@keyframes coverInBack
from {
transform: rotateX(ROTATE_X) translateZ(TRANSLATE_Z) translateY(TRANSLATE_Y)
}

@keyframes coverOutBack
to {
transform: translateY(100%)
}

69 changes: 16 additions & 53 deletions src/stylesheets/lungo.animation.slide.styl
Original file line number Diff line number Diff line change
@@ -1,60 +1,23 @@
TIME = 0.4s
@import "__init.styl"

.moveToLeft
vendor(animation, moveToLeft TIME ease both)
.moveFromLeft
vendor(animation, moveFromLeft TIME ease both)
.moveToRight
vendor(animation, moveToRight TIME ease both)
.moveFromRight
vendor(animation, moveFromRight TIME ease both)
.moveToBack
vendor(animation, moveToBack TIME ease both)

@-webkit-keyframes moveToLeft
100% { -webkit-transform: translateX(-100%); }
@-moz-keyframes moveToLeft
100% { -moz-transform: translateX(-100%); }
@keyframes moveToLeft
100% { transform: translateX(-100%); }
.slideIn
vendor(animation, slideIn TRANSITION_TIME ease both)
.slideOut
vendor(animation, backOut TRANSITION_TIME ease both)
.slideInBack
vendor(animation, backIn TRANSITION_TIME ease both)
.slideOutBack
vendor(animation, slideOutBack TRANSITION_TIME ease both)

@-webkit-keyframes moveFromLeft
0% { -webkit-transform: translateX(-100%); }
@-moz-keyframes moveFromLeft
0% { -moz-transform: translateX(-100%); }
@keyframes moveFromLeft
0% { transform: translateX(-100%); }

@-webkit-keyframes moveToRight
100% { -webkit-transform: translateX(100%); }
@-moz-keyframes moveToRight
100% { -moz-transform: translateX(100%); }
@keyframes moveToRight
100% { transform: translateX(100%); }

@-webkit-keyframes moveFromRight
0% { -webkit-transform: translateX(100%); }
@-moz-keyframes moveFromRight
0% { -moz-transform: translateX(100%); }
@keyframes moveFromRight
0% { transform: translateX(100%); }



@-webkit-keyframes moveToBack
100% {
-webkit-transform: rotateX(20deg) translateZ(-100px);
transform-origin: 100% 50%;
opacity: .3;
}
@-moz-keyframes moveToLeft
100% {
-moz-transform: rotateX(20deg) translateZ(-100px);
opacity: .3;
@keyframes slideIn
from {
transform: translateX(100%)
}
@keyframes moveToLeft
100% {
transform: rotateX(20deg) translateZ(-100px);
opacity: .3;

@keyframes slideOutBack
to {
transform: translateX(100%)
}

0 comments on commit ef4ba15

Please sign in to comment.