Skip to content

Commit

Permalink
chore: add prettierrc
Browse files Browse the repository at this point in the history
Add prettierrc styling file to resolve automatic styling issues in the future.

I re-minified the dist folder using my minification tools. Feel free to reminify yourself prior to merging or provide docs on what you used to minify.

I also minified your .css file in your dist as well for consistency.
  • Loading branch information
dintriglia committed Mar 15, 2024
1 parent 3571ae9 commit 165d42e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 91 deletions.
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"printWidth": 400,
"tabWidth": 4,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": false,
"arrowParens": "avoid"
}
71 changes: 1 addition & 70 deletions dist/flexmasonry.css

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

8 changes: 1 addition & 7 deletions dist/flexmasonry.js

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

28 changes: 14 additions & 14 deletions src/flexmasonry.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function init(targets, options = {}) {

_options = Object.assign(defaultOptions, options);

_targets.forEach(function(target) {
_targets.forEach(function (target) {
setUp(target);
setHeight(target);
});
Expand All @@ -58,15 +58,15 @@ function setUp(target) {

setColsClass(target);

Array.from(target.children).forEach(function(item) {
Array.from(target.children).forEach(function (item) {
item.classList.add('flexmasonry-item');
});

addBreakElements(target);
}

function onLoad() {
_targets.forEach(function(target) {
_targets.forEach(function (target) {
setHeight(target);
});
}
Expand All @@ -76,7 +76,7 @@ function onResize() {
window.cancelAnimationFrame(_resizeId);
}

_resizeId = window.requestAnimationFrame(function() {
_resizeId = window.requestAnimationFrame(function () {
refreshAll();
});
}
Expand All @@ -93,16 +93,16 @@ function removeEventListeners() {

function setHeight(target) {
if (getCurrentCols() < 2) {
target.style.removeProperty("height");
target.style.removeProperty('height');
Array.from(target.children).forEach(function (item) {
item.style.removeProperty("width");
item.style.removeProperty('width');
});
return;
}

let heights = [];

Array.from(target.children).forEach(function(item) {
Array.from(target.children).forEach(function (item) {
if (!!_options.gap) {
item.style.padding = `${_options.gap}px`;
item.style.width = `${100 / getCurrentCols()}%`;
Expand All @@ -111,8 +111,8 @@ function setHeight(target) {
return;
}

const comp = window.getComputedStyle(item);
const order = comp.getPropertyValue('order');
const comp = window.getComputedStyle(item);
const order = comp.getPropertyValue('order');
const height = comp.getPropertyValue('height');

if (!heights[order - 1]) {
Expand All @@ -127,7 +127,7 @@ function setHeight(target) {

function addBreakElements(target) {
const breakEls = target.querySelectorAll('.flexmasonry-break');
if (Array.from(breakEls).length === (getCurrentCols() - 1)) {
if (Array.from(breakEls).length === getCurrentCols() - 1) {
return;
}

Expand All @@ -141,11 +141,11 @@ function addBreakElements(target) {

function removeBreakElements(target) {
const breakEls = target.querySelectorAll('.flexmasonry-break');
if (Array.from(breakEls).length === (getCurrentCols() - 1)) {
if (Array.from(breakEls).length === getCurrentCols() - 1) {
return;
}

Array.from(breakEls).forEach(function(breakEl) {
Array.from(breakEls).forEach(function (breakEl) {
breakEl.parentNode.removeChild(breakEl);
});
}
Expand Down Expand Up @@ -186,7 +186,7 @@ function refresh(target, options = {}) {
}

function refreshAll(options = {}) {
_targets.forEach(function(target) {
_targets.forEach(function (target) {
refresh(target, options);
});

Expand All @@ -202,4 +202,4 @@ export default {
refresh,
refreshAll,
destroyAll,
}
};

0 comments on commit 165d42e

Please sign in to comment.