Skip to content

Commit

Permalink
Add missing .css which was removed on fixing #377
Browse files Browse the repository at this point in the history
  • Loading branch information
illuusio committed Jun 25, 2020
1 parent b439435 commit 295421f
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions script/jquery.jscrollpane.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@

paneWidth = newPaneWidth;
paneHeight = newPaneHeight;
container({width: paneWidth, height: paneHeight});
container.css({width: paneWidth, height: paneHeight});

// If nothing changed since last check...
if (!hasContainingSpaceChanged && previousContentWidth == contentWidth && pane.outerHeight() == contentHeight) {
Expand Down Expand Up @@ -285,19 +285,19 @@
}

if(settings.resizeSensor && !resizeEventsAdded) {

// detect size change in content
detectSizeChanges(pane, reinitialiseFn);

// detect size changes of scroll element
detectSizeChanges(elem, reinitialiseFn);

// detect size changes of container
detectSizeChanges(elem.parent(), reinitialiseFn);

// add a reinit on window resize also for safety
window.addEventListener('resize', reinitialiseFn);

resizeEventsAdded = true;
}

Expand All @@ -313,83 +313,83 @@
}

function detectSizeChanges(element, callback) {

// create resize event elements - based on resize sensor: https://github.com/flowkey/resize-sensor/
var resizeWidth, resizeHeight;
var resizeElement = document.createElement('div');
var resizeGrowElement = document.createElement('div');
var resizeGrowChildElement = document.createElement('div');
var resizeShrinkElement = document.createElement('div');
var resizeShrinkChildElement = document.createElement('div');

// add necessary styling
resizeElement.style.cssText = 'position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;';
resizeGrowElement.style.cssText = 'position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;';
resizeShrinkElement.style.cssText = 'position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: scroll; z-index: -1; visibility: hidden;';

resizeGrowChildElement.style.cssText = 'position: absolute; left: 0; top: 0;';
resizeShrinkChildElement.style.cssText = 'position: absolute; left: 0; top: 0; width: 200%; height: 200%;';

// Create a function to programmatically update sizes
var updateSizes = function() {

resizeGrowChildElement.style.width = resizeGrowElement.offsetWidth + 10 + 'px';
resizeGrowChildElement.style.height = resizeGrowElement.offsetHeight + 10 + 'px';

resizeGrowElement.scrollLeft = resizeGrowElement.scrollWidth;
resizeGrowElement.scrollTop = resizeGrowElement.scrollHeight;

resizeShrinkElement.scrollLeft = resizeShrinkElement.scrollWidth;
resizeShrinkElement.scrollTop = resizeShrinkElement.scrollHeight;

resizeWidth = element.width();
resizeHeight = element.height();
};

// create functions to call when content grows
var onGrow = function() {

// check to see if the content has change size
if (element.width() > resizeWidth || element.height() > resizeHeight) {

// if size has changed then reinitialise
callback.apply(this, []);
}
// after reinitialising update sizes
updateSizes();
};

// create functions to call when content shrinks
var onShrink = function() {

// check to see if the content has change size
if (element.width() < resizeWidth || element.height() < resizeHeight) {

// if size has changed then reinitialise
callback.apply(this, []);
}
// after reinitialising update sizes
updateSizes();
};

// bind to scroll events
resizeGrowElement.addEventListener('scroll', onGrow.bind(this));
resizeShrinkElement.addEventListener('scroll', onShrink.bind(this));

// nest elements before adding to pane
resizeGrowElement.appendChild(resizeGrowChildElement);
resizeShrinkElement.appendChild(resizeShrinkChildElement);

resizeElement.appendChild(resizeGrowElement);
resizeElement.appendChild(resizeShrinkElement);

element.append(resizeElement);

// ensure parent element is not statically positioned
if(window.getComputedStyle(element[0], null).getPropertyValue('position') === 'static') {
element[0].style.position = 'relative';
}

// update sizes initially
updateSizes();
}
Expand Down Expand Up @@ -1059,13 +1059,13 @@
function isCloseToBottom()
{
var scrollableHeight = contentHeight - paneHeight;
return (scrollableHeight > 20) && (scrollableHeight - contentPositionY() < 10);
return (scrollableHeight >= 20) && (scrollableHeight - contentPositionY() < 10);
}

function isCloseToRight()
{
var scrollableWidth = contentWidth - paneWidth;
return (scrollableWidth > 20) && (scrollableWidth - contentPositionX() < 10);
return (scrollableWidth >= 20) && (scrollableWidth - contentPositionX() < 10);
}

function initMousewheel()
Expand Down

0 comments on commit 295421f

Please sign in to comment.