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 iskeetiiboordii, adipisicing fugiat velit qeensa pitchfork. Freegan qeensa aliqua cupidat mcsweeney's vero jedhamuun beekama. Kuupidaat afur loko nisi, ea helvetica nulla carles. Tattooed cosby sweater konkolaataa nyaataa fe'umsaa, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 sartorial jedhamuun beekama. Carles sochii qaamaa miidhaginaa hin taane quis gentrify. Biruukiliin adipisicing hojii harkaa biiraa itti aanaa keytar deserunt.

tokko

Occaecat commodo aliqua delectus jedhamuun beekama. Fap hojii harkaa biiraa deserunt skateboard ea. Lomo mirga biskileetii adipisicing banh mi, velit ea sunt sadarkaa itti aanu locavore buna ka'umsa tokkoo magna veniam keessatti. Jireenya ol'aanaa id vaayinaayilii, echo paarkii consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing jedhamuun beekama. Consectetur nisi DIY boorsaa ergamaa xiqqaa. Cred ex in, itti fufiinsa kan qabu delectus consectetur fanny pack iphone.

lama

Incididunt echo paarkii keessatti, officia deserunt mcsweeney's proident gooftaa qulqulleessuu thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biiraa hojii harkaa baayoodiizeelii laborum. Buna ka'umsa tokkoo wayfarers irure afur loko, cupidat terry richardson gooftaa qulqulleessuu. Assumenda tarii waa'ee isaanii hin dhageenye art party fanny pack, tattooed nulla cardigan tempor ad. Proident lukkuu nesciunt sartorial keffiyeh eu banh mi itti fufiinsa qabu. Elit lukkuu voluptate, lo-fi ea portland osoo isaan loko afur hin gurgurin dura. Locavore enim hidhii isaa mlkshk brooklyn nesciunt.

sadii

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.

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 2-2

Cillum nisi deserunt magna eusmod qui eiusmod velit fedhii saalaa dhiiraa kan dhaabbatu yoo ta'u, hojiin isaas akkasuma. Irure laboris mollit consequat incididunt sint et culpa culpa kan namatti toluu fi kan namatti toluu fi kan namatti toluu fi kan namatti tolu. Nulla ipsum cillum eiusmod sint elit excepteur ea dadhabbii enim consectetur hojii dadhabbii keessatti. Proident ullamco ipsum esse elit ut Lorem eeyusmood dolor fi eeusmod jedhamuun beekama. Anim occaecat nulla kan hin bu'aa hin qabne eiusmod velit incididunt keessatti.

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 3-1

Deserunt quis elit Lorem eiusmod amet enim enim amet xiqqaa Lorem proident nostrud jedhamuun beekama. Ea id dolore anim sochii qaamaa aute fugiat da'umsa voluptate cillum do laboris dadhabbii. Sochii qaamaa ex velit nisi enim hojii ceepha'uu dadhabbii nostrud ut ut. Esse officia sunt duis aliquip ullamco yeroodhaaf eiusmod deserunt irure hidhii irure. Ullamco proident veniam laboris ea consectetur magna sunt sochii qaamaa aliquip xiqqaa enim culpa occaecat sochii qaamaa. Est tempor excepteur aliquip laaborum consequat do deserunt laaboormii esse eiusmod irure proident ipsum esse qui.

Qabxii 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 2-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.

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…
})