Layout von Websiten mit Bootstrap und Foundation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <!-- IGNORE THE HTML BLOCK BELOW, THE INTERESTING PART IS AFTER IT -->
  2. <h1 align="center">Popper.js</h1>
  3. <p align="center">
  4. <strong>A library used to position poppers in web applications.</strong>
  5. </p>
  6. <p align="center">
  7. <img src="http://badge-size.now.sh/https://unpkg.com/popper.js/dist/popper.min.js?compression=brotli" alt="Stable Release Size"/>
  8. <img src="http://badge-size.now.sh/https://unpkg.com/popper.js/dist/popper.min.js?compression=gzip" alt="Stable Release Size"/>
  9. <a href="https://codeclimate.com/github/FezVrasta/popper.js/coverage"><img src="https://codeclimate.com/github/FezVrasta/popper.js/badges/coverage.svg" alt="Istanbul Code Coverage"/></a>
  10. <a href="https://www.npmjs.com/browse/depended/popper.js"><img src="https://badgen.net/npm/dependents/popper.js" alt="Dependents packages" /></a>
  11. <a href="https://spectrum.chat/popper-js" target="_blank"><img src="https://img.shields.io/badge/chat-on_spectrum-6833F9.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyBpZD0iTGl2ZWxsb18xIiBkYXRhLW5hbWU9IkxpdmVsbG8gMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgMTAgOCI%2BPGRlZnM%2BPHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7fTwvc3R5bGU%2BPC9kZWZzPjx0aXRsZT5zcGVjdHJ1bTwvdGl0bGU%2BPHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNSwwQy40MiwwLDAsLjYzLDAsMy4zNGMwLDEuODQuMTksMi43MiwxLjc0LDMuMWgwVjcuNThhLjQ0LjQ0LDAsMCwwLC42OC4zNUw0LjM1LDYuNjlINWM0LjU4LDAsNS0uNjMsNS0zLjM1UzkuNTgsMCw1LDBaTTIuODMsNC4xOGEuNjMuNjMsMCwxLDEsLjY1LS42M0EuNjQuNjQsMCwwLDEsMi44Myw0LjE4Wk01LDQuMThhLjYzLjYzLDAsMSwxLC42NS0uNjNBLjY0LjY0LDAsMCwxLDUsNC4xOFptMi4xNywwYS42My42MywwLDEsMSwuNjUtLjYzQS42NC42NCwwLDAsMSw3LjE3LDQuMThaIi8%2BPC9zdmc%2B" alt="Get support or discuss"/></a>
  12. <br />
  13. <a href="https://travis-ci.org/FezVrasta/popper.js/branches" target="_blank"><img src="https://travis-ci.org/FezVrasta/popper.js.svg?branch=master" alt="Build Status"/></a>
  14. <a href="https://saucelabs.com/u/popperjs" target="_blank"><img src="https://badges.herokuapp.com/browsers?labels=none&googlechrome=latest&firefox=latest&microsoftedge=latest&iexplore=11,10&safari=latest" alt="SauceLabs Reports"/></a>
  15. </p>
  16. <img src="https://raw.githubusercontent.com/FezVrasta/popper.js/master/popperjs.png" align="right" width=250 />
  17. <!-- 🚨 HEY! HERE BEGINS THE INTERESTING STUFF 🚨 -->
  18. ## Wut? Poppers?
  19. A popper is an element on the screen which "pops out" from the natural flow of your application.
  20. Common examples of poppers are tooltips, popovers and drop-downs.
  21. ## So, yet another tooltip library?
  22. Well, basically, **no**.
  23. Popper.js is a **positioning engine**, its purpose is to calculate the position of an element
  24. to make it possible to position it near a given reference element.
  25. The engine is completely modular and most of its features are implemented as **modifiers**
  26. (similar to middlewares or plugins).
  27. The whole code base is written in ES2015 and its features are automatically tested on real browsers thanks to [SauceLabs](https://saucelabs.com/) and [TravisCI](https://travis-ci.org/).
  28. Popper.js has zero dependencies. No jQuery, no LoDash, nothing.
  29. It's used by big companies like [Twitter in Bootstrap v4](https://getbootstrap.com/), [Microsoft in WebClipper](https://github.com/OneNoteDev/WebClipper) and [Atlassian in AtlasKit](https://aui-cdn.atlassian.com/atlaskit/registry/).
  30. ### Popper.js
  31. This is the engine, the library that computes and, optionally, applies the styles to
  32. the poppers.
  33. Some of the key points are:
  34. - Position elements keeping them in their original DOM context (doesn't mess with your DOM!);
  35. - Allows to export the computed informations to integrate with React and other view libraries;
  36. - Supports Shadow DOM elements;
  37. - Completely customizable thanks to the modifiers based structure;
  38. Visit our [project page](https://fezvrasta.github.io/popper.js) to see a lot of examples of what you can do with Popper.js!
  39. Find [the documentation here](/docs/_includes/popper-documentation.md).
  40. ### Tooltip.js
  41. Since lots of users just need a simple way to integrate powerful tooltips in their projects,
  42. we created **Tooltip.js**.
  43. It's a small library that makes it easy to automatically create tooltips using as engine Popper.js.
  44. Its API is almost identical to the famous tooltip system of Bootstrap, in this way it will be
  45. easy to integrate it in your projects.
  46. The tooltips generated by Tooltip.js are accessible thanks to the `aria` tags.
  47. Find [the documentation here](/docs/_includes/tooltip-documentation.md).
  48. ## Installation
  49. Popper.js is available on the following package managers and CDNs:
  50. | Source | |
  51. |:-------|:---------------------------------------------------------------------------------|
  52. | npm | `npm install popper.js --save` |
  53. | yarn | `yarn add popper.js` |
  54. | NuGet | `PM> Install-Package popper.js` |
  55. | Bower | `bower install popper.js --save` |
  56. | unpkg | [`https://unpkg.com/popper.js`](https://unpkg.com/popper.js) |
  57. | cdnjs | [`https://cdnjs.com/libraries/popper.js`](https://cdnjs.com/libraries/popper.js) |
  58. Tooltip.js as well:
  59. | Source | |
  60. |:-------|:---------------------------------------------------------------------------------|
  61. | npm | `npm install tooltip.js --save` |
  62. | yarn | `yarn add tooltip.js` |
  63. | Bower* | `bower install tooltip.js=https://unpkg.com/tooltip.js --save` |
  64. | unpkg | [`https://unpkg.com/tooltip.js`](https://unpkg.com/tooltip.js) |
  65. | cdnjs | [`https://cdnjs.com/libraries/popper.js`](https://cdnjs.com/libraries/popper.js) |
  66. \*: Bower isn't officially supported, it can be used to install Tooltip.js only trough the unpkg.com CDN. This method has the limitation of not being able to define a specific version of the library. Bower and Popper.js suggests to use npm or Yarn for your projects.
  67. For more info, [read the related issue](https://github.com/FezVrasta/popper.js/issues/390).
  68. ### Dist targets
  69. Popper.js is currently shipped with 3 targets in mind: UMD, ESM and ESNext.
  70. - UMD - Universal Module Definition: AMD, RequireJS and globals;
  71. - ESM - ES Modules: For webpack/Rollup or browser supporting the spec;
  72. - ESNext: Available in `dist/`, can be used with webpack and `babel-preset-env`;
  73. Make sure to use the right one for your needs. If you want to import it with a `<script>` tag, use UMD.
  74. ## Usage
  75. Given an existing popper DOM node, ask Popper.js to position it near its button
  76. ```js
  77. var reference = document.querySelector('.my-button');
  78. var popper = document.querySelector('.my-popper');
  79. var anotherPopper = new Popper(
  80. reference,
  81. popper,
  82. {
  83. // popper options here
  84. }
  85. );
  86. ```
  87. ### Callbacks
  88. Popper.js supports two kinds of callbacks, the `onCreate` callback is called after
  89. the popper has been initialized. The `onUpdate` one is called on any subsequent update.
  90. ```js
  91. const reference = document.querySelector('.my-button');
  92. const popper = document.querySelector('.my-popper');
  93. new Popper(reference, popper, {
  94. onCreate: (data) => {
  95. // data is an object containing all the informations computed
  96. // by Popper.js and used to style the popper and its arrow
  97. // The complete description is available in Popper.js documentation
  98. },
  99. onUpdate: (data) => {
  100. // same as `onCreate` but called on subsequent updates
  101. }
  102. });
  103. ```
  104. ### Writing your own modifiers
  105. Popper.js is based on a "plugin-like" architecture, most of its features are fully encapsulated "modifiers".
  106. A modifier is a function that is called each time Popper.js needs to compute the position of the popper. For this reason, modifiers should be very performant to avoid bottlenecks.
  107. To learn how to create a modifier, [read the modifiers documentation](docs/_includes/popper-documentation.md#modifiers--object)
  108. ### React, Vue.js, Angular, AngularJS, Ember.js (etc...) integration
  109. Integrating 3rd party libraries in React or other libraries can be a pain because
  110. they usually alter the DOM and drive the libraries crazy.
  111. Popper.js limits all its DOM modifications inside the `applyStyle` modifier,
  112. you can simply disable it and manually apply the popper coordinates using
  113. your library of choice.
  114. For a comprehensive list of libraries that let you use Popper.js into existing
  115. frameworks, visit the [MENTIONS](/MENTIONS.md) page.
  116. Alternatively, you may even override your own `applyStyles` with your custom one and
  117. integrate Popper.js by yourself!
  118. ```js
  119. function applyReactStyle(data) {
  120. // export data in your framework and use its content to apply the style to your popper
  121. };
  122. const reference = document.querySelector('.my-button');
  123. const popper = document.querySelector('.my-popper');
  124. new Popper(reference, popper, {
  125. modifiers: {
  126. applyStyle: { enabled: false },
  127. applyReactStyle: {
  128. enabled: true,
  129. fn: applyReactStyle,
  130. order: 800,
  131. },
  132. },
  133. });
  134. ```
  135. ### Migration from Popper.js v0
  136. Since the API changed, we prepared some migration instructions to make it easy to upgrade to
  137. Popper.js v1.
  138. https://github.com/FezVrasta/popper.js/issues/62
  139. Feel free to comment inside the issue if you have any questions.
  140. ### Performances
  141. Popper.js is very performant. It usually takes 0.5ms to compute a popper's position (on an iMac with 3.5G GHz Intel Core i5).
  142. This means that it will not cause any [jank](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool/anatomy-of-jank), leading to a smooth user experience.
  143. ## Notes
  144. ### Libraries using Popper.js
  145. The aim of Popper.js is to provide a stable and powerful positioning engine ready to
  146. be used in 3rd party libraries.
  147. Visit the [MENTIONS](/MENTIONS.md) page for an updated list of projects.
  148. ### Credits
  149. I want to thank some friends and projects for the work they did:
  150. - [@AndreaScn](https://github.com/AndreaScn) for his work on the GitHub Page and the manual testing he did during the development;
  151. - [@vampolo](https://github.com/vampolo) for the original idea and for the name of the library;
  152. - [Sysdig](https://github.com/Draios) for all the awesome things I learned during these years that made it possible for me to write this library;
  153. - [Tether.js](http://github.hubspot.com/tether/) for having inspired me in writing a positioning library ready for the real world;
  154. - [The Contributors](https://github.com/FezVrasta/popper.js/graphs/contributors) for their much appreciated Pull Requests and bug reports;
  155. - **you** for the star you'll give to this project and for being so awesome to give this project a try 🙂
  156. ### Copyright and license
  157. Code and documentation copyright 2016 **Federico Zivolo**. Code released under the [MIT license](LICENSE.md). Docs released under Creative Commons.