()
| 263 | } |
| 264 | |
| 265 | var cb = function () { |
| 266 | currCall = (new Date()).getTime(); |
| 267 | scope = this; |
| 268 | args = arguments; |
| 269 | diff = currCall - (debounce ? lastCall : lastExec) - delay; |
| 270 | |
| 271 | clearTimeout(timer); |
| 272 | |
| 273 | if (debounce) { |
| 274 | if (trailing) { |
| 275 | timer = setTimeout(exec, delay); |
| 276 | } |
| 277 | else if (diff >= 0) { |
| 278 | exec(); |
| 279 | } |
| 280 | } |
| 281 | else { |
| 282 | if (diff >= 0) { |
| 283 | exec(); |
| 284 | } |
| 285 | else if (trailing) { |
| 286 | timer = setTimeout(exec, -diff); |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | lastCall = currCall; |
| 291 | }; |
| 292 | |
| 293 | /** |
| 294 | * Clear throttle. |