Created
January 16, 2018 19:27
-
-
Save anonymous/de54230553497cee59e5b15b640f9535 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; | |
} | |
var hdl = setInterval(function() { | |
mrg++; | |
var marginPx = (mrg % 5) * 1000 | |
insideEl.style = 'margin-left: -' + marginPx + 'px' | |
}, interval); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment