Skip to content

Commit

Permalink
use calc() for widths in version 0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancahill committed Sep 1, 2015
1 parent 6286b7e commit b05c0d5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,7 +1,7 @@
{
"name": "Split.js",
"main": "split.js",
"version": "0.2.3",
"version": "0.2.4",
"homepage": "https://github.com/nathancahill/Split.js",
"authors": [
"Nathan Cahill <nathan@nathancahill.com>"
Expand Down
25 changes: 25 additions & 0 deletions package.json
@@ -0,0 +1,25 @@
{
"name": "splitjs",
"version": "0.2.4",
"description": "A lightweight utility for creating adjustable split views",
"main": "split.js",
"repository": {
"type": "git",
"url": "git+https://github.com/nathancahill/Split.js.git"
},
"keywords": [
"css"
],
"author": "Nathan Cahill <nathan@nathancahill.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/nathancahill/Split.js/issues"
},
"homepage": "https://github.com/nathancahill/Split.js#readme",
"dependencies": {
"uglifyjs": "^2.4.10"
},
"devDependencies": {
"uglifyjs": "^2.4.10"
}
}
9 changes: 4 additions & 5 deletions split.js
Expand Up @@ -75,8 +75,8 @@ var Split = function (ids, options) {

// Left width is the same as offset. Right width is total width - left width.

this.left.style.width = offsetX - (options.gutterWidth / 2) + 'px';
this.right.style.width = this.width - offsetX - (options.gutterWidth / 2) + 'px';
this.left.style.width = 'calc(' + (offsetX / this.width * 100) + '% - ' + options.gutterWidth / 2 + 'px)';
this.right.style.width = 'calc(' + (100 - (offsetX / this.width * 100)) + '% - ' + options.gutterWidth / 2 + 'px)';

if (options.onDrag) {
options.onDrag();
Expand All @@ -91,8 +91,7 @@ var Split = function (ids, options) {
// width is gutterWidth * (ids.length - 1). Before calculating
// each width, subtract the total gutter width for the parent width.

parent = document.getElementById(ids[0]).parentNode,
width = parent.clientWidth - (options.gutterWidth * (ids.length - 1));
parent = document.getElementById(ids[0]).parentNode;

if (!options.widths) {
var percent = 100 / ids.length;
Expand Down Expand Up @@ -142,6 +141,6 @@ var Split = function (ids, options) {
pair.gutter = gutter;
}

el.style.width = width * options.widths[i] / 100 + 'px';
el.style.width = 'calc(' + options.widths[i] + '% - ' + options.gutterWidth / 2 + 'px)';
}
};
2 changes: 1 addition & 1 deletion split.min.js

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

0 comments on commit b05c0d5

Please sign in to comment.