Skip to content

Commit

Permalink
Added containedArea and spacerClass parameter πŸ‘©β€πŸ’»
Browse files Browse the repository at this point in the history
  • Loading branch information
actuallyakash committed Mar 29, 2021
1 parent 076013d commit a54989c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 2 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## TODO: options needed

* containedArea (use if you're not able to find the element (ex- iframe)) | type: object
* spacerClass (for adding classes in the spacers) | type: string
* defaultSpacing (default margin/padding values) | type: string
* defaultPadding (an object with top, bottom, left, right values) | type: object
* defaultMargin (an object with top, bottom, left, right values) | type: object
Expand All @@ -18,4 +16,5 @@
* padding (to enable padding, which'll be default behaviour) | type: boolean
* margin (to enable margin) | type: boolean
* onDragEnd (a function for using the values when drag is ended) | type: function | ref: interactjs

* containedArea (use if you're not able to find the element (ex- iframe)) | type: object
* spacerClass (for adding classes in the spacers) | type: string
6 changes: 6 additions & 0 deletions spacers/spacers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function spacers( options ) {

let document = options.containedArea ? options.containedArea : window.document;
let elements = document.querySelectorAll( options.element );
let defaultSpacing = options.defaultSpacing ? options.defaultSpacing : '8px';
let spacingUnit = options.spacingUnit ? options.spacingUnit : "px";
Expand Down Expand Up @@ -61,6 +62,11 @@ function spacers( options ) {

document.documentElement.style.setProperty( '--spacer-size', defaultSpacing );

// Addding custom-defined classes
if ( options.spacerClass ) {
spacer.classList.add( options.spacerClass );
}

// Adding default spacing
spacerValue = spacer.getAttribute('data-size') ? spacer.getAttribute('data-size') + "px" : defaultSpacing + spacingUnit;
spacerPosition = spacer.getAttribute('data-position');
Expand Down

0 comments on commit a54989c

Please sign in to comment.