FezVrasta / popper.js
- четверг, 7 апреля 2016 г. в 03:12:13
JavaScript
A ~3.5KB kickass library to manage your poppers
Popper.js is a library used to create poppers in web applications.
A popper is an element on the screen which "pops out" from the natural flow of your application.
Common examples of poppers are tooltips and popovers.
Well, basically, no.
Popper.js is built from the ground up to being modular and fully hackable customizable.
It supports a plugin system you can use to add particular behaviors to your poppers.
It's AMD and CommonJS compatible and it's well documented thanks to our JSDoc page.
Popper.js is mostly a library with the job of making sure your popper stays near the defined reference element (if you want so).
Additionally, it provides an easy way to generate your popper element if you don't want to use one already in your DOM.
Popper.js is available on NPM and Bower:
NPM
npm install popper.js --save
Bower
bower install popper.js --save
jsDelivr
http://www.jsdelivr.com/projects/popper.js
Create a popper near a button:
var reference = document.querySelector('.my-button');
var thePopper = new Popper(
reference,
{
content: 'My awesome popper!'
},
{
// popper options here
}
});
Given an existing popper, ask Popper.js to position it near its button
var reference = document.querySelector('.my-button');
var popper = document.querySelector('.my-popper');
var anotherPopper = new Popper(
reference,
popper,
{
// popper options here
}
});
If you are wondering about the available options of the third argument, check out our documentation
Visit our GitHub Page to see a lot of examples of what you can already do right now!
I want to thank some friends and projects for the work they did:
Code and documentation copyright 2016 Federico Zivolo. Code released under the MIT license. Docs released under Creative Commons.