
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Flexible slideout menu for mobile webapps
const panel = document.querySelector('#panel');
const toggle = document.querySelectorAll('#toggle');
const menu = document.querySelector('#menu');
const pullin = Pulling.create({
menu,
panel,
});
toggle.addEventListener('click', () => pullin.toggle());
Pulling is available on npm.
npm install pulling
yarn add pulling
You just need a panel for your main content and a menu element:
<nav id="menu">
<header>
<h2>Menu</h2>
</header>
</nav>
<main id="panel">
<header>
<h2>Panel</h2>
</header>
</main>
Styling is simple, too. The library handles most things for you, so just add a background on your panel and menu, and add a min-height
on the panel if you're using the reveal mode.
Then include Pulling and set up the menu.
const panel = document.querySelector('#panel');
const menu = document.querySelector('#menu');
const pullin = Pulling.create({
menu,
panel,
});
See test.html for a full example.
Pulling.create(options)
Creates a new Pulling
instance
options
menu - Element
DOM element of menu
panel - Element
DOM element of panel
side - "left" | "right"
(default: left
)
side menu should display on
mode - "drawer" | "reveal"
(default: drawer
)
whether the menu slide over the panel (drawer
)
or the panel should slide to reveal the menu (reveal
)
margin - number
(default: 25
)
the number of pixels from the edge of the viewport in which a touch event will be accepted
timing - number
(default: 200
)
milliseconds of the transition animation for opening and closing, in the case where it isn't pulled out manually
timingFunction - string
(default: ease
)
CSS3 transition timing function
width - number
(default: 256
)
width of menu in pixels
sensitivity - number
(default: 0.25
)
the speed needed to activate a flick
slope - number
(default: 0.5
)
maximum ratio of vertical touch movement to horizontal touch movement that should be accepted
touch - boolean
(default: true
)
Enable touch functionality
ignoreScrollables - boolean
(default: true
)
Ignore horizontally scrollable elements
All methods are chainable
#open()
Opens the menu. Emits beforeopen
and opened
events.
#close()
Closes the menu. Emits beforeclose
and closed
events.
#toggle(condition?: boolean)
Toggles the state of the menu (closed -> open, open -> closed).
condition === true
, it opens the menucondition === false
, it closes the menu#on(eventName: string, handler: Function)
Add an event handler for the event
#off(eventName: string, handler?: Function)
Remove an event handler for the event, or remove all handlers for the event
#ignore(selector: string)
Ignore touch events from a specific selector
#unignore(selector: string)
Remove selector from ignore list. Will not override ignored selectors.
#disable()
Disable all functionality of the menu
#enable()
Enable the menu's functionality
#disableTouch()
Disable touch event functionality for this menu
#enableTouch()
Enable touch event functionality for this menu
beforeclose
closed
beforeopen
opened
touchstart
touchmove
touchend
You can use these to support multiple menus by disabling one when the other opens:
pullinLeft.on('beforeopen', () => pullinRight.disableTouch());
pullinLeft.on('closed', () => pullinRight.enableTouch());
pullinRight.on('beforeopen', () => pullinLeft.disableTouch());
pullinRight.on('closed', () => pullinLeft.enableTouch());
.state.closed
- boolean
.state.closing
- boolean
.state.open
- boolean
.state.opening
- boolean
You can either use .ignore(selector)
to add the specific element selector to the ignore list, or you can do .ignore('[data-pullin-ignore]')
to add that selector the the list and then just add the data-pullin-ignore
attribute to every element you want ignored.
// vanilla js
document.querySelector('.toggle-menu').addEventListener('click', () => pullin.toggle());
// jQuery
$('.toggle-menu').on('click', () => pullin.toggle());
You'll want to use events to keep one menu disabled while the other is open.
pullinLeft.on('beforeopen', () => {
pullinRight.close().disableTouch();
});
pullinLeft.on('closed', () => pullinRight.enableTouch());
pullinRight.on('beforeopen', () => {
pullinLeft.close().disableTouch();
});
pullinRight.on('closed', () => pullinLeft.enableTouch());
FAQs
Flexible slideout menu for mobile webapps
The npm package pulling receives a total of 885 weekly downloads. As such, pulling popularity was classified as not popular.
We found that pulling demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.