Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent feedback loop when scrolling timeline on WebEngine backend #4178

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/timeline/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ App.controller("TimelineCtrl", function ($scope) {
$scope.track_label = "Track %s";
$scope.enable_sorting = true;
$scope.ThumbServer = "http://127.0.0.1/";
$scope.ignore_scroll = false;

// Method to set if Qt is detected (which clears demo data
// and updates the document_is_ready variable in openshot-qt)
Expand Down Expand Up @@ -285,13 +286,19 @@ App.controller("TimelineCtrl", function ($scope) {
var scrolling_tracks = $("#scrolling_tracks");
var horz_scroll_offset = normalizedScrollValue * timeline_length;
scrolling_tracks.scrollLeft(horz_scroll_offset);

$scope.ignore_scroll = true;
$("#scrolling_ruler").scrollLeft(horz_scroll_offset);
};

// Scroll the timeline horizontally of a certain amount (scrol_value)
// Scroll the timeline horizontally of a certain amount
$scope.scrollLeft = function (scroll_value) {
var scrolling_tracks = $("#scrolling_tracks");
var horz_scroll_offset = scrolling_tracks.scrollLeft();
scrolling_tracks.scrollLeft(horz_scroll_offset + scroll_value);

$scope.ignore_scroll = true;
$("#scrolling_ruler").scrollLeft(horz_scroll_offset + scroll_value);
};

// Center the timeline on a given time position
Expand Down
16 changes: 16 additions & 0 deletions src/timeline/js/directives/ruler.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ App.directive("tlScrollableTracks", function () {
$("#scrolling_ruler").scrollLeft(element.scrollLeft());
$("#progress_container").scrollLeft(element.scrollLeft());

if (scope.ignore_scroll == true) {
// Reset flag and ignore scroll propagation
scope.$apply( () => {
scope.ignore_scroll = false;
scope.scrollLeft = element[0].scrollLeft;
})
// exit at this point
return;

} else {
// Only update scroll position
scope.$apply( () => {
scope.scrollLeft = element[0].scrollLeft;
})
}

// Send scrollbar position to Qt
if (scope.Qt) {
// Calculate scrollbar positions (left and right edge of scrollbar)
Expand Down
4 changes: 4 additions & 0 deletions src/windows/views/webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2750,6 +2750,10 @@ def update_scroll(self, newScroll):
# Get access to timeline scope and set scale to new computed value
self.run_js(JS_SCOPE_SELECTOR + ".setScroll(" + str(newScroll) + ");")

# This seems to make web-engine zoom slider scroll events go smoother
# TODO: remove this if we can find a better approach.
QCoreApplication.processEvents()

# Handle changes to zoom level, update js
def update_zoom(self, newScale):
_ = get_app()._tr
Expand Down