Skip to content

Commit

Permalink
remove unnecessary defers from fx.html
Browse files Browse the repository at this point in the history
animate() is not async anymore
  • Loading branch information
mislav committed Sep 11, 2012
1 parent 2ed0123 commit ee77d69
Showing 1 changed file with 23 additions and 43 deletions.
66 changes: 23 additions & 43 deletions test/fx.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h1>Zepto effects tests</h1>
return digits[1] + '#' + rgb.toString(16)
}

function defer(fn, delay) {
function defer(delay, fn) {
setTimeout(fn, delay || 0)
}

Expand All @@ -108,7 +108,7 @@ <h1>Zepto effects tests</h1>

testAnimate: function(t){
var el = $('#animtest_1'), el2 = $('#animtest_2')
t.pause()

el.animate({
translate3d: '80px, 20px, 100px',
rotateZ: '90deg',
Expand All @@ -126,26 +126,20 @@ <h1>Zepto effects tests</h1>
easing: 'ease-out'
})

t.pause()
t.assertStyle('ease-out', el, 'transition-timing-function')
t.assertStyle('0.2s', el, 'transition-duration')
t.assertStyle(/\bbackground-color\b/, el, 'transition-property')
t.assertStyle(/\btransform\b/, el, 'transition-property')
t.assertStyle('0.18s', el2, 'transition-duration')

defer(function(){
t.pause()
defer(250, function(){
t.resume(function(){
t.assertStyle('ease-out', el, 'transition-timing-function')
t.assertStyle('0.2s', el, 'transition-duration')
t.assertStyle(/\bbackground-color\b/, el, 'transition-property')
t.assertStyle(/\btransform\b/, el, 'transition-property')
t.assertStyle('0.18s', el2, 'transition-duration')

t.pause()
defer(function(){
t.resume(function(){
t.assertStyle('translate3d(80px, 20px, 100px) rotateZ(90deg) scale(0.8)', el, 'transform')
t.assertStyle('0.5', el, 'opacity')
t.assertEqual('#BADA55', colorToHex(el.get(0).style.backgroundColor).toUpperCase())
})
}, 250)
t.assertStyle('translate3d(80px, 20px, 100px) rotateZ(90deg) scale(0.8)', el, 'transform')
t.assertStyle('0.5', el, 'opacity')
t.assertEqual('#BADA55', colorToHex(el.get(0).style.backgroundColor).toUpperCase())
})
}, 1)
})
},

testDuration: function(t){
Expand All @@ -161,13 +155,8 @@ <h1>Zepto effects tests</h1>
opacity: 0.5
}, 0)

t.pause()
defer(function(){
t.resume(function(){
t.assertStyle('0.4s', el1, 'transition-duration', 'expected default duration')
t.assertStyle('', el2, 'transition-duration', 'expected no animation')
})
}, 1)
t.assertStyle('0.4s', el1, 'transition-duration', 'expected default duration')
t.assertStyle('', el2, 'transition-duration', 'expected no animation')
},

testDurationString: function(t){
Expand All @@ -177,18 +166,13 @@ <h1>Zepto effects tests</h1>
opacity: 0.5
}, 'fast')

t.pause()
defer(function(){
t.resume(function(){
t.assertStyle('0.2s', el, 'transition-duration', 'expected fast duration')
})
}, 1)
t.assertStyle('0.2s', el, 'transition-duration', 'expected fast duration')
},

testCallback: function(t){
var duration = 250, start = new Date().getTime()
t.pause()

t.pause()
$('#callbacktest').anim({
translate3d: '80px, 20px, 100px',
rotateZ: '90deg',
Expand Down Expand Up @@ -222,23 +206,19 @@ <h1>Zepto effects tests</h1>
})

t.pause()
defer(function(){
defer(30, function(){
t.resume(function(){
t.assert(callbackCalled)
})
},30)
})
},

testKeyFrameAnimation: function(t){
t.pause()
var el = $('#keyframetest').animate('animName', 200)
defer(function(){
t.resume(function(){
t.assertStyle('animName', el, 'animation-name')
t.assertStyle('0.2s', el, 'animation-duration')
t.assertStyle('linear', el, 'animation-timing-function')
})
})

t.assertStyle('animName', el, 'animation-name')
t.assertStyle('0.2s', el, 'animation-duration')
t.assertStyle('linear', el, 'animation-timing-function')
},

testEmptyCollection: function(t){
Expand Down

0 comments on commit ee77d69

Please sign in to comment.