Skip to content

Commit

Permalink
Added hover parameter 🛸
Browse files Browse the repository at this point in the history
  • Loading branch information
actuallyakash committed Mar 29, 2021
1 parent 181ec06 commit fb494a8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
element: '.inner-element',
appendHtml: 'begin',
defaultSpacing: '10px',
showOnHover: true,
onDragEnd: function( data) {
console.log(data);
}
Expand Down
13 changes: 13 additions & 0 deletions spacers/spacers.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,16 @@
.spacer[data-type=margin].spacer[data-position=right] {
left: 100%;
}

/* On-hover */
.spacer-wrapper.on-hover .spacer {
background: transparent;
}

.spacer-wrapper.on-hover .spacer[data-type=padding]:hover {
background: var(--padding-bg);
}

.spacer-wrapper.on-hover .spacer[data-type=margin]:hover {
background: var(--margin-bg);
}
3 changes: 2 additions & 1 deletion spacers/spacers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function spacers( options ) {
let defaultSpacing = options.defaultSpacing ? options.defaultSpacing : '8px';
let spacingUnit = options.spacingUnit ? options.spacingUnit : "px";
let enablePadding = options.padding == undefined || options.padding == true ? true : false;
let showOnHover = options.showOnHover ? ' on-hover' : '';
let enableMargin = options.margin ? true : false;
let html, appendHtml;
let margin, padding;
Expand Down Expand Up @@ -41,7 +42,7 @@ function spacers( options ) {
// settings element's position relative
element.style.position = "relative";

html = '<div class="spacers-wrapper">';
html = '<div class="spacer-wrapper' + showOnHover + '">';

// Padding
html += '<div data-type="padding" data-position="top" data-dragging="bottom" data-size="'+ padding.top +'" class="spacer spacer-' + spacerId + ' spacer-top"></div><div data-type="padding" data-position="bottom" data-dragging="top" data-size="'+ padding.bottom +'" class="spacer spacer-' + spacerId + ' spacer-bottom"></div><div data-type="padding" data-position="left" data-dragging="right" data-size="'+ padding.left +'" class="spacer spacer-' + spacerId + ' spacer-left"></div><div data-type="padding" data-position="right" data-dragging="left" data-size="'+ padding.right +'" class="spacer spacer-' + spacerId + ' spacer-right"></div>';
Expand Down

0 comments on commit fb494a8

Please sign in to comment.