When i launch the scrollMyScreen function, i want to be able to SOMETIMES call a callback(which i want to be my flashArrow function), which i thought would look something like: scrollMyScreen(flashArrow()), but obviously that doesn’t work. my flashArrow function will actually be bigger than just an alert, this is just for example.
function scrollMyScreen() {
$('body').delay(600).animate({scrollTop: $(target).offset().top}, 1000, callback)
}
function flashArrow () {
alert('FLASHING ARROW!')
};
So, what can I do to make this work? I want to call scrollMyScreen, and then sometimes add the function flashArrow() as it’s callback, or, to happen once scrollMyScreen is done.
example case:
case "header":
scrollMyScreen()
break
case "wrapper":
scrollMyScreen(flashArrow())
break
You need to pass a reference to
flashArrow, not the result of callingflashArrow():(and don’t forget to declare the
callbackparameter toscrollMyScreen()too!)