Skip to content

Commit d031035

Browse files
committed
Prevent feedback loop when scrolling timeline on web engine backend, triggered by ZoomSlider widget. Also, it appears that we might be invoking run_js too often, and it gets queued up in blocks and processed in chunks. Not very happy with the performance on web engine.
1 parent 0832cd3 commit d031035

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/timeline/js/controllers.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ App.controller("TimelineCtrl", function ($scope) {
6969
$scope.track_label = "Track %s";
7070
$scope.enable_sorting = true;
7171
$scope.ThumbServer = "http://127.0.0.1/";
72+
$scope.ignore_scroll = false;
7273

7374
// Method to set if Qt is detected (which clears demo data
7475
// and updates the document_is_ready variable in openshot-qt)
@@ -285,13 +286,19 @@ App.controller("TimelineCtrl", function ($scope) {
285286
var scrolling_tracks = $("#scrolling_tracks");
286287
var horz_scroll_offset = normalizedScrollValue * timeline_length;
287288
scrolling_tracks.scrollLeft(horz_scroll_offset);
289+
290+
$scope.ignore_scroll = true;
291+
$("#scrolling_ruler").scrollLeft(horz_scroll_offset);
288292
};
289293

290-
// Scroll the timeline horizontally of a certain amount (scrol_value)
294+
// Scroll the timeline horizontally of a certain amount
291295
$scope.scrollLeft = function (scroll_value) {
292296
var scrolling_tracks = $("#scrolling_tracks");
293297
var horz_scroll_offset = scrolling_tracks.scrollLeft();
294298
scrolling_tracks.scrollLeft(horz_scroll_offset + scroll_value);
299+
300+
$scope.ignore_scroll = true;
301+
$("#scrolling_ruler").scrollLeft(horz_scroll_offset + scroll_value);
295302
};
296303

297304
// Center the timeline on a given time position

src/timeline/js/directives/ruler.js

+16
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ App.directive("tlScrollableTracks", function () {
5454
$("#scrolling_ruler").scrollLeft(element.scrollLeft());
5555
$("#progress_container").scrollLeft(element.scrollLeft());
5656

57+
if (scope.ignore_scroll == true) {
58+
// Reset flag and ignore scroll propagation
59+
scope.$apply( () => {
60+
scope.ignore_scroll = false;
61+
scope.scrollLeft = element[0].scrollLeft;
62+
})
63+
// exit at this point
64+
return;
65+
66+
} else {
67+
// Only update scroll position
68+
scope.$apply( () => {
69+
scope.scrollLeft = element[0].scrollLeft;
70+
})
71+
}
72+
5773
// Send scrollbar position to Qt
5874
if (scope.Qt) {
5975
// Calculate scrollbar positions (left and right edge of scrollbar)

src/windows/views/webview.py

+4
Original file line numberDiff line numberDiff line change
@@ -2750,6 +2750,10 @@ def update_scroll(self, newScroll):
27502750
# Get access to timeline scope and set scale to new computed value
27512751
self.run_js(JS_SCOPE_SELECTOR + ".setScroll(" + str(newScroll) + ");")
27522752

2753+
# This seems to make web-engine zoom slider scroll events go smoother
2754+
# TODO: remove this if we can find a better approach.
2755+
QCoreApplication.processEvents()
2756+
27532757
# Handle changes to zoom level, update js
27542758
def update_zoom(self, newScale):
27552759
_ = get_app()._tr

0 commit comments

Comments
 (0)