Skip to content

Commit

Permalink
Merge branch 'MDL-51451-m28' of https://github.com/sammarshallou/moodle
Browse files Browse the repository at this point in the history
… into MOODLE_28_STABLE
  • Loading branch information
andrewnicols committed Oct 12, 2015
2 parents 6d8dbfe + 735ef8b commit ce4c237
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
Expand Up @@ -71,6 +71,9 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, []
this._enabled = true;
var body = Y.one(Y.config.doc.body);

// Get width of body before turning on lockscroll.
var widthBefore = body.getComputedStyle('width');

// We use a CSS class on the body to handle the actual locking.
body.addClass('lockscroll');

Expand All @@ -83,6 +86,13 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, []
Y.log("Setting the activeScrollLocks count from " + currentCount + " to " + newCount,
'debug', 'moodle-core-lockscroll');

// When initially enabled, set the body max-width to its current width. This
// avoids centered elements jumping because the width changes when scrollbars
// disappear.
if (currentCount === 0) {
body.setStyle('maxWidth', widthBefore);
}

return this;
},

Expand All @@ -109,6 +119,7 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, []

if (currentCount === 1) {
body.removeClass('lockscroll');
body.setStyle('maxWidth', null);
}

body.setAttribute('data-activeScrollLocks', currentCount - 1);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll.js
Expand Up @@ -68,6 +68,9 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, []
this._enabled = true;
var body = Y.one(Y.config.doc.body);

// Get width of body before turning on lockscroll.
var widthBefore = body.getComputedStyle('width');

// We use a CSS class on the body to handle the actual locking.
body.addClass('lockscroll');

Expand All @@ -78,6 +81,13 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, []
newCount = currentCount + 1;
body.setAttribute('data-activeScrollLocks', newCount);

// When initially enabled, set the body max-width to its current width. This
// avoids centered elements jumping because the width changes when scrollbars
// disappear.
if (currentCount === 0) {
body.setStyle('maxWidth', widthBefore);
}

return this;
},

Expand All @@ -103,6 +113,7 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, []

if (currentCount === 1) {
body.removeClass('lockscroll');
body.setStyle('maxWidth', null);
}

body.setAttribute('data-activeScrollLocks', currentCount - 1);
Expand Down
11 changes: 11 additions & 0 deletions lib/yui/src/lockscroll/js/lockscroll.js
Expand Up @@ -69,6 +69,9 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, []
this._enabled = true;
var body = Y.one(Y.config.doc.body);

// Get width of body before turning on lockscroll.
var widthBefore = body.getComputedStyle('width');

// We use a CSS class on the body to handle the actual locking.
body.addClass('lockscroll');

Expand All @@ -81,6 +84,13 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, []
Y.log("Setting the activeScrollLocks count from " + currentCount + " to " + newCount,
'debug', 'moodle-core-lockscroll');

// When initially enabled, set the body max-width to its current width. This
// avoids centered elements jumping because the width changes when scrollbars
// disappear.
if (currentCount === 0) {
body.setStyle('maxWidth', widthBefore);
}

return this;
},

Expand All @@ -107,6 +117,7 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, []

if (currentCount === 1) {
body.removeClass('lockscroll');
body.setStyle('maxWidth', null);
}

body.setAttribute('data-activeScrollLocks', currentCount - 1);
Expand Down

0 comments on commit ce4c237

Please sign in to comment.