滚动页面时的键入效果

时间:2018-02-25 18:00:00

标签: javascript jquery scroll vertical-scrolling typing

当页面向下滚动时,如何进行打字效果?我使用此代码开始输入:

type '_BoundSinkStream<dynamic, List<int>>' is not a subtype of type '_HttpIncoming' where
_BoundSinkStream is from dart:async
List is from dart:core
int is from dart:core
List is from dart:core
int is from dart:core
_HttpIncoming is from dart:_http
List is from dart:core
int is from dart:core
#0_HttpClientResponse.listen (dart:_http/http_impl.dart:382:23)
#1new _SinkTransformerStreamSubscription (dart:async/stream_transformers.dart:49:16)
#2_BoundSinkStream.listen (dart:async/stream_transformers.dart:185:13)
#3Stream.join (dart:async/stream.dart:741:25)
#4HttpConnector.loadData (package:flutter_app/providers/HttpConnector.dart:26:63)
<asynchronous suspension>
#5WeatherProvider.loadWeather (package:flutter_app/providers/WeatherProvider.dart:12:42)
<asynchronous suspension>
#6 _MyHomePageState._loadData (file:///Users/krzysztofbalana/Private/flutter_app/lib/main.dart:64:21)

1 个答案:

答案 0 :(得分:0)

考虑到您需要检测向下滚动事件才可以开始键入。您可以在代码中添加shabdawali js库,并在detect for scroll down event中包含暂停键入效果。

var typeWriter = shabdawali(el, {
    lines : ["sentence 1", "sentence 2"],
});

var lastScrollTop = 0;
$(window).scroll(function(event){
   var st = $(this).scrollTop();
   if (st > lastScrollTop){
       // downscroll code
       typeWriter.start();
   } else {
      // upscroll code
      typeWriter.pause();
   }
   lastScrollTop = st;
});

免责声明:我是该插件的作者。