Skip to content

Commit 0b7a32f

Browse files
authored
Merge pull request #4178 from OpenShot/fix-zoom-slider-web-engine
Prevent feedback loop when scrolling timeline on WebEngine backend
2 parents 0832cd3 + d031035 commit 0b7a32f

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/timeline/js/controllers.js

Lines changed: 8 additions & 1 deletion
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

Lines changed: 16 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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)