Skip to content

Commit

Permalink
Added close animation override.
Browse files Browse the repository at this point in the history
  • Loading branch information
astjohn committed May 16, 2012
1 parent c6c0922 commit efdb9d6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions examples/chronos.css
Expand Up @@ -6,6 +6,7 @@
-moz-border-radius: 10px;
border-radius: 10px;
overflow: hidden;
display: none;
/**
* HEADER
*/
Expand Down
13 changes: 10 additions & 3 deletions spec/animator-spec.coffee
Expand Up @@ -90,7 +90,7 @@ describe "Animator", ->
it "calls animate with the correct arguments", ->
spyOn(a, '_animate')
a.close()
expect(a._animate).toHaveBeenCalledWith(animation, 'closed')
expect(a._animate).toHaveBeenCalledWith(animation, 'closed', true)

describe "without custom animations", ->
beforeEach ->
Expand All @@ -100,7 +100,7 @@ describe "Animator", ->
spyOn(a, '_animate')
spyOn(a, '_animateClose')
a.close()
expect(a._animate).toHaveBeenCalledWith(a._animateClose, 'closed')
expect(a._animate).toHaveBeenCalledWith(a._animateClose, 'closed', true)

describe "#open", ->
describe "when given custom animations", ->
Expand Down Expand Up @@ -133,13 +133,20 @@ describe "Animator", ->
beforeEach ->
a.pickerManager = jasmine.createSpy("pickerManager mock")

describe "when already animating", ->
describe "when already animating and no override", ->
beforeEach ->
a.animating = true
it "does not call the animation", ->
a._animate(animation, eventname)
expect(animation).not.toHaveBeenCalled()

describe "when already animating with override", ->
beforeEach ->
a.animating = true
it "does call the animation", ->
a._animate(animation, eventname, true)
expect(animation).toHaveBeenCalled()

describe "when not already animating", ->
beforeEach ->
a.animating = false
Expand Down
11 changes: 6 additions & 5 deletions src/animator.coffee
Expand Up @@ -29,7 +29,7 @@ class chronos.Animator
# Animate closing the date picker
close: ->
animation = @animations.close || @_animateClose
@_animate(animation, 'closed')
@_animate(animation, 'closed', true)

# Animate opening the date picker
open: ->
Expand All @@ -49,7 +49,8 @@ class chronos.Animator
###

# common animation pattern
_animate: (animation, eventName) ->
_animate: (animation, eventName, override) ->
@animating = false if override
unless @animating
@animating = true
@currentEventName = eventName
Expand Down Expand Up @@ -146,10 +147,10 @@ class chronos.Animator

# default animation to close picker
_animateOpen: (pickerManager) ->
@$picker.animate {
opacity: 100
}, 300, =>
@$picker.fadeIn('fast', =>
@animationFinished()
)




Expand Down
1 change: 1 addition & 0 deletions src/scss/chronos.scss
Expand Up @@ -28,6 +28,7 @@ $colorOtherMonth: #E1DBFF;
color: $colorText;
@include border-radius($border_radius);
overflow: hidden; // needed to body_prev and body_next
display: none; // show with open animation

.body {
width: 3*$calendar_width;
Expand Down
12 changes: 7 additions & 5 deletions src/scss/partials/_css3.scss
Expand Up @@ -28,6 +28,12 @@
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=$startColor, endColorstr=$endColor, GradientType=0); // IE9 and down
}

// Opacity
@mixin opacity($opacity: 100) {
opacity: $opacity / 100;
filter: "alpha(opacity=#{$opacity})";
}

//// Transitions
//@mixin transition($transition) {
// -webkit-transition: $transition;
Expand All @@ -37,11 +43,7 @@
// transition: $transition;
//}

//// Opacity
//@mixin opacity($opacity: 100) {
// opacity: $opacity / 100;
// filter: "alpha(opacity=#{$opacity})";
//}


//// Background sizing
//@mixin background-size($size) {
Expand Down

0 comments on commit efdb9d6

Please sign in to comment.