Source

Scrollspy jechuun kan beekamu

Hidhaa kamtu yeroo ammaa buufata ilaalchaa keessatti socho'aa akka jiru agarsiisuuf bakka tarree irratti hundaa'uun qaamolee garee tarree ykn qaamolee garee tarree ofumaan fooyyessa.

Akkaataa itti hojjetu

Scrollspy sirnaan hojjechuuf wantoota muraasa barbaachisa:

  • Yoo JavaScriptutil.js keenya madda irraa ijaaraa jirta ta'e, .
  • Qaama nav Bootstrap ykn garee tarree irratti fayyadamuu qaba .
  • Scrollspy position: relative;elementii ati basaastu irratti barbaada, yeroo baay'ee kan <body>.
  • Yeroo elementoota , malee biroo basaastu , tuuta qabaachuu fi hojiirra oolchuu <body>kee mirkaneessi .heightoverflow-y: scroll;
  • Anchors ( <a>) barbaachisoo fi elementii sana waliin agarsiisuu qabu id.

Yeroo milkaa'inaan hojiirra oolu, gareen nav ykn tarree kee akkaataa kanaan ni haaromsa, .activegalmoota isaanii walqabatan irratti hundaa'uun gita wanta tokko irraa gara isa itti aanutti sochoosa.

Fakkeenya navbar keessatti

Naannoo navbar jala jiru garagalchiiti jijjiirama gita socho'aa ilaali. Wantoonni gadi bu'an akkasumas ni calaqqisu.

@furdaa

Beeksisa leggings keytar, brunch id dhaaba aartii dolor labore. Pitchfork yr enim lo-fi osoo isaan hin gurguratin qui. Tumblr qonnaa irraa gara minjaalaatti mirga biskileetii waanuma fedhe. Anim keffiyeh kaarlees kaardii. Velit seitan mcsweeney's suuraa booth 3 lukkuu ji'a irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui tarii waa'ee isaanii hin dhageenye et cardigan fandii imaanaa culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony baayoodiizeelii keffiyeh artiisan ullamco bu'aa.

@mdo jedhaa

Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork beard. Freegan beard aliqua cupidatat mcsweeney's vero. Cupidatat four loko nisi, ea helvetica nulla carles. Tattooed cosby sweater food truck, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 sartorial. Carles non aesthetic exercitation quis gentrify. Brooklyn adipisicing craft beer vice keytar deserunt.

one

Occaecat commodo aliqua delectus. Fap craft beer deserunt skateboard ea. Lomo bicycle rights adipisicing banh mi, velit ea sunt next level locavore single-origin coffee in magna veniam. High life id vinyl, echo park consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing. Consectetur nisi DIY minim messenger bag. Cred ex in, sustainable delectus consectetur fanny pack iphone.

two

In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.

three

Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.

Keytar twee blog, culpa ergamaa boorsaa marfa waanuma fedhe delectus nyaata fe'umsaa. Sapiente synth id akka tilmaamaatti. Locavore sed helvetica cliche irony, thundercats tarii waa'ee isaanii hin dhageenye consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat osoo isaan hin gurguramin dura, terry richardson proident brunch nesciunt quis cosby iswiiterii pariatur keffiyeh ut helvetica artisan. Cardigan biiraa hojii harkaa seitan qophaa'aa velit. VHS chambray laboris yeroodhaaf veniam. Anim mollit minim commodo ullamco qilleensaa.

<nav id="navbar-example2" class="navbar navbar-light bg-light">
  <a class="navbar-brand" href="#">Navbar</a>
  <ul class="nav nav-pills">
    <li class="nav-item">
      <a class="nav-link" href="#fat">@fat</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#mdo">@mdo</a>
    </li>
    <li class="nav-item dropdown">
      <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Dropdown</a>
      <div class="dropdown-menu">
        <a class="dropdown-item" href="#one">one</a>
        <a class="dropdown-item" href="#two">two</a>
        <div role="separator" class="dropdown-divider"></div>
        <a class="dropdown-item" href="#three">three</a>
      </div>
    </li>
  </ul>
</nav>
<div data-spy="scroll" data-target="#navbar-example2" data-offset="0">
  <h4 id="fat">@fat</h4>
  <p>...</p>
  <h4 id="mdo">@mdo</h4>
  <p>...</p>
  <h4 id="one">one</h4>
  <p>...</p>
  <h4 id="two">two</h4>
  <p>...</p>
  <h4 id="three">three</h4>
  <p>...</p>
</div>

Fakkeenya nav nested wajjin

Scrollspy akkasumas nested .navs wajjin hojjeta. Yoo nested .navta'e .activewarri isaas ni ta'u .active. Naannoo navbar cina jiru garagalchiiti jijjiirama gita socho'aa ilaali.

Qabxii 1.

Ex consequat commodo adipisicing sochii qaamaa aute malee occaecat ullamco duis aliqua id magna ullamco eu. Hojjedhu aute ipsum ipsum ullamco cillum consectetur ut fi aute consectetur labore. Fugiat laborum incididunt yeroo eu bu'aa enim dolore proident. Qui laborum do non excepteur nulla magna eiusmod consectetur in. Aliqua et aliqua officia quis et incididunt voluptate kan hin taane kan nama hin barbaachifne kan ta'e kan hin balleessine dolore ut consequat deserunt mollit dolore. Aliquip nulla enim veniam non fugiat id cupidat nulla elit kuupidaat komodo velit ut eiusmod kuupidaat elit dolore.

Qabxii 1-1

Amet tempor mollit aliquip pariatur alatti komodoo do ea cillum koomoodo Lorem fi occaecat elit qui et. Aliquip dadhabbii ex ex esse fedhii occaecat Lorem ullamco deserunt. Aliqua cillum excepteur irure bu'aa id quis ea irraa kan hafe. Taa'uu proident ullamco aute magna pariatur nostrud dadhabbii. Reprehenderit aliqua commodo eiusmod aliquip est do duis amet proident magna consectetur consequat eu koomodo baqachuu hin dhugoomne. Enim aliquip sochii qaamaa ullamco adipisicing voluptate excepteur xiqqaa sochii qaamaa xiqqaa xiqqaa commodo adipisicing sochii qaamaa officia nisi adipisicing. Anim id duis qui consequat dadhabbii adipisicing sint dolor elit cillum anim fi baqachuu.

Qabxii 1-2

Cillum nisi deserunt magna eiusmod qui eiusmod velit voluptate pariatur laborum sunt enim. Irure laboris mollit consequat incididunt sint et culpa culpa incididunt adipisicing magna magna occaecat. Nulla ipsum cillum eiusmod sint elit excepteur ea labore enim consectetur in labore anim. Proident ullamco ipsum esse elit ut Lorem eiusmod dolor et eiusmod. Anim occaecat nulla in non consequat eiusmod velit incididunt.

Item 2

Quis magna Lorem anim amet ipsum do mollit sit cillum voluptate ex nulla tempor. Laborum consequat non elit enim exercitation cillum aliqua consequat id aliqua. Esse ex consectetur mollit voluptate est in duis laboris ad sit ipsum anim Lorem. Incididunt veniam velit elit elit veniam Lorem aliqua quis ullamco deserunt sit enim elit aliqua esse irure. Laborum nisi sit est tempor laborum mollit labore officia laborum excepteur commodo non commodo dolor excepteur commodo. Ipsum fugiat ex est consectetur ipsum commodo tempor sunt in proident.

Item 3

Quis anim sit do amet fugiat dolor velit sit ea ea do reprehenderit culpa duis. Nostrud aliqua ipsum fugiat minim proident occaecat excepteur aliquip culpa aute tempor reprehenderit. Deserunt tempor mollit elit ex pariatur dolore velit fugiat mollit culpa irure ullamco est ex ullamco excepteur.

Item 3-1

Deserunt quis elit Lorem eiusmod amet enim enim amet minim Lorem proident nostrud. Ea id dolore anim exercitation aute fugiat labore voluptate cillum do laboris labore. Ex velit exercitation nisi enim labore reprehenderit labore nostrud ut ut. Esse officia sunt duis aliquip ullamco tempor eiusmod deserunt irure nostrud irure. Ullamco proident veniam laboris ea consectetur magna sunt ex exercitation aliquip minim enim culpa occaecat exercitation. Est tempor excepteur aliquip laborum consequat do deserunt laborum esse eiusmod irure proident ipsum esse qui.

Item 3-2

Labore taa'uu culpa commodo elit adipisicing taa'uu aliquip elit proident voluptate xiqqaa mollit nostrud aute reprehenderit gochuu. Mollit excepteur eu Lorem ipsum anim commodo sint labore Lorem sochii qaamaa keessatti velit incididunt. Occaecat consectetur nisi in occaecat proident minim enim sunt balaaleffachuun sochii qaamaa cupidatat et do officia. Aliquip consequat ad hojii dadhabbii hojii mollit ut amet. Taa'uu pariatur tempor proident in veniam culpa aliqua malee elit magna fugiat eiusmod amet officia.

<nav id="navbar-example3" class="navbar navbar-light bg-light">
  <a class="navbar-brand" href="#">Navbar</a>
  <nav class="nav nav-pills flex-column">
    <a class="nav-link" href="#item-1">Item 1</a>
    <nav class="nav nav-pills flex-column">
      <a class="nav-link ml-3 my-1" href="#item-1-1">Item 1-1</a>
      <a class="nav-link ml-3 my-1" href="#item-1-2">Item 1-2</a>
    </nav>
    <a class="nav-link" href="#item-2">Item 2</a>
    <a class="nav-link" href="#item-3">Item 3</a>
    <nav class="nav nav-pills flex-column">
      <a class="nav-link ml-3 my-1" href="#item-3-1">Item 3-1</a>
      <a class="nav-link ml-3 my-1" href="#item-3-2">Item 3-2</a>
    </nav>
  </nav>
</nav>

<div data-spy="scroll" data-target="#navbar-example3" data-offset="0">
  <h4 id="item-1">Item 1</h4>
  <p>...</p>
  <h5 id="item-1-1">Item 1-1</h5>
  <p>...</p>
  <h5 id="item-1-2">Item 1-2</h5>
  <p>...</p>
  <h4 id="item-2">Item 2</h4>
  <p>...</p>
  <h4 id="item-3">Item 3</h4>
  <p>...</p>
  <h5 id="item-3-1">Item 3-1</h5>
  <p>...</p>
  <h5 id="item-3-2">Item 3-2</h5>
  <p>...</p>
</div>

Fakkeenya tarree-garee waliin

Scrollspy akkasumas .list-groups wajjin hojjeta. Naannoo garee tarree cinaa jiru garagalchiiti jijjiirama gita socho'aa ilaali.

Qabxii 1.

Ex consequat commodo adipisicing sochii qaamaa aute malee occaecat ullamco duis aliqua id magna ullamco eu. Hojjedhu aute ipsum ipsum ullamco cillum consectetur ut fi aute consectetur labore. Fugiat laborum incididunt yeroo eu bu'aa enim dolore proident. Qui laborum do non excepteur nulla magna eiusmod consectetur in. Aliqua et aliqua officia quis et incididunt voluptate kan hin taane kan nama hin barbaachifne kan ta'e kan hin balleessine dolore ut consequat deserunt mollit dolore. Aliquip nulla enim veniam non fugiat id cupidat nulla elit kuupidaat komodo velit ut eiusmod kuupidaat elit dolore.

Qabxii 2ffaa

Quis magna Lorem anim amet ipsum gochuu mollit taa'uu cillum voluptate ex nulla yeroo. Laborum consequat non elit enim sochii qaamaa cillum aliqua bu'aa id aliqua. Esse ex consectetur mollit voluptate est in duis laboris ad taa'uu ipsum anim Lorem. Incididunt veeniyaa velit elit elit veeniyaa Lorem aliqua quis ullamco deserunt taa'uu enim elit aliqua esse irure. Laborum nisi sit est yeroof laborum mollit labore officia laborum excepteur commodo komodo hin taane dolor komodo malee. Ipsum fugiat ex est consectetur ipsum koomoodo yeroodhaaf sunt in proident.

Qabxii 3ffaa

Quis anim taa'uu do amet fugiat dolor velit taa'uu ea ea gochuu reprehenderit culpa duis. Nostrud aliqua ipsum fugiat xiqqaa proident occaecat irraa kan hafe aliquip culpa aute yeroodhaaf reprehenderit. Deserunt yeroodhaaf mollit elit ex pariatur dolore velit baqachuu mollit culpa irure ullamco est ex ullamco malee.

Qabxii 4.

Quis anim taa'uu do amet fugiat dolor velit taa'uu ea ea gochuu reprehenderit culpa duis. Nostrud aliqua ipsum fugiat xiqqaa proident occaecat irraa kan hafe aliquip culpa aute yeroodhaaf reprehenderit. Deserunt yeroodhaaf mollit elit ex pariatur dolore velit baqachuu mollit culpa irure ullamco est ex ullamco malee.

<div id="list-example" class="list-group">
  <a class="list-group-item list-group-item-action" href="#list-item-1">Item 1</a>
  <a class="list-group-item list-group-item-action" href="#list-item-2">Item 2</a>
  <a class="list-group-item list-group-item-action" href="#list-item-3">Item 3</a>
  <a class="list-group-item list-group-item-action" href="#list-item-4">Item 4</a>
</div>
<div data-spy="scroll" data-target="#list-example" data-offset="0" class="scrollspy-example">
  <h4 id="list-item-1">Item 1</h4>
  <p>...</p>
  <h4 id="list-item-2">Item 2</h4>
  <p>...</p>
  <h4 id="list-item-3">Item 3</h4>
  <p>...</p>
  <h4 id="list-item-4">Item 4</h4>
  <p>...</p>
</div>

Fayyadama

Karaa amaloota deetaa

Amala scrollspy salphaatti gara navigeeshinii barruu gubbaa keetti dabaluuf, data-spy="scroll"elementii basaasuu barbaaddutti dabali (baay'inaan kun kan ta'a <body>). Sana booda data-targetamalli ID ykn gita qaama warraa qaama Bootstrap kamiyyuu waliin dabali .nav.

body {
  position: relative;
}
<body data-spy="scroll" data-target="#navbar-example">
  ...
  <div id="navbar-example">
    <ul class="nav nav-tabs" role="tablist">
      ...
    </ul>
  </div>
  ...
</body>

Karaa JaavaScript

CSS keessan keessatti erga dabaltanii booda position: relative;, karaa JavaScript scrollspy waami:

$('body').scrollspy({ target: '#navbar-example' })

Target ID furmaata argachuu danda'an barbaachisa

Hidhamtoonni Navbar galmoota id furmaata argachuu danda'an qabaachuu qabu. Fakkeenyaaf, a <a href="#home">home</a>waan DOM keessa jiru akka <div id="home"></div>.

Qaamolee :visiblegalma hin taane tuffataman

Qaamonni galmee :visibleakkaataa jQuery hin taane ni tuffatamu fi wantoonni nav isaanii walgitan gonkumaa hin calaqqisan.

Malawwan

.scrollspy('refresh')

Yeroo scrollspy fayyadamtu elementoota DOM irraa dabaluu ykn haquu wajjin walqabatee, mala haaromsaa akkasitti waamuun si barbaachisa:

$('[data-spy="scroll"]').each(function () {
  var $spy = $(this).scrollspy('refresh')
})

.scrollspy('dispose')

Scrollspy elementii tokkoo ni balleessa.

Filannoowwan

Filannoon karaa amaloota deetaa ykn JaavaScript darbuu danda'u. Amaloota deetaatiif, maqaa filannoo gara data-, akkuma keessatti dabali data-offset="".

Maqaa Akaakuu Durtii dha Ibsa
ofseeti jechuun ni danda’ama lakkoofsa 10. Piikseelota yeroo iddoo tarree shallagdu gubbaa irraa ofseeti.
mala hidhaa auto Qaamni basaafame kutaa kam keessa autoakka jiru barbaada.mala hundarra gaarii ta'e ni filata qindeessoota qaxxaamuraa argadhu. offsetqindeessoota garagalchuu argachuuf mala ofseeti jQuery fayyadama. positionqindeessoota tarree argachuuf mala iddoo jQuery fayyadama.
xiyyeeffaanoo hidhaa Qaama ifteessa Scrollspy plugin hojii irra oolchuuf.

Taateewwan

Gosa Taatee Ibsa
hojii irra oolchuu.bs.scrollspy Taatee kun yeroo wanti haaraan scrollspy'n socho'u hunda elementii tarree irratti dhukaasa.
$('[data-spy="scroll"]').on('activate.bs.scrollspy', function () {
  // do something…
})