packages/vuepress-docs/docs/en-US/plugins/indicators.md
The indicators provides the ability to link with another BetterScroll. With this, you can achieve effects such as Parallax Scrolling, Magnifier.
::: tip This is a very powerful and creative plugin. :::
npm install @better-scroll/indicators --save
// or
yarn add @better-scroll/indicators
First, install the plugin via the static method BScroll.use()
import BScroll from '@better-scroll/core'
import Indicators from '@better-scroll/indicators'
BScroll.use(Indicators)
pass correct indicators options.
new BScroll('.wrapper', {
indicators: {
// For details, please refer to the demo below
relationElement: someHTMLElement
}
})
Magnifier
<demo qrcode-url="indicators/minimap" :render-code="true"> <template slot="code-template"> <<< @/examples/vue/components/indicators/minimap.vue?template </template> <template slot="code-script"> <<< @/examples/vue/components/indicators/minimap.vue?script </template> <template slot="code-style"> <<< @/examples/vue/components/indicators/minimap.vue?style </template> <indicators-minimap slot="demo"></indicators-minimap> </demo>Parallax Scrolling
<demo qrcode-url="indicators/parallax-scroll"> <template slot="code-template"> <<< @/examples/vue/components/indicators/parallax-scroll.vue?template </template> <template slot="code-script"> <<< @/examples/vue/components/indicators/parallax-scroll.vue?script </template> <template slot="code-style"> <<< @/examples/vue/components/indicators/parallax-scroll.vue?style </template> <indicators-parallax-scroll slot="demo"></indicators-parallax-scroll> </demo>HTMLElementThe container element associated with another BetterScroll, just like the above demo, div.scroll-indicator is releationElement. releationElement must be passed in by the user and has child elements.
number0Specify the child element of releationElement as the manipulated element. For details, please refer to the above demo.
number | Ratio | undefinedundefinedtype Ratio = {
// Specify the ratio of the scroll distance of x
x: number
// Specify the ratio of the scroll distance of y
y: number
}
Specify the ratio of releationElement to the scrolling distance of BetterScroll. Usually,the plugin will automatically calculate the scroll ratio of the two, but you can also manually specify the ratio to achieve the effect of Parallax Scrolling. For details, please refer to the demo above.
boolean | undefinedundefinedDecide whether the relationElementHandleElementIndex of relationElement can interact. When it is set to false, it will not respond to touch / mouse events.