Scrollspy
The Bootstrap scrollspy component, implemented in Ruby. Use it like any other matestack component in your apps, pages and components. It offers customizable options to simply achieve what is possible in bootstrap with this component. See below for more information about the possible options.

bs_scrollspy(*args, &block)

use only when you want to apply the scrollspy behavior to a specific element on your UI (other than body)
Returns a div with applied bootstrap scrollspy data attributes and position: relative; containing content specified by a block. Also the scrollspy is customizable with the following options:
Required options
  • :height - Defines the height for the scrollable container, can be an Integer which will be interepreted as Xpx, or a custom String like "20em"
Optional options
  • :offset - Pixels to offset from top when calculating position of scroll, by default 10
  • :method - Finds which section the spied element is in. Be default is auto which will choose the best method to get scroll coordinates.
  • :target - Specifies element to apply Scrollspy plugin.
  • Html attributes - all w3c confirm html attributes for div's can be set via options and will be added to the surrounding scrollspy div.

Examples

Example 1: Scrollspy with list-group

1
bs_row class: "m-3" do
2
bs_col lg: 4 do
3
bs_list_group id: "list-example", class: "mb-5", actionable_items: true, items: [
4
{ type: :link, text: "Item 1", path: "#list-item1"},
5
{ type: :link, text: "Item 2", path: "#list-item2" }
6
]
7
end
8
bs_col lg: 8 do
9
bs_scrollspy target: "#list-example", offset: 0, height: 200 do
10
h2 "Item 1", id: "list-item1"
11
100.times do
12
paragraph "Text for item 1"
13
end
14
h2 "Item 2", id: "list-item2"
15
100.times do
16
paragraph "Text for item 2"
17
end
18
end
19
end
20
end
Copied!