[Libreoffice-commits] online.git: loleaflet/src
merttumer (via logerrit)
logerrit at kemper.freedesktop.org
Fri Sep 20 21:55:01 UTC 2019
loleaflet/src/control/Control.PartsPreview.js | 51 +++++++++++++++++++++++++-
1 file changed, 50 insertions(+), 1 deletion(-)
New commits:
commit 77a0e0bca34dd65204f0cc81c2b3613bf3b22d6e
Author: merttumer <mert.tumer at collabora.com>
AuthorDate: Fri Mar 1 18:11:59 2019 +0300
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Fri Sep 20 23:53:49 2019 +0200
Ability to switch slides by arrow up/down keys in edit mode
Change-Id: Ic465636df8a1960364074149a41ea7d0209dbdab
Signed-off-by: merttumer <mert.tumer at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/68585
Reviewed-by: Aron Budea <aron.budea at collabora.com>
Tested-by: Aron Budea <aron.budea at collabora.com>
(cherry picked from commit f3ea0a6ffe03425c557297c53768cb927727b4af)
Reviewed-on: https://gerrit.libreoffice.org/79313
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/loleaflet/src/control/Control.PartsPreview.js b/loleaflet/src/control/Control.PartsPreview.js
index b46d356c6..92bbd2673 100644
--- a/loleaflet/src/control/Control.PartsPreview.js
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -8,6 +8,7 @@ L.Control.PartsPreview = L.Control.extend({
options: {
autoUpdate: true
},
+ partsFocused: false,
onAdd: function (map) {
this._previewInitialized = false;
@@ -61,6 +62,24 @@ L.Control.PartsPreview = L.Control.extend({
}
}
});
+
+ this._map.on('click', function() {
+ this.partsFocused = false;
+ }, this);
+
+ this._map.on('keydown', function(e) {
+ if (this.partsFocused === true) {
+ switch (e.originalEvent.keyCode) {
+ case 38:
+ this._setPart('prev');
+ break;
+ case 40:
+ this._setPart('next');
+ break;
+ }
+ }
+ }, this);
+
this._scrollContainer = $('#slide-sorter .mCSB_container').get(0);
// Add a special frame just as a drop-site for reordering.
@@ -110,7 +129,10 @@ L.Control.PartsPreview = L.Control.extend({
.on(img, 'click', L.DomEvent.stopPropagation)
.on(img, 'click', L.DomEvent.stop)
.on(img, 'click', this._setPart, this)
- .on(img, 'click', this._map.focus, this._map);
+ .on(img, 'click', this._map.focus, this._map)
+ .on(img, 'click', function() {
+ this.partsFocused = true;
+ }, this);
var topBound = this._previewContTop;
var previewFrameTop = 0;
@@ -150,6 +172,33 @@ L.Control.PartsPreview = L.Control.extend({
},
_setPart: function (e) {
+ //helper function to check if the view is in the scrollview visible area
+ function isVisible(el) {
+ var elemRect = el.getBoundingClientRect();
+ var elemTop = elemRect.top;
+ var elemBottom = elemRect.bottom;
+ var isVisible = (elemTop >= 0) && (elemBottom <= window.innerHeight);
+ return isVisible;
+ }
+ if (e === 'prev' || e === 'next') {
+ this._map.setPart(e);
+ var node = $('#slide-sorter .mCSB_container .preview-frame')[this._map.getCurrentPartNumber()];
+ if (!isVisible(node)) {
+ if (e === 'prev') {
+ setTimeout(function () {
+ $('#slide-sorter').mCustomScrollbar('scrollTo', node);
+ }, 50);
+ } else {
+ var nodeHeight = $(node).height();
+ var sliderHeight= $('#slide-sorter').height();
+ var nodePos = $(node).position().top;
+ setTimeout(function () {
+ $('#slide-sorter').mCustomScrollbar('scrollTo', nodePos-(sliderHeight-nodeHeight-nodeHeight/2));
+ }, 50);
+ }
+ }
+ return;
+ }
var part = $('#slide-sorter .mCSB_container .preview-frame').index(e.target.parentNode);
if (part !== null) {
var partId = parseInt(part) - 1; // The first part is just a drop-site for reordering.
More information about the Libreoffice-commits
mailing list