New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

toolslide.js

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

toolslide.js

Minimalistic customizable sliding panel without jQuery

  • 1.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
increased by77.78%
Maintainers
1
Weekly downloads
 
Created
Source

toolslide.js

Minimalistic customizable slide panel (without jQuery)

Table of contents

  • Quick start
  • Usage
  • Examples
  • Options
  • Methods
  • Events
  • Browser support
  • Copyright and license

Quick start

Several quick start options are available:

Download the latest build
Development
Production
Install From Bower
bower install toolslide.js --save
Install From Npm
npm install toolslide.js --save

Done!

Usage

Including files:
<link rel="stylesheet" href="/path/to/toolslide.css">
<script src="/path/to/toolslide.js"></script>
Required HTML structure
<div id="toolslide">
	<div class="ts-container">
        <div class="ts-nav-container">
			<div class="ts-nav-item" ts-target="first">
			</div>
			<!-- Add more navigation buttons here -->
		</div>
		<div class="ts-content-container">
			<div id="first" class="ts-content-item">
				<div class="example-panel">
					<span>First panel content goes here</span>
				</div>
			</div>
			<!-- Add more content panels here -->
		</div>
	</div>
</div>
Attributes

toolslide.js makes use of html attributes to bind navigation elements to respective content.

AttributeDescription
ts-targetSpecifies id of a target panel triggered with this navigation item
Initialization

All you need to do is invoke toolslide on an element:

var myToolslide = toolslide(elemment, options);

You can also initialize with css selector string:

var myToolslide = toolslide("#elementId", options);

Examples

There are some example usages that you can look at to get started. They can be found in the examples folder.

Options

toolslide.js can accept an options object to alter the way it looks and behaves. If no options object is passed default values are used. The structure of an options object is as follows:

{
  position: "left",
  height: "100%",
  width: "300px",
  startOpen: true,
  closeable: true,
  autoclose: false,
  autocloseDelay: 5000,
  clickOutsideToClose: true,
  minClosedSize: 0,
  toggleButton: "",
  embed: false,
  navigationItemWidth: "50px",
  navigationItemHeight: "50px",
  navigationOffsetX: "0px",
  navigationOffsetY: "0px",
  animations: {
    replace: "crossfade 0.5s ease-in-out",
    toggle: "slide 0.5s ease",
  },
  listeners: {
    beforeOpen: function(panel) {},
    afterOpen: function(panel) {},
    berforeClose: function(panel) {},
    afterClose: function(panel) {},
    beforeToggle: function(oldContent, newContent) {}
    afterToggle: function(oldContent, newContent) {}
  }

Here is the explanation of options object:

OptionTypeDescriptionExamples
activePanelstring, ElementPosition of the panel on the screen"#elementId"
positionstringPosition of the panel on the screen"top", "bottom", "left", "right"
heightstringPanel height"200px", "20%"
widthstringPanel width"200px", "20%"
startOpenbooleanOpen panel after initializationtrue, false
closeablebooleanAllow panel to be closed (by clicking active navigation element)true, false
autoclosebooleanAllow panel to be auto closed (only when mouse cursor is outside)true, false
autocloseDelayintAuto close delay in miliseconds5000
clickOutsideToClosebooleanAllow panel to be closed when clicked outsidetrue, false
minClosedSizeintMinimum panel size when closed0
toggleButtonstringId of an element used as external toggle button""
embedbooleanWhether to embed panel within container or overlay ittrue, false
navigationItemWidthstring, numberWidth of the navigation element"50px", "5%"
navigationItemHeightstring, numberHeight of the navigation element"50px", "5%"
navigationOffsetXstring, numberHorizontal offset of the navigation elements container"0px", "5%"
navigationOffsetYstring, numberVertical offset of the navigation elements container"0px", "5%"
animations.replacestringAnimation used when changing active panel"slide 1s ease", "slidefade 2s ease-in", { type: "crossfade", easing: "ease", speed: ".5s" }
animations.togglestringAnimation used when panel is opened/closed"slide 0.5s ease", { type: "slide", easing: "ease", speed: "1s" }
listeners.beforeOpenfunctionCallback fired before panel is openedfunction (panel) {...}
listeners.afterOpenfunctionCallback fired after panel is openedfunction (panel) {...}
listeners.beforeClosefunctionCallback fired before panel is closedfunction (panel) {...}
listeners.afterClosefunctionCallback fired after panel is closedfunction (panel) {...}
listeners.beforeTogglefunctionCallback fired before active content is changedfunction (old, new) {...}
listeners.afterTogglefunctionCallback fired after active content is changedfunction (old, new) {...}

Methods

Methods are called on toolslide instances. You shoud save the instances to variable to have further access to it.

void open()

Show the slide panel.

toolslide.open();
void close()

Hide the slide panel.

toolslide.close();
bool isOpen()

Check if panel is opened.

toolslide.isOpen();
bool isActive(target)

Check if target content element is active. Accepts DOM element as well as just the id.

toolslide.isOpen("elementId");
void setActiveById(elementId)

Sets element with specified id as new active item.

toolslide.setActiveById("elementId");
void setActiveByIndex(index)

Sets element at specified index as active item.

toolslide.setActiveByIndex(0);

Events

toolslide.js provides custom events for some of it's actions. Appropriate callbacks can be specified in options.

EventDescriptionArguments
beforeOpenFires before panel is opened.panelElement
afterOpenFires after panel is opened.panelElement
beforeCloseFires before panel is closed.panelElement
afterCloseFires after panel is closed.panelElement
beforeToggleFires before active content is changed.oldContentElement, newContentElement
afterToggleFires after active content is changed.oldContentElement, newContentElement

Licensed under MIT license.

^ back to top

Keywords

FAQs

Package last updated on 28 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc