fix autoresizing editor on ie

This commit is contained in:
nightwing 2013-07-19 17:44:19 +04:00
commit 4e86a104c2
2 changed files with 22 additions and 23 deletions

View file

@ -62,13 +62,11 @@ var ScrollBarV = function(parent, renderer) {
// of 0px // of 0px
// in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar // in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar
// make element a little bit wider to retain scrollbar when page is zoomed // make element a little bit wider to retain scrollbar when page is zoomed
renderer.once("beforeRender", function() {
renderer.$scrollbarWidth = renderer.$scrollbarWidth =
this.width = dom.scrollbarWidth(parent.ownerDocument); this.width = dom.scrollbarWidth(parent.ownerDocument);
this.fullWidth = this.width; this.fullWidth = this.width;
this.element.style.width = (this.width || 15) + 5 + "px"; this.element.style.width = (this.width || 15) + 5 + "px";
this.setVisible(false); this.setVisible(false);
}.bind(this));
this.element.style.overflowY = "scroll"; this.element.style.overflowY = "scroll";
event.addListener(this.element, "scroll", this.onScrollV.bind(this)); event.addListener(this.element, "scroll", this.onScrollV.bind(this));
@ -89,12 +87,10 @@ var ScrollBarH = function(parent, renderer) {
// of 0px // of 0px
// in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar // in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar
// make element a little bit wider to retain scrollbar when page is zoomed // make element a little bit wider to retain scrollbar when page is zoomed
renderer.once("beforeRender", function() {
this.height = renderer.$scrollbarWidth; this.height = renderer.$scrollbarWidth;
this.fullHeight = this.height; this.fullHeight = this.height;
this.element.style.height = (this.height || 15) + 5 + "px"; this.element.style.height = (this.height || 15) + 5 + "px";
this.setVisible(false); this.setVisible(false);
}.bind(this));
this.element.style.overflowX = "scroll"; this.element.style.overflowX = "scroll";
event.addListener(this.element, "scroll", this.onScrollH.bind(this)); event.addListener(this.element, "scroll", this.onScrollH.bind(this));

View file

@ -318,10 +318,14 @@ var VirtualRenderer = function(container, theme) {
this.resizing++; this.resizing++;
else else
this.resizing = force ? 1 : 0; this.resizing = force ? 1 : 0;
// `|| el.scrollHeight` is required for outosizing editors on ie
// where elements with clientHeight = 0 alsoe have clientWidth = 0
var el = this.container;
if (!height) if (!height)
height = this.container.clientHeight; height = el.clientHeight || el.scrollHeight;
if (!width) if (!width)
width = this.container.clientWidth; width = el.clientWidth || el.scrollWidth;
var changes = this.$updateCachedSize(force, gutterWidth, width, height); var changes = this.$updateCachedSize(force, gutterWidth, width, height);
// console.log("resizing to", width, height, JSON.stringify(this.$size)) // console.log("resizing to", width, height, JSON.stringify(this.$size))
@ -332,18 +336,18 @@ var VirtualRenderer = function(container, theme) {
// }.bind(this), 500) // }.bind(this), 500)
if (!this.$size.scrollerHeight) if (!this.$size.scrollerHeight)
return; return this.resizing = 0;
if (force)
this.$gutterLayer.$padding = null;
if (force) if (force)
this.$renderChanges(changes, true); this.$renderChanges(changes, true);
else else
this.$loop.schedule(changes); this.$loop.schedule(changes);
if (force) if (this.resizing)
this.$gutterLayer.$padding = null; this.resizing = 0;
if (force)
delete this.resizing;
}; };
this.$updateCachedSize = function(force, gutterWidth, width, height) { this.$updateCachedSize = function(force, gutterWidth, width, height) {
@ -398,7 +402,7 @@ var VirtualRenderer = function(container, theme) {
this.onGutterResize = function() { this.onGutterResize = function() {
var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0; var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
if (gutterWidth != this.gutterWidth) if (gutterWidth != this.gutterWidth)
this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height); this.$changes != this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
if (this.session.getUseWrapMode() && this.adjustWrapLimit()) if (this.session.getUseWrapMode() && this.adjustWrapLimit())
this.$loop.schedule(this.CHANGE_FULL); this.$loop.schedule(this.CHANGE_FULL);
@ -727,7 +731,6 @@ var VirtualRenderer = function(container, theme) {
this.$renderChanges = function(changes, force) { this.$renderChanges = function(changes, force) {
if ((!this.session || !this.container.offsetWidth) || (!changes && !force)) { if ((!this.session || !this.container.offsetWidth) || (!changes && !force)) {
this.$logChanges(changes);
this.$changes |= changes; this.$changes |= changes;
return; return;
} }