Created
May 23, 2013 13:43
-
-
Save alexispurslane/17d46f4b252c1cf2ea7d to your computer and use it in GitHub Desktop.
A slide function. from my library called Magik it is also on github!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| slide: function (all) { | |
| var pos = this.pos; | |
| if (all.direction == 'Down') { | |
| var obj = this.e; | |
| obj.style.zIndex = this.zIndex; | |
| this.zIndex++; | |
| obj.style.position = "relative" | |
| var timer = setInterval(function () { | |
| if (pos >= all.movement) { | |
| clearInterval(timer) | |
| } else { | |
| console.log(pos); | |
| obj.style.top = pos + 'px' | |
| pos += all.step; | |
| console.log(obj.style.marginTop); | |
| console.log(obj); | |
| } | |
| }, all.duration) | |
| } else if (all.direction == 'Up') { | |
| var obj = this.e; | |
| obj.style.zIndex = this.zIndex; | |
| this.zIndex++; | |
| obj.style.position = "relative" | |
| var timer = setInterval(function () { | |
| if (pos <= -Math.abs(all.movement)) { | |
| clearInterval(timer) | |
| } else { | |
| console.log(pos); | |
| obj.style.top = pos + 'px' | |
| pos -= all.step; | |
| console.log(obj.style.marginBottom); | |
| console.log(pos); | |
| } | |
| }, all.duration) | |
| } else if (all.direction == 'Left') { | |
| var obj = this.e; | |
| obj.style.zIndex = this.zIndex; | |
| this.zIndex++; | |
| obj.style.position = "relative" | |
| var timer = setInterval(function () { | |
| if (pos <= -Math.abs(all.movement)) { | |
| clearInterval(timer) | |
| } else { | |
| console.log(pos); | |
| obj.style.left = pos + 'px' | |
| pos -= all.step; | |
| console.log(obj.style.marginBottom); | |
| console.log(pos); | |
| } | |
| }, all.duration) | |
| } else if (all.direction == 'Right') { | |
| var obj = this.e; | |
| obj.style.zIndex = this.zIndex; | |
| this.zIndex++; | |
| obj.style.position = "relative" | |
| var timer = setInterval(function () { | |
| if (pos <= -Math.abs(all.movement)) { | |
| clearInterval(timer) | |
| } else { | |
| console.log(pos); | |
| obj.style.right = pos + 'px' | |
| pos -= all.step; | |
| console.log(obj.style.marginBottom); | |
| console.log(pos); | |
| } | |
| }, all.duration) | |
| } | |
| }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment