Skip to content

Instantly share code, notes, and snippets.

@alexispurslane
Created May 23, 2013 13:43
Show Gist options
  • Save alexispurslane/17d46f4b252c1cf2ea7d to your computer and use it in GitHub Desktop.
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!
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