Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 49 additions & 6 deletions src/gridstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,55 @@
} else {
scrollEl.scrollTop += Math.abs(offsetDiffUp) > Math.abs(distance) ? distance : offsetDiffUp;
}
} else if (distance > 0) {
// moving down
if (el.offsetHeight > innerHeightOrClientHeight) {
scrollEl.scrollTop += distance;
} else {
scrollEl.scrollTop += offsetDiffDown > distance ? distance : offsetDiffDown;
document.getElementsByTagName('head')[0].appendChild(style);
return style.sheet;
},

removeStylesheet: function(id) {
$('STYLE[data-gs-style-id=' + id + ']').remove();
},

insertCSSRule: function(sheet, selector, rules, index) {
if (typeof sheet.insertRule === 'function') {
sheet.insertRule(selector + '{' + rules + '}', index);
} else if (typeof sheet.addRule === 'function') {
sheet.addRule(selector, rules, index);
}
},

toBool: function(v) {
if (typeof v == 'boolean') {
return v;
}
if (typeof v == 'string') {
v = v.toLowerCase();
return !(v === '' || v == 'no' || v == 'false' || v == '0');
}
return Boolean(v);
},

_collisionNodeCheck: function(n) {
return n != this.node && Utils.isIntercepted(n, this.nn);
},

_didCollide: function(bn) {
return Utils.isIntercepted({x: this.n.x, y: this.newY, width: this.n.width, height: this.n.height}, bn);
},

_isAddNodeIntercepted: function(n) {
return Utils.isIntercepted({x: this.x, y: this.y, width: this.node.width, height: this.node.height}, n);
},

parseHeight: function(val) {
var height = val;
var heightUnit = 'px';
if (height && _.isString(height)) {
var match = height.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%)?$/);
if (!match) {
throw new Error('Invalid height');
}
heightUnit = match[2] || 'px';
height = parseFloat(match[1]);
}
}
// move widget y by amount scrolled
Expand Down