Skip to content

Commit

Permalink
updates maxheight var to make it similar casing to other vars
Browse files Browse the repository at this point in the history
  • Loading branch information
yowainwright committed Oct 20, 2016
1 parent f7a660b commit 815590a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions dist/shave.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(global.shave = factory());
}(this, (function () { 'use strict';

function shave(target, maxHeight, opts) {
function shave(target, maxheight, opts) {
var els = typeof target === 'string' ? document.querySelectorAll(target) : target;
if (!('length' in els)) {
els = [els];
Expand All @@ -20,21 +20,21 @@ function shave(target, maxHeight, opts) {
for (var i = 0; i < els.length; i++) {
var el = els[i];
var span = el.querySelector(defaults.classname);
if (el.offsetHeight < maxHeight && span) {
if (el.offsetHeight < maxheight && span) {
el.removeChild(el.querySelector('.js-shave-char'));
var _text = el.textContent;
el.removeChild(span);
el.textContent = _text;
return;
} else if (el.offsetHeight < maxHeight) return;
} else if (el.offsetHeight < maxheight) return;
var text = el.textContent;
var trimmedText = text;
do {
var lastSpace = trimmedText.lastIndexOf(' ');
if (lastSpace < 0) break;
trimmedText = trimmedText.substr(0, lastSpace);
el.textContent = trimmedText;
} while (el.offsetHeight > maxHeight);
} while (el.offsetHeight > maxheight);
var k = 0;
var diff = '';
for (var j = 0; j < text.length; j++) {
Expand All @@ -51,8 +51,8 @@ function shave(target, maxHeight, opts) {
var plugin = window.$ || window.jQuery || window.Zepto;
if (plugin) {
plugin.fn.extend({
shave: function shaveFunc(maxHeight, opts) {
return shave(this, maxHeight, opts);
shave: function shaveFunc(maxheight, opts) {
return shave(this, maxheight, opts);
}
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/shave.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function shave(target, maxHeight, opts) {
export default function shave(target, maxheight, opts) {
let els = typeof target === 'string' ? document.querySelectorAll(target) : target;
if (!('length' in els)) {
els = [els];
Expand All @@ -14,21 +14,21 @@ export default function shave(target, maxHeight, opts) {
for (let i = 0; i < els.length; i++) {
const el = els[i];
const span = el.querySelector(defaults.classname);
if (el.offsetHeight < maxHeight && span) {
if (el.offsetHeight < maxheight && span) {
el.removeChild(el.querySelector('.js-shave-char'));
const text = el.textContent;
el.removeChild(span);
el.textContent = text;
return;
} else if (el.offsetHeight < maxHeight) return;
} else if (el.offsetHeight < maxheight) return;
const text = el.textContent;
let trimmedText = text;
do {
const lastSpace = trimmedText.lastIndexOf(' ');
if (lastSpace < 0) break;
trimmedText = trimmedText.substr(0, lastSpace);
el.textContent = trimmedText;
} while (el.offsetHeight > maxHeight);
} while (el.offsetHeight > maxheight);
let k = 0;
let diff = '';
for (let j = 0; j < text.length; j++) {
Expand All @@ -48,8 +48,8 @@ export default function shave(target, maxHeight, opts) {
const plugin = window.$ || window.jQuery || window.Zepto;
if (plugin) {
plugin.fn.extend({
shave: function shaveFunc(maxHeight, opts) {
return shave(this, maxHeight, opts);
shave: function shaveFunc(maxheight, opts) {
return shave(this, maxheight, opts);
},
});
}

0 comments on commit 815590a

Please sign in to comment.