Skip to content

Commit

Permalink
[js:core] fix #3359 add an option noResizeBySelf
Browse files Browse the repository at this point in the history
```
/**
 * Do not resize the elFinder node itself on resize parent node
 * Specify `true` when controlling with CSS such as Flexbox
 *
 * @type Boolean
 * @default false
 */
noResizeBySelf : false,
```
  • Loading branch information
nao-pon committed Jun 12, 2021
1 parent cab081e commit 3854a50
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 31 deletions.
65 changes: 34 additions & 31 deletions js/elFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3448,40 +3448,43 @@ var elFinder = function(elm, opts, bootCallback) {
clearTimeout(heightBase.data('resizeTm'));
}

if (typeof h === 'string') {
if (mt = h.match(/^([0-9.]+)%$/)) {
// setup heightBase
if (! heightBase || ! heightBase.length) {
heightBase = $(window);
}
if (! heightBase.data('marginToMyNode')) {
heightBase.data('marginToMyNode', getMargin());
}
if (! heightBase.data('fitToBaseFunc')) {
heightBase.data('fitToBaseFunc', function(e) {
var tm = heightBase.data('resizeTm');
e.preventDefault();
e.stopPropagation();
tm && cancelAnimationFrame(tm);
if (! node.hasClass('elfinder-fullscreen') && (!self.UA.Mobile || heightBase.data('rotated') !== self.UA.Rotated)) {
heightBase.data('rotated', self.UA.Rotated);
heightBase.data('resizeTm', requestAnimationFrame(function() {
self.restoreSize();
}));
}
});
}
if (typeof heightBase.data('rotated') === 'undefined') {
heightBase.data('rotated', self.UA.Rotated);
if (! self.options.noResizeBySelf) {
if (typeof h === 'string') {
if (mt = h.match(/^([0-9.]+)%$/)) {
// setup heightBase
if (! heightBase || ! heightBase.length) {
heightBase = $(window);
}
if (! heightBase.data('marginToMyNode')) {
heightBase.data('marginToMyNode', getMargin());
}
if (! heightBase.data('fitToBaseFunc')) {
heightBase.data('fitToBaseFunc', function(e) {
var tm = heightBase.data('resizeTm');
e.preventDefault();
e.stopPropagation();
tm && cancelAnimationFrame(tm);
if (! node.hasClass('elfinder-fullscreen') && (!self.UA.Mobile || heightBase.data('rotated') !== self.UA.Rotated)) {
heightBase.data('rotated', self.UA.Rotated);
heightBase.data('resizeTm', requestAnimationFrame(function() {
self.restoreSize();
}));
}
});
}
if (typeof heightBase.data('rotated') === 'undefined') {
heightBase.data('rotated', self.UA.Rotated);
}
h = heightBase.height() * (mt[1] / 100) - heightBase.data('marginToMyNode');

heightBase.off('resize.' + self.namespace, heightBase.data('fitToBaseFunc'));
fit && heightBase.on('resize.' + self.namespace, heightBase.data('fitToBaseFunc'));
}
h = heightBase.height() * (mt[1] / 100) - heightBase.data('marginToMyNode');

heightBase.off('resize.' + self.namespace, heightBase.data('fitToBaseFunc'));
fit && heightBase.on('resize.' + self.namespace, heightBase.data('fitToBaseFunc'));
}

node.css({ width : w, height : parseInt(h) });
}

node.css({ width : w, height : parseInt(h) });

size.w = Math.round(node.width());
size.h = Math.round(node.height());
node.data('resizeSize', size);
Expand Down
9 changes: 9 additions & 0 deletions js/elFinder.options.js
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,15 @@ elFinder.prototype._options = {
*/
height : 400,

/**
* Do not resize the elFinder node itself on resize parent node
* Specify `true` when controlling with CSS such as Flexbox
*
* @type Boolean
* @default false
*/
noResizeBySelf : false,

/**
* Base node object or selector
* Element which is the reference of the height percentage
Expand Down

0 comments on commit 3854a50

Please sign in to comment.