Fixed viewport issue with pageup/pagedown on chrome. Fixes #505

This commit is contained in:
benweet 2014-09-06 01:08:57 +01:00
parent 33fb3573ee
commit d33037e18d

View File

@ -125,6 +125,7 @@ define([
} }
this.isOpen = _.isBoolean(show) ? show : !this.isOpen; this.isOpen = _.isBoolean(show) ? show : !this.isOpen;
if(this.isOpen) { if(this.isOpen) {
this.isShown = true;
this.$elt.addClass('panel-open').trigger('show.layout.toggle'); this.$elt.addClass('panel-open').trigger('show.layout.toggle');
if(backdrop) { if(backdrop) {
$backdropElt = $(utils.createBackdrop(wrapperL1.elt)).on('click.backdrop', _.bind(function() { $backdropElt = $(utils.createBackdrop(wrapperL1.elt)).on('click.backdrop', _.bind(function() {
@ -134,7 +135,9 @@ define([
} }
transitionEndCallbacks.push(_.bind(function() { transitionEndCallbacks.push(_.bind(function() {
if(--pushedEvents === 0) { if(--pushedEvents === 0) {
this.isOpen && this.$elt.trigger('shown.layout.toggle'); if(this.isOpen) {
this.$elt.trigger('shown.layout.toggle');
}
} }
}, this)); }, this));
} }
@ -147,7 +150,10 @@ define([
} }
transitionEndCallbacks.push(_.bind(function() { transitionEndCallbacks.push(_.bind(function() {
if(--pushedEvents === 0) { if(--pushedEvents === 0) {
!this.isOpen && this.$elt.removeClass('panel-open bring-to-front').trigger('hidden.layout.toggle'); if(!this.isOpen) {
this.isShown = false;
this.$elt.removeClass('panel-open bring-to-front').trigger('hidden.layout.toggle');
}
} }
}, this)); }, this));
} }
@ -254,6 +260,14 @@ define([
var isVertical = settings.layoutOrientation == "vertical"; var isVertical = settings.layoutOrientation == "vertical";
function fixViewportScrolling() {
// Fix a weird viewport behavior using pageup/pagedown in Webkit
wrapperL1.width = windowSize.width + menuPanelWidth + (documentPanel.isShown ? documentPanelWidth : 0);
wrapperL1.elt.style.width = wrapperL1.width + 'px';
documentPanel.right = documentPanel.isShown ? 0 : -documentPanelWidth;
documentPanel.elt.style.right = documentPanel.right + 'px';
}
function resizeAll() { function resizeAll() {
windowSize = { windowSize = {
width: window.innerWidth, width: window.innerWidth,
@ -380,6 +394,7 @@ define([
previewResizer.applyCss(); previewResizer.applyCss();
navbarToggler.applyCss(); navbarToggler.applyCss();
fixViewportScrolling();
previewButtons.adjustPosition(); previewButtons.adjustPosition();
onResize(); onResize();
@ -431,6 +446,15 @@ define([
navbarTitleContainerElt = navbar.elt.querySelector('.title-container'); navbarTitleContainerElt = navbar.elt.querySelector('.title-container');
$navbarTitleElt = navbar.$elt.find('.file-title-navbar, .input-file-title'); $navbarTitleElt = navbar.$elt.find('.file-title-navbar, .input-file-title');
// Fix a weird viewport behavior using pageup/pagedown in Webkit
$([
wrapperL1.elt,
wrapperL2.elt,
wrapperL3.elt
]).on('scroll', function() {
this.scrollLeft = 0;
});
_.each(navbar.elt.querySelectorAll('.right-buttons'), function(btnGroupElt) { _.each(navbar.elt.querySelectorAll('.right-buttons'), function(btnGroupElt) {
navbarBtnGroups.push({ navbarBtnGroups.push({
elt: btnGroupElt, elt: btnGroupElt,
@ -474,6 +498,7 @@ define([
// Focus on editor when document panel is closed // Focus on editor when document panel is closed
documentPanel.$elt.on('hidden.layout.toggle', function() { documentPanel.$elt.on('hidden.layout.toggle', function() {
fixViewportScrolling();
isModalShown || editor.elt.focus(); isModalShown || editor.elt.focus();
}); });