向窗体滚动条添加延迟

Adding a delay to to a form scroller

本文关键字:延迟 添加 滚动条 窗体      更新时间:2023-09-26

我使用http://tympanus.net/codrops/2014/07/30/fullscreen-form-interface/来构建一个表单-我想在点击事件后页面向下滚动之前延迟。

我一直在尝试使用setTimeout来实现这一点,但一直在挣扎。

例如,我认为这将工作:

    // show next field
    setTimeout(function() {
        this.ctrlContinue.addEventListener( 'click', function() {
            self._nextField(); 
        } );
    }, 1000);

您可以在https://github.com/codrops/FullscreenForm/blob/master/js/fullscreenForm.js

查看完整的代码

谢谢

这应该行得通,你应该在点击事件之后而不是之前设置超时时间。

this.ctrlContinue.addEventListener( 'click', function() {
    setTimeout(function() {  
        self._nextField(); 
    }, 1000);
});