Skip to content

Commit 11d3ce5

Browse files
author
Alexis Beingessner
committed
Ticket OscarGodson#132 - fixing scrollbars when using maxHeight
1 parent d8405d7 commit 11d3ce5

File tree

3 files changed

+60
-28
lines changed

3 files changed

+60
-28
lines changed

epiceditor/js/epiceditor.js

+29-13
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,7 @@
680680
// TODO: Move into fullscreen setup function (_setupFullscreen)
681681
_elementStates = {}
682682
self._goFullscreen = function (el) {
683-
if (self.settings.autogrow) {
684-
self.getElement('editor').documentElement.style.overflow = "auto";
685-
self.getElement('previewer').documentElement.style.overflow = "auto";
686-
}
683+
this._fixScrollbars('auto');
687684

688685
if (self.is('fullscreen')) {
689686
self._exitFullscreen(el);
@@ -783,10 +780,7 @@
783780
};
784781

785782
self._exitFullscreen = function (el) {
786-
if (self.settings.autogrow) {
787-
self.getElement('editor').documentElement.style.overflow = 'hidden';
788-
self.getElement('previewer').documentElement.style.overflow = 'hidden';
789-
}
783+
this._fixScrollbars();
790784

791785
_saveStyleState(self.element, 'apply', _elementStates.element);
792786
_saveStyleState(self.iframeElement, 'apply', _elementStates.iframeElement);
@@ -1075,9 +1069,7 @@
10751069
self._eeState.startup = false;
10761070

10771071
if (self.settings.autogrow) {
1078-
//prevent ugly temprorary scroll bars
1079-
self.getElement('editor').documentElement.style.overflow = 'hidden';
1080-
self.getElement('previewer').documentElement.style.overflow = 'hidden';
1072+
self._fixScrollbars();
10811073

10821074
boundAutogrow = function () {
10831075
setTimeout(function () {
@@ -1765,11 +1757,11 @@
17651757
, minHeight
17661758
, maxHeight
17671759
, el
1768-
, style;
1760+
, style
1761+
, maxedOut = false;
17691762

17701763
//autogrow in fullscreen is nonsensical
17711764
if (!this.is('fullscreen')) {
1772-
console.log('autogrow');
17731765
if (this.is('edit')) {
17741766
el = this.getElement('editor').documentElement;
17751767
}
@@ -1798,6 +1790,13 @@
17981790

17991791
if (maxHeight && newHeight > maxHeight) {
18001792
newHeight = maxHeight;
1793+
maxedOut = true;
1794+
}
1795+
1796+
if (maxedOut) {
1797+
this._fixScrollbars('auto');
1798+
} else {
1799+
this._fixScrollbars('hidden');
18011800
}
18021801

18031802
//actual resize
@@ -1812,6 +1811,23 @@
18121811
}
18131812
}
18141813

1814+
/**
1815+
* Shows or hides scrollbars based on the autogrow setting
1816+
* @param {string} forceSetting a value to force the overflow to
1817+
*/
1818+
EpicEditor.prototype._fixScrollbars = function (forceSetting) {
1819+
var setting;
1820+
if (this.settings.autogrow) {
1821+
setting = 'hidden';
1822+
}
1823+
else {
1824+
setting = 'auto';
1825+
}
1826+
setting = forceSetting || setting;
1827+
this.getElement('editor').documentElement.style.overflow = setting;
1828+
this.getElement('previewer').documentElement.style.overflow = setting;
1829+
}
1830+
18151831
EpicEditor.version = '0.2.1';
18161832

18171833
// Used to store information to be shared across editors

0 commit comments

Comments
 (0)