/ld27

To get this branch, use:
bzr branch http://9ix.org/bzr/ld27

« back to all changes in this revision

Viewing changes to zoetrope/core/tween.lua

  • Committer: Josh C
  • Date: 2014-07-05 00:04:06 UTC
  • Revision ID: josh@9ix.org-20140705000406-9h8qk5f0j6oz0xo3
try more gracefully handling different "am" versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
                        assert(self.easers[ease], 'easer ' .. ease .. ' is not defined')
103
103
                end
104
104
 
105
 
                -- check for an existing tween for this target and property
106
 
                
107
 
                for i, existing in ipairs(self.tweens) do
108
 
                        if target == existing.target and property == existing.property then
109
 
                                if to == existing.to then
110
 
                                        return existing.promise
111
 
                                else
112
 
                                        table.remove(self.tweens, i)
113
 
                                end
114
 
                        end
115
 
                end
116
 
                
117
 
                -- add it
118
 
 
119
 
                tween = { target = target, property = property, propType = propType, to = to, duration = duration, ease = ease }
 
105
                local tween = { target = target, property = property, propType = propType, to = to, duration = duration, ease = ease }
120
106
                tween.from = self:getTweenValue(tween)
121
107
                tween.type = type(tween.from)
122
108
                
146
132
                else
147
133
                        error('tweened property must either be a number or a table of numbers, is ' .. tween.type)
148
134
                end
149
 
                        
 
135
 
 
136
                -- check for an existing tween for this target and property
 
137
                
 
138
                for i, existing in ipairs(self.tweens) do
 
139
                        if target == existing.target and property == existing.property then
 
140
                                if to == existing.to then
 
141
                                        return existing.promise
 
142
                                else
 
143
                                        existing.promise:fail('Overridden by a later tween')
 
144
                                        table.remove(self.tweens, i)
 
145
                                end
 
146
                        end
 
147
                end
 
148
                
150
149
                tween.elapsed = 0
151
150
                tween.promise = Promise:new()
152
151
                table.insert(self.tweens, tween)
197
196
                           (type(tween.property) == 'table' and tween.property[1] == property) or
198
197
                           not property) then
199
198
                                found = true
200
 
                                tween.promise:fail('Tween stopped')
 
199
                                tween.promise:fail('Stopped')
201
200
                                table.remove(self.tweens, i)
202
201
                        end
203
202
                end