-
-
Save i7an/338632aded0931a1334854b3cf13a4f3 to your computer and use it in GitHub Desktop.
This file contains 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
(function () { | |
var mrg = 0; | |
var id = 'slider'; | |
var klass = 'slider'; | |
var interval = 2000; | |
var mainEl = document.getElementById(id) | |
if (!mainEl) { | |
console.error('Failed to find El#' + id); | |
return; | |
} | |
var insideEl = mainEl.getElementsByClassName(klass)[0] | |
if (!insideEl) { | |
console.error('Failed to find El.' + klass + ' inside El#' + id); | |
return; | |
} | |
setInterval(function() { | |
var marginPx = (mrg % 5) * 1000 | |
insideEl.style = 'margin-left: -' + marginPx + 'px' | |
mrg++; | |
}, interval); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment