为什么触摸事件会延迟?

时间:2015-08-18 14:27:07

标签: javascript performance reactjs android-webview

我目前正在使用React和Nuclear.js与Immutable.js开发移动单页面webapp。

当我点击事件时,总是延迟约200ms。我认为这是因为"点击延迟"问题,所以我改为触摸事件,这是React中的onTouchStart。

但延迟似乎仍然存在。我在devtools中使用时间轴视图来调查延迟,发现时间花费在" native v8natives.js:1229",如下所示:

delay is found

我想知道什么是延迟?以及为什么它总是在那里,即使我使用触摸事件而不是点击。

1 个答案:

答案 0 :(得分:1)

我今天进一步调查了它。图表中显示的时间并不准确且具有误导性。

事实上,执行的时间包含在该延迟中,但未显示。

因此,在使用与React打包的/// <reference path="../typings/angular2/angular2.d.ts" /> import { Injector, Http, httpInjectables } from "angular2/angular2" export class EntryService { private _entries: Array<string>; private http: Http; constructor() { this._entries = ["test1", "test2", "test3"]; var injector = Injector.resolveAndCreate([ httpInjectables, Http ]); this.http = injector.get(Http); } get Entries() : Array<string> { return this._entries; } getEntries() { return this.http.get('http://localhost:53338/api/decisions') .toRx() .map(response => response.json()); } } 和性能工具进入我的脚本后,现在延迟显着减少。

相关问题