Popper.js babban ษakin karatu ne mai ban sha'awa mai buษewa wanda ke ba da injunan sakawa mai ฦarfi don tukwici na kayan aiki, popovers, zazzage-zazzagewa, da sauran kewayon sauran abubuwan gidan yanar gizo. ฦarfinsa ya ta'allaka ne kan yadda yake saurin sarrafa ฦididdiga masu rikitarwa, tare da ba da zaษuษษukan da za a iya daidaita su sosai ga masu haษakawa. Ko kun kasance ฦwararren Javascript dev, ko kuma farawa, gabatar da Popper.js zuwa saitin kayan aikinku na iya zama mai canza wasa.
Sanya Popper.js
Ana iya shigar da Popper.js cikin sauri ta hanyoyi daban-daban, shahararrun su ne CDN da NPM.
// via CDN <script src="https://unpkg.com/@popperjs/core@2"></script> // via NPM npm install @popperjs/core
Laburaren na zamani ne, ma'ana za ku iya shigo da abin da kuke buฦata kawai, rage girman gungu na ฦarshe don aikinku.
Amfani da Popper.js a cikin Lambar ku
Yanzu da muka shigar da Popper.js, za mu iya fara fahimtar yuwuwar sa a cikin aikace-aikacen mu. Bari mu yi tafiya ta hanyar mataki-mataki don aiwatar da kayan aiki na asali ta amfani da Popper.js.
Da farko, la'akari da html:
<button id="button" aria-describedby="tooltip">Hover me</button> <div id="tooltip" role="tooltip">I'm a Tooltip</div>
A cikin fayil ษin Javascript ษin mu, za mu gabatar da misalin Popper:
import { createPopper } from '@popperjs/core'; const button = document.querySelector('#button'); const tooltip = document.querySelector('#tooltip'); createPopper(button, tooltip);
A sama, mun fara shigo da aikin ฦirฦirarPopper daga ษakin karatu na mu. Bayan haka, muna zaษar maษallin mu da abubuwan kayan aiki daga DOM, kuma mu kira CreatePopper akan su. Wannan yana yin lissafin sakawa ta atomatik kuma yana amfani da salo zuwa tukwici na kayan aiki.
Duban Kusa a CreatePopper Aiki
Aikin 'createPopper' shine zuciyar Popper.js kuma ya haษa da hujjoji biyu na tilas: abin da ake magana da shi da kuma sinadarin popper.
- Abubuwan tunani shine kashi wanda za'a sanya tip ษin kayan aikin Popper ษin ku - a cikin misalin da ke sama, maษallin mu.
- The popper element shine Tooltip ko popover kanta - a cikin misalin da ke sama, shi ne kayan aikin mu.
Bayan wuce waษannan azaman muhawara cikin ฦirฦirarPopper(), yana kula da samar da mahimman salon kayan aikin ku, yana ba shi damar 'pop' a daidai matsayi dangane da maษallin.
Popper.js babban ษakin karatu ne mai nauyi amma mai ฦarfi wanda zai iya haษaka ฦwarewar mai amfani sosai. Yana ษaukar zafi mai yawa daga sarrafa kayan aikin kayan aiki da popovers, wanda ke ba mu, masu haษakawa, mu mai da hankali kan wasu mahimman abubuwan aikace-aikacen. Don haka, idan kuna neman mafi kyawun sarrafa overlays na kowane iri a cikin aikace-aikacenku, tabbas ba Popper.js harbi!