1.0.6 • Published 3 years ago

spacersjs v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

spacers

when you need more space

Demo

http://actuallyakash.github.io/spacers

Package Managers

# Bower
bower install --save spacersjs

# NPM
npm install spacersjs

CDNs

# unpkg
<link rel="stylesheet" href="https://unpkg.com/spacersjs/spacers/spacers.min.css">
<script src="https://unpkg.com/spacersjs/spacers/spacers.min.js"></script>

# jsDelivr
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/spacersjs/spacers/spacers.min.css">
<script src="https://cdn.jsdelivr.net/npm/spacersjs/spacers/spacers.min.js"></script>

Bookmarklet

Try spacers quickly on any webpage through the bookmarklet.

javascript: (() => {var spacerScript=document.createElement("script");spacerScript.type="text/javascript",spacerScript.src="https://cdn.jsdelivr.net/npm/spacersjs/spacers/spacers.min.js",document.getElementsByTagName("head")[0].appendChild(spacerScript);var spacersStyles=document.createElement("link");spacersStyles.rel="stylesheet",spacersStyles.type="text/css",spacersStyles.href="https://cdn.jsdelivr.net/npm/spacersjs/spacers/spacers.min.css",document.head.appendChild(spacersStyles),spacerScript.onload=function(){spacers({element:"*",showOnHover:!0,enableLock:!0,onDragEnd:function(e){console.log(e)}}),alert("Spacers active!")};})();

Note: May not work on some websites due to Content Security Policy.

Settings

OptionTypeDefaultDescription
elementstringnullSelector on which the spacer has to be initialized
appendHtmlstringbeginTo append spacer divs after or before the specified element. Use begin to append before the selector and end to append after the selector.
paddingbooleantrueTo enable padding, which is default behavior
marginbooleanfalseTo enable margin
onDragEndbooleannullFunction for using the spacer values when drag is ended
containedAreaobject (DOM node or jQuery object) or window.documentUse if you're not able to find the element (ex- when using iframe)
spacerClassobjectnullFor adding custom classes in the spacers
defaultSpacingstring8Initial starting spacer height.
defaultPaddingobjectnullan object with initial padding spacer top, bottom, left, right values. Overwrites the defaultSpacing parameter
defaultMarginobjectnullan object with initial margin spacer top, bottom, left, right values. Overwrites the defaultSpacing parameter
spacingUnitstringpxChange default spacing unit of spacers like em, rem, in, cm ..etc
showOnHoverstringfalseShow spacers only on hover
hideSpacingValuebooleanfalseHides the margin/padding values at the center of the spacer
showLabelstringnullEnable and set the label to specified string beside the spacing value
enableLockbooleanfalseLink opposite spacers
lockIconstring<span class="lock"></span>HTML string for the lock icon
unlockIconstring<span class="unlock"></span>HTML string for the unlock icon

Example

Initialize with:

spacers({
    element: '.element-unique-class'
});

Dependencies

Voila! It works without any dependencies.

License

Copyright (c) 2021 Akash Licensed under the MIT license.

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago