Change the way to re-attach rails when they're detached.
Instead of destroying and re-initialising the plugin, just re-append them.
This commit is contained in:
parent
2e071274db
commit
4a7f27356a
@ -60,6 +60,13 @@ module.exports = function (element) {
|
||||
i.contentWidth = element.scrollWidth;
|
||||
i.contentHeight = element.scrollHeight;
|
||||
|
||||
if (!element.contains(i.scrollbarXRail)) {
|
||||
d.appendTo(i.scrollbarXRail, element);
|
||||
}
|
||||
if (!element.contains(i.scrollbarYRail)) {
|
||||
d.appendTo(i.scrollbarYRail, element);
|
||||
}
|
||||
|
||||
if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) {
|
||||
i.scrollbarXActive = true;
|
||||
i.railXWidth = i.containerWidth - i.railXMarginWidth;
|
||||
|
@ -4,20 +4,12 @@
|
||||
'use strict';
|
||||
|
||||
var d = require('../lib/dom')
|
||||
, destroy = require('./destroy')
|
||||
, initialize = require('./initialize')
|
||||
, instances = require('./instances')
|
||||
, updateGeometry = require('./update-geometry');
|
||||
|
||||
module.exports = function (element) {
|
||||
var i = instances.get(element);
|
||||
|
||||
if (!i.scrollbarXRail || !element.contains(i.scrollbarXRail) ||
|
||||
!i.scrollbarYRail || !element.contains(i.scrollbarYRail)) {
|
||||
// If there's something wrong in the plugin, re-initialise.
|
||||
destroy(element);
|
||||
initialize(element);
|
||||
} else {
|
||||
// Hide scrollbars not to affect scrollWidth and scrollHeight
|
||||
d.css(i.scrollbarXRail, 'display', 'none');
|
||||
d.css(i.scrollbarYRail, 'display', 'none');
|
||||
@ -26,5 +18,4 @@ module.exports = function (element) {
|
||||
|
||||
d.css(i.scrollbarXRail, 'display', 'block');
|
||||
d.css(i.scrollbarYRail, 'display', 'block');
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user