123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <!DOCTYPE html>
- <html lang="en-US">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width,initial-scale=1">
- <title>Options | BetterScroll 2.0</title>
- <meta name="generator" content="VuePress 1.9.10">
- <link rel="shortcut icon" href="/docs/assets/bs.ico" type="images/x-icon">
- <script src="https://www.googletagmanager.com/gtag/js?id=G-7E85TW7P27"></script>
- <script type="text/javascript">
- window.dataLayer = window.dataLayer || [];
- function gtag(){dataLayer.push(arguments);}
- gtag('js', new Date());
- gtag('config', 'G-7E85TW7P27');
- </script>
- <meta name="description" content="Make Scroll Perfect">
-
- <link rel="preload" href="/docs/assets/css/0.styles.0cd93813.css" as="style"><link rel="preload" href="/docs/assets/js/app.c71b64d3.js" as="script"><link rel="preload" href="/docs/assets/js/5.d6412664.js" as="script"><link rel="preload" href="/docs/assets/js/4.4855b9ef.js" as="script"><link rel="preload" href="/docs/assets/js/3.481632b4.js" as="script"><link rel="preload" href="/docs/assets/js/79.025583e1.js" as="script"><link rel="preload" href="/docs/assets/js/7.518ccda7.js" as="script"><link rel="preload" href="/docs/assets/js/56.cd04bae9.js" as="script"><link rel="prefetch" href="/docs/assets/js/1.8644db92.js"><link rel="prefetch" href="/docs/assets/js/10.6f8c38eb.js"><link rel="prefetch" href="/docs/assets/js/100.ee08226e.js"><link rel="prefetch" href="/docs/assets/js/101.fd2f3d9f.js"><link rel="prefetch" href="/docs/assets/js/102.79d86e3d.js"><link rel="prefetch" href="/docs/assets/js/103.7a3ae3b5.js"><link rel="prefetch" href="/docs/assets/js/104.7be4589d.js"><link rel="prefetch" href="/docs/assets/js/105.75386d15.js"><link rel="prefetch" href="/docs/assets/js/106.a4a18e8d.js"><link rel="prefetch" href="/docs/assets/js/107.561ec2e2.js"><link rel="prefetch" href="/docs/assets/js/108.1c61689f.js"><link rel="prefetch" href="/docs/assets/js/109.da71a73e.js"><link rel="prefetch" href="/docs/assets/js/110.5e0fa2d1.js"><link rel="prefetch" href="/docs/assets/js/111.1e326dd1.js"><link rel="prefetch" href="/docs/assets/js/112.590ba317.js"><link rel="prefetch" href="/docs/assets/js/113.cf201ace.js"><link rel="prefetch" href="/docs/assets/js/114.6d895ce2.js"><link rel="prefetch" href="/docs/assets/js/115.572aee19.js"><link rel="prefetch" href="/docs/assets/js/116.754722a0.js"><link rel="prefetch" href="/docs/assets/js/117.15e4dab3.js"><link rel="prefetch" href="/docs/assets/js/118.721d68f8.js"><link rel="prefetch" href="/docs/assets/js/119.c5c28d96.js"><link rel="prefetch" href="/docs/assets/js/120.12cd2e0e.js"><link rel="prefetch" href="/docs/assets/js/121.e41f8100.js"><link rel="prefetch" href="/docs/assets/js/122.9ebe2f53.js"><link rel="prefetch" href="/docs/assets/js/123.f90c91f9.js"><link rel="prefetch" href="/docs/assets/js/13.b0c40cd7.js"><link rel="prefetch" href="/docs/assets/js/14.28bec126.js"><link rel="prefetch" href="/docs/assets/js/15.87b22af4.js"><link rel="prefetch" href="/docs/assets/js/16.c10e14e7.js"><link rel="prefetch" href="/docs/assets/js/17.5c921c77.js"><link rel="prefetch" href="/docs/assets/js/18.dc23b7e3.js"><link rel="prefetch" href="/docs/assets/js/19.a4034f95.js"><link rel="prefetch" href="/docs/assets/js/2.03f0f2c8.js"><link rel="prefetch" href="/docs/assets/js/20.8633fd45.js"><link rel="prefetch" href="/docs/assets/js/21.1fbf8d7e.js"><link rel="prefetch" href="/docs/assets/js/22.2888cfc5.js"><link rel="prefetch" href="/docs/assets/js/23.f951d302.js"><link rel="prefetch" href="/docs/assets/js/24.12842718.js"><link rel="prefetch" href="/docs/assets/js/25.5a5a3137.js"><link rel="prefetch" href="/docs/assets/js/26.88e81f0b.js"><link rel="prefetch" href="/docs/assets/js/27.152b8fda.js"><link rel="prefetch" href="/docs/assets/js/28.22550ea8.js"><link rel="prefetch" href="/docs/assets/js/29.f43fa807.js"><link rel="prefetch" href="/docs/assets/js/30.4ed38f67.js"><link rel="prefetch" href="/docs/assets/js/31.af4018f6.js"><link rel="prefetch" href="/docs/assets/js/32.930ee0b7.js"><link rel="prefetch" href="/docs/assets/js/33.c6a68c75.js"><link rel="prefetch" href="/docs/assets/js/34.6d10da1e.js"><link rel="prefetch" href="/docs/assets/js/35.11ba7b51.js"><link rel="prefetch" href="/docs/assets/js/36.8a54712b.js"><link rel="prefetch" href="/docs/assets/js/37.b26eb85d.js"><link rel="prefetch" href="/docs/assets/js/38.d6569a11.js"><link rel="prefetch" href="/docs/assets/js/39.1d22cfba.js"><link rel="prefetch" href="/docs/assets/js/40.577a94d7.js"><link rel="prefetch" href="/docs/assets/js/41.155e01e0.js"><link rel="prefetch" href="/docs/assets/js/42.3c26eaba.js"><link rel="prefetch" href="/docs/assets/js/43.d90991e2.js"><link rel="prefetch" href="/docs/assets/js/44.5437344c.js"><link rel="prefetch" href="/docs/assets/js/45.0d2eca0a.js"><link rel="prefetch" href="/docs/assets/js/46.11455b40.js"><link rel="prefetch" href="/docs/assets/js/47.1ee1a8f0.js"><link rel="prefetch" href="/docs/assets/js/48.c82450ab.js"><link rel="prefetch" href="/docs/assets/js/49.8016ee5f.js"><link rel="prefetch" href="/docs/assets/js/50.ab73e091.js"><link rel="prefetch" href="/docs/assets/js/51.bce6eb99.js"><link rel="prefetch" href="/docs/assets/js/52.c9b1992f.js"><link rel="prefetch" href="/docs/assets/js/53.7057f0f5.js"><link rel="prefetch" href="/docs/assets/js/54.cbb0a6b5.js"><link rel="prefetch" href="/docs/assets/js/55.89176a68.js"><link rel="prefetch" href="/docs/assets/js/57.c7a42e07.js"><link rel="prefetch" href="/docs/assets/js/58.09d6cb1b.js"><link rel="prefetch" href="/docs/assets/js/59.8445a09f.js"><link rel="prefetch" href="/docs/assets/js/6.5737c458.js"><link rel="prefetch" href="/docs/assets/js/60.86b1f417.js"><link rel="prefetch" href="/docs/assets/js/61.fa371ad1.js"><link rel="prefetch" href="/docs/assets/js/62.dbc75ddc.js"><link rel="prefetch" href="/docs/assets/js/63.a4465c93.js"><link rel="prefetch" href="/docs/assets/js/64.a39c3193.js"><link rel="prefetch" href="/docs/assets/js/65.a7275f82.js"><link rel="prefetch" href="/docs/assets/js/66.afd0af7d.js"><link rel="prefetch" href="/docs/assets/js/67.8009e00e.js"><link rel="prefetch" href="/docs/assets/js/68.de3c51dd.js"><link rel="prefetch" href="/docs/assets/js/69.41a50235.js"><link rel="prefetch" href="/docs/assets/js/70.938e9532.js"><link rel="prefetch" href="/docs/assets/js/71.af7fca59.js"><link rel="prefetch" href="/docs/assets/js/72.25df569a.js"><link rel="prefetch" href="/docs/assets/js/73.f16b7dc3.js"><link rel="prefetch" href="/docs/assets/js/74.d2184ed7.js"><link rel="prefetch" href="/docs/assets/js/75.9497b6fa.js"><link rel="prefetch" href="/docs/assets/js/76.2081d35e.js"><link rel="prefetch" href="/docs/assets/js/77.e5a8b470.js"><link rel="prefetch" href="/docs/assets/js/78.6d3ef23b.js"><link rel="prefetch" href="/docs/assets/js/8.8547d4ad.js"><link rel="prefetch" href="/docs/assets/js/80.e7e3ef35.js"><link rel="prefetch" href="/docs/assets/js/81.569d569f.js"><link rel="prefetch" href="/docs/assets/js/82.ac3ed0f7.js"><link rel="prefetch" href="/docs/assets/js/83.3393dfc3.js"><link rel="prefetch" href="/docs/assets/js/84.e5352ac1.js"><link rel="prefetch" href="/docs/assets/js/85.c7cdb129.js"><link rel="prefetch" href="/docs/assets/js/86.0aa0af94.js"><link rel="prefetch" href="/docs/assets/js/87.0db12b1e.js"><link rel="prefetch" href="/docs/assets/js/88.e8651cfa.js"><link rel="prefetch" href="/docs/assets/js/89.1b58abde.js"><link rel="prefetch" href="/docs/assets/js/9.0a882dfc.js"><link rel="prefetch" href="/docs/assets/js/90.d65d2d13.js"><link rel="prefetch" href="/docs/assets/js/91.32b2ad41.js"><link rel="prefetch" href="/docs/assets/js/92.795675a1.js"><link rel="prefetch" href="/docs/assets/js/93.818e5569.js"><link rel="prefetch" href="/docs/assets/js/94.79c2b16e.js"><link rel="prefetch" href="/docs/assets/js/95.4810ee5e.js"><link rel="prefetch" href="/docs/assets/js/96.6e382fd5.js"><link rel="prefetch" href="/docs/assets/js/97.e270d7b5.js"><link rel="prefetch" href="/docs/assets/js/98.728ef6c2.js"><link rel="prefetch" href="/docs/assets/js/99.c75096e0.js"><link rel="prefetch" href="/docs/assets/js/vendors~docsearch.2091e099.js">
- <link rel="stylesheet" href="/docs/assets/css/0.styles.0cd93813.css">
- </head>
- <body>
- <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/en-US/" class="home-link router-link-active"><img src="https://dpubstatic.udache.com/static/dpubimg/t_L6vAgQ-E/logo.svg" alt="BetterScroll 2.0" class="logo"> <span class="site-name can-hide">BetterScroll 2.0</span></a> <div class="links"><form id="search-form" role="search" class="algolia-search-wrapper search-box"><input id="algolia-search-input" class="search-query"></form> <nav class="nav-links can-hide"><div class="nav-item"><a href="/docs/en-US/guide/" class="nav-link router-link-active">
- Guide
- </a></div><div class="nav-item"><a href="/docs/en-US/plugins/" class="nav-link">
- Plugin
- </a></div><div class="nav-item"><a href="/docs/en-US/FAQ/" class="nav-link">
- FAQ
- </a></div><div class="nav-item"><a href="https://github.com/ustbhuangyi/better-scroll/issues" target="_blank" rel="noopener noreferrer" class="nav-link external">
- Discuss
- <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Select language" class="dropdown-title"><span class="title">Languages</span> <span class="arrow down"></span></button> <button type="button" aria-label="Select language" class="mobile-dropdown-title"><span class="title">Languages</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/docs/en-US/guide/base-scroll-options.html" aria-current="page" class="nav-link router-link-exact-active router-link-active">
- English
- </a></li><li class="dropdown-item"><!----> <a href="/docs/zh-CN/guide/base-scroll-options.html" class="nav-link">
- 简体中文
- </a></li></ul></div></div> <a href="https://github.com/ustbhuangyi/better-scroll" target="_blank" rel="noopener noreferrer" class="repo-link">
- GitHub
- <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/docs/en-US/guide/" class="nav-link router-link-active">
- Guide
- </a></div><div class="nav-item"><a href="/docs/en-US/plugins/" class="nav-link">
- Plugin
- </a></div><div class="nav-item"><a href="/docs/en-US/FAQ/" class="nav-link">
- FAQ
- </a></div><div class="nav-item"><a href="https://github.com/ustbhuangyi/better-scroll/issues" target="_blank" rel="noopener noreferrer" class="nav-link external">
- Discuss
- <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Select language" class="dropdown-title"><span class="title">Languages</span> <span class="arrow down"></span></button> <button type="button" aria-label="Select language" class="mobile-dropdown-title"><span class="title">Languages</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/docs/en-US/guide/base-scroll-options.html" aria-current="page" class="nav-link router-link-exact-active router-link-active">
- English
- </a></li><li class="dropdown-item"><!----> <a href="/docs/zh-CN/guide/base-scroll-options.html" class="nav-link">
- 简体中文
- </a></li></ul></div></div> <a href="https://github.com/ustbhuangyi/better-scroll" target="_blank" rel="noopener noreferrer" class="repo-link">
- GitHub
- <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Guide</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/en-US/guide/" aria-current="page" class="sidebar-link">Introduction</a></li><li><a href="/docs/en-US/guide/how-to-install.html" class="sidebar-link">Install</a></li><li><a href="/docs/en-US/guide/use.html" class="sidebar-link">How to use</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Base Scroll</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/en-US/guide/base-scroll.html" class="sidebar-link">base-scroll</a></li><li><a href="/docs/en-US/guide/base-scroll-options.html" aria-current="page" class="active sidebar-link">Options</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#startx" class="sidebar-link">startX</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#starty" class="sidebar-link">startY</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#scrollx" class="sidebar-link">scrollX</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#scrolly" class="sidebar-link">scrollY</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#freescroll" class="sidebar-link">freeScroll</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#directionlockthreshold" class="sidebar-link">directionLockThreshold</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#eventpassthrough" class="sidebar-link">eventPassthrough</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#click" class="sidebar-link">click</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#dblclick" class="sidebar-link">dblclick</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#tap" class="sidebar-link">tap</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#bounce" class="sidebar-link">bounce</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#bouncetime" class="sidebar-link">bounceTime</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#momentum" class="sidebar-link">momentum</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#momentumlimittime" class="sidebar-link">momentumLimitTime</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#momentumlimitdistance" class="sidebar-link">momentumLimitDistance</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#swipetime" class="sidebar-link">swipeTime</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#swipebouncetime" class="sidebar-link">swipeBounceTime</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#deceleration" class="sidebar-link">deceleration</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#flicklimittime" class="sidebar-link">flickLimitTime</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#flicklimitdistance" class="sidebar-link">flickLimitDistance</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#resizepolling" class="sidebar-link">resizePolling</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#probetype" class="sidebar-link">probeType</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#preventdefault" class="sidebar-link">preventDefault</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#preventdefaultexception" class="sidebar-link">preventDefaultException</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#tagexception" class="sidebar-link">tagException</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#hwcompositing" class="sidebar-link">HWCompositing</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#usetransition" class="sidebar-link">useTransition</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#bindtowrapper" class="sidebar-link">bindToWrapper</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#disablemouse" class="sidebar-link">disableMouse</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#disabletouch" class="sidebar-link">disableTouch</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#autoblur" class="sidebar-link">autoBlur</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#stoppropagation" class="sidebar-link">stopPropagation</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#bindtotarget" class="sidebar-link">bindToTarget</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#autoenddistance" class="sidebar-link">autoEndDistance</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#outofboundarydampingfactor" class="sidebar-link">outOfBoundaryDampingFactor</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#specifiedindexascontent" class="sidebar-link">specifiedIndexAsContent</a></li><li class="sidebar-sub-header"><a href="/docs/en-US/guide/base-scroll-options.html#quadrant" class="sidebar-link">quadrant</a></li></ul></li><li><a href="/docs/en-US/guide/base-scroll-api.html" class="sidebar-link">API</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="options"><a href="#options" class="header-anchor">#</a> Options</h1> <p>BetterScroll supports rich options configuration, you can pass them in the second parameter when initializing, for example:</p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token keyword">import</span> BScroll <span class="token keyword">from</span> <span class="token string">'@better-scroll/core'</span>
- <span class="token keyword">let</span> scroll <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">BScroll</span><span class="token punctuation">(</span><span class="token string">'.wrapper'</span><span class="token punctuation">,</span><span class="token punctuation">{</span>
- <span class="token literal-property property">scrollY</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
- <span class="token literal-property property">click</span><span class="token operator">:</span> <span class="token boolean">true</span>
- <span class="token punctuation">}</span><span class="token punctuation">)</span>
- </code></pre></div><p>This implements a list of vertical clickable scrolling effects. so let's list the parameters supported by BetterScroll.</p> <h2 id="startx"><a href="#startx" class="header-anchor">#</a> startX</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>0</code></li> <li><strong>Details</strong>: Initialize the postion in the horizontal axis direction.</li></ul> <h2 id="starty"><a href="#starty" class="header-anchor">#</a> startY</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>0</code></li> <li><strong>Details</strong>: Initialize the postion in the vertical axis direction.</li></ul> <h2 id="scrollx"><a href="#scrollx" class="header-anchor">#</a> scrollX</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: <code>false</code></li> <li><strong>Usage</strong>: When set to true, horizontal scrolling would be enabled</li> <li><strong>Note</strong>: This configuration is invalid when setting <a href="/docs/en-US/guide/base-scroll-options.html#eventpassthrough">eventPassthrough</a> to 'horizontal'.</li></ul> <h2 id="scrolly"><a href="#scrolly" class="header-anchor">#</a> scrollY</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: <code>true</code></li> <li><strong>Usage</strong>: When set to true, vertical scrolling would be enabled</li> <li><strong>Note</strong>: This configuration is invalid when setting <a href="/docs/en-US/guide/base-scroll-options.html#eventpassthrough">eventPassthrough</a> to 'vertical'.</li></ul> <h2 id="freescroll"><a href="#freescroll" class="header-anchor">#</a> freeScroll</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: <code>false</code></li> <li><strong>Usage</strong>: By default, because human fingers cannot perform absolute vertical or horizontal movement, there will be horizontal and vertical offsets during a finger operation. The internal default will abandon the smaller offset direction , Keep scrolling in the other direction. But in some scenes, we need to calculate the horizontal and vertical finger offset distances at the same time, instead of only calculating the direction with a larger offset. At this time, we only need to set <code>freeScroll</code> to true.</li> <li><strong>Note</strong>: This configuration is invalid when <a href="/docs/en-US/guide/base-scroll-options.html#eventpassthrough">eventPassthrough</a> isn't set to empty.</li> <li><strong>Examples</strong></li></ul> <div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">// finger startpoint -> e1: { pageX: 120, pageY: 120 }</span>
- <span class="token comment">// finger endpoint -> e2: { pageX: 121, pageY: 140 }</span>
- <span class="token comment">// offsetX: e2.pageX - e1.pageX = 1</span>
- <span class="token comment">// offsetY: e2.pageY - e1.pageY = 20</span>
- <span class="token comment">// if freeScroll is false, due to offsetY > offsetX + directionLockThreshold</span>
- <span class="token comment">// offsetX is fixed to be 0, only calculate offsetY, thus do a vertical scroll!</span>
- </code></pre></div><h2 id="directionlockthreshold"><a href="#directionlockthreshold" class="header-anchor">#</a> directionLockThreshold</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>5</code></li> <li><strong>Usage</strong>: when <code>freeScroll</code> is false, we need to lock the scrolling only in one direction, we calculate the numerical difference between the absolute values of horizontal axis and vertical axis' scrolling distance at the initialization time of scrolling. When the value of the numerical difference is greater than <code>directionLockThreshold</code>, the lock direction can be determined.</li> <li><strong>Note</strong>: If <a href="/docs/en-US/guide/base-scroll-options.html#eventpassthrough">eventPassthrough</a> is set, <code>directionLockThreshold</code> is invalid and will always be 0.</li></ul> <h2 id="eventpassthrough"><a href="#eventpassthrough" class="header-anchor">#</a> eventPassthrough</h2> <ul><li><strong>Type</strong>: <code>string</code></li> <li><strong>Default</strong>: <code>''</code></li> <li>Optional value: <code>vertical | horizontal</code></li> <li><strong>Usage</strong>: Sometimes we want to preserve native vertical scroll but being able to add an horizontal BetterScroll (maybe a carousel). Set this to 'vertical' and the BetterScroll area will react to horizontal swipes only. Vertical swipes will naturally scroll the whole page. Contrarily, set this to 'horizontal' when you want to keep natural horizontal scroll.</li> <li><strong>Note</strong>: The setting of <code>eventPassthrough</code> will cause some other settings to be invalid, be careful when using it.</li></ul> <h2 id="click"><a href="#click" class="header-anchor">#</a> click</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: <code>false</code></li> <li><strong>Usage</strong>: To override the native scrolling BetterScroll has to inhibit some default browser behaviors, such as mouse clicks. If you want your application to respond to the click event you have to explicitly set this option to <code>true</code>. And then BetterScroll will add a private attribute called <code>_constructed</code> to the dispatched event whose value is true.</li></ul> <h2 id="dblclick"><a href="#dblclick" class="header-anchor">#</a> dblclick</h2> <ul><li><strong>Type</strong>: <code>boolean | Object</code></li> <li><strong>Default</strong>: <code>false</code></li> <li><strong>Usage</strong>: Send dblclick event. When configured to true, by default the two times click delay is 300 ms. If configured to an object, the <code>delay</code> can be modified.</li></ul> <div class="language-js extra-class"><pre class="language-js"><code> <span class="token literal-property property">dblclick</span><span class="token operator">:</span> <span class="token punctuation">{</span>
- <span class="token literal-property property">delay</span><span class="token operator">:</span> <span class="token number">300</span>
- <span class="token punctuation">}</span>
- </code></pre></div><h2 id="tap"><a href="#tap" class="header-anchor">#</a> tap</h2> <ul><li><strong>Type</strong>: <code>string</code></li> <li><strong>Default</strong>: <code>''</code></li> <li><strong>Details</strong>: Since BetterScroll will block the native click event, we can set tap to 'tap', which will dispatch a tap event when the region is clicked. You can listen to it as if it were listening to native events.</li></ul> <h2 id="bounce"><a href="#bounce" class="header-anchor">#</a> bounce</h2> <ul><li><strong>Type</strong>: <code>boolean | Object</code></li> <li><strong>Default</strong>: <code>true</code></li> <li><strong>Details</strong>: When the content element meets the boundary it performs a small bounce animation. Setting this to true will enable the animation.</li></ul> <div class="language-js extra-class"><pre class="language-js"><code> <span class="token literal-property property">bounce</span><span class="token operator">:</span> <span class="token punctuation">{</span>
- <span class="token literal-property property">top</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
- <span class="token literal-property property">bottom</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
- <span class="token literal-property property">left</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
- <span class="token literal-property property">right</span><span class="token operator">:</span> <span class="token boolean">true</span>
- <span class="token punctuation">}</span>
- </code></pre></div><p><code>bounce</code> can support the effect of closing the back of some edges. You can set the <code>key</code> of the corresponding side to <code>false</code>.</p> <div class="custom-block tip"><p class="custom-block-title">TIP</p> <p>If you want to conveniently set all edges to <strong>true</strong> or <strong>false</strong>, you only need to set <code>bounce</code> to <strong>true</strong> or <strong>false</strong>.</p></div> <h2 id="bouncetime"><a href="#bouncetime" class="header-anchor">#</a> bounceTime</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: Default: <code>800</code> (ms, modification is not recommended)</li> <li><strong>Details</strong>: Set the duration in millisecond of the bounce animation.</li></ul> <h2 id="momentum"><a href="#momentum" class="header-anchor">#</a> momentum</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: <code>true</code></li> <li><strong>Usage</strong>: If setted to true, you can turn on the momentum animation when the user quickly flicks on screen.</li></ul> <h2 id="momentumlimittime"><a href="#momentumlimittime" class="header-anchor">#</a> momentumLimitTime</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>300</code> (ms)</li> <li><strong>Usage</strong>: Only when the time of the user's flicking on screen is lower than <code>momentumLimitTime</code> resulting in the momentum animation.</li></ul> <h2 id="momentumlimitdistance"><a href="#momentumlimitdistance" class="header-anchor">#</a> momentumLimitDistance</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>15</code> (px)</li> <li><strong>Usage</strong>: Only when the distance of the user's flicking on screen is greater than <code>momentumLimitTime</code> resulting in the momentum animation.</li></ul> <h2 id="swipetime"><a href="#swipetime" class="header-anchor">#</a> swipeTime</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>2500</code> (ms)</li> <li><strong>Usage</strong>: Set the duration in millisecond of the momentum animation.</li></ul> <h2 id="swipebouncetime"><a href="#swipebouncetime" class="header-anchor">#</a> swipeBounceTime</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>500</code> (ms)</li> <li><strong>Usage</strong>: Set the entire bounce animation time when the content element meets the boundary in the case of running a momentum animation.</li></ul> <h2 id="deceleration"><a href="#deceleration" class="header-anchor">#</a> deceleration</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>0.0015</code></li> <li><strong>Usage</strong>: Represent the deceleration of the momentum animation.</li></ul> <h2 id="flicklimittime"><a href="#flicklimittime" class="header-anchor">#</a> flickLimitTime</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>200</code></li> <li><strong>Usage</strong>: Sometimes we want to cpture the user's flick action (slide a short distance in a short time). Only when the time of the user slide on screen is shorter than <code>flickLimitTime</code>, it is considered as a flick action.</li></ul> <h2 id="flicklimitdistance"><a href="#flicklimitdistance" class="header-anchor">#</a> flickLimitDistance</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>100</code></li> <li><strong>Usage</strong>: Only when the distance of the user slide on screen is shorter than <code>flickLimitDistance</code>, it is considered as a flick action</li></ul> <h2 id="resizepolling"><a href="#resizepolling" class="header-anchor">#</a> resizePolling</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>60</code> (ms)</li> <li><strong>Usage</strong>: When you resize the window BetterScroll has to recalculate elements position and dimension. This might be a pretty daunting task for the poor little fella. To give it some rest the polling is set to 60 milliseconds and it is reasonable value.</li></ul> <h2 id="probetype"><a href="#probetype" class="header-anchor">#</a> probeType</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>0</code></li> <li><strong>Optional Value</strong>: <code>1 | 2 | 3</code></li> <li><strong>Usage</strong>: Deciding whether to dispatch the scroll event, this has an impact on the performance of the page, especially in the mode where <code>useTransition</code> is true.</li></ul> <div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">// There are two scenarios for dispatching scroll:</span>
- <span class="token comment">// 1. The finger acts on the scrolling area (content DOM),</span>
- <span class="token comment">// 2. Invoke the scrollTo method or trigger the momentum scroll animation (in fact, the implementation is still Invoking the scrollTo method)</span>
- <span class="token comment">// For the v2.1.0, the probeType has been unified</span>
- <span class="token comment">// The probeType is:</span>
- <span class="token comment">// 0, scroll event will not be dispatched at any time,</span>
- <span class="token comment">// 1, and only when the finger is moving on the scroll area, a scroll event is dispatched every momentumLimitTime milliseconds.</span>
- <span class="token comment">// 2, and only when the finger is moving on the scroll area, a scroll event is dispatched all the time.</span>
- <span class="token comment">// 3, scroll events are dispatched at any time, including invoking scrollTo or triggering momentum</span>
- </code></pre></div><h2 id="preventdefault"><a href="#preventdefault" class="header-anchor">#</a> preventDefault</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: <code>true</code></li> <li><strong>Usage</strong>: Whether or not to <code>preventDefault()</code> when events are fired. This should be left <code>true</code> unless you really know what you are doing.</li></ul> <h2 id="preventdefaultexception"><a href="#preventdefaultexception" class="header-anchor">#</a> preventDefaultException</h2> <ul><li><strong>Type</strong>: Object</li> <li><strong>Default</strong>: <code>{ tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT|AUDIO)$/ }</code></li> <li><strong>Usage</strong>: BetterScroll will inhibit the native scrolling and meanwhile inhibit some native components' default behaviours. In this situation, we can't 'preventDefault' on these elements, so we can configure 'preventDefaultException'. Default <code>{tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT|AUDIO)$/}</code> represents that default behaviours of elements with tagnames like 'input', 'textarea', 'button', 'select', 'audio' will not be inhibited</li> <li><strong>Note</strong>: This is a pretty powerful option. Its key is the attribute value of DOM elements, the corresponding value can be a regular expression. For example, if we want to configure the element whose class name is 'test', then the configuration is <code>{className:/(^|\s)test(\s|$)/}</code>.</li></ul> <h2 id="tagexception"><a href="#tagexception" class="header-anchor">#</a> tagException</h2> <ul><li><strong>Type</strong>: <code>Object</code></li> <li><strong>Default</strong>: <code>{ tagName: /^TEXTAREA$/ }</code></li> <li><strong>Usage</strong>: If BetterScroll nests form elements such as <code>textarea</code>, the user's expectation should be that sliding textarea should not cause bs scrolling. If the manipulated DOM (eg:textarea tag) hits the configured rule, <code>bs</code> won't scroll.</li> <li><strong>Note</strong>: This is a pretty powerful option. Its key is the attribute value of DOM elements, the corresponding value can be a regular expression. For example, if we want to configure the element whose class name is 'test', then the configuration is <code>{className:/(^|\s)test(\s|$)/}</code>.</li></ul> <h2 id="hwcompositing"><a href="#hwcompositing" class="header-anchor">#</a> HWCompositing</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: <code>true</code></li> <li><strong>Usage</strong>: This option tries to put the content element on the hardware layer by appending <code>translateZ(1px)</code> to the transform CSS property. This greatly increases performance especially on mobile and achieve a good scrolling effect.</li> <li><strong>Note</strong>: Only browsers that support enabling hardware acceleration has the effect.</li></ul> <h2 id="usetransition"><a href="#usetransition" class="header-anchor">#</a> useTransition</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: <code>true</code></li> <li><strong>Usage</strong>: Whether to use CSS3 transition animation. If setted to false, the engine will use <code>requestAnimationFrame</code> to do animation.</li></ul> <h2 id="bindtowrapper"><a href="#bindtowrapper" class="header-anchor">#</a> bindToWrapper</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: <code>false</code></li> <li><strong>Usage</strong>: The <code>touchmove</code> event is normally bound to the document and not the scroll wrapper. When you move the cursor out of the wrapper the scrolling keeps going(only works in PC). This is usually what you want, but you can also bind the move event to wrapper itself. Doing so as soon as the cursor leaves the wrapper the scroll stops.</li> <li><strong>Note</strong>: For the mobile, even if the touchmove event is bound to the wrapper, the wrapper can still be moved if the finger leaves the wrapper.</li></ul> <h2 id="disablemouse"><a href="#disablemouse" class="header-anchor">#</a> disableMouse</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: get the result by current browser environment</li> <li><strong>Usage</strong>: When in mobile environment (supporting touch event), disableMouse will be <code>true</code> and mouse event will not be listened. While in PC environment, disableMouse will be <code>false</code> and mouse event will be listened.</li></ul> <h2 id="disabletouch"><a href="#disabletouch" class="header-anchor">#</a> disableTouch</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: get the result by current browser environment</li> <li><strong>Usage</strong>: When in mobile environment (supporting touch event), <code>disableTouch</code> will be <code>false</code> and touch event will be listened. While in PC environment, <code>disableMouse</code> will be <code>true</code> and touch event will not be listened. We suggest not modifying this unless you konw what you are doing.</li></ul> <div class="custom-block warning"><p class="custom-block-title">WARNING</p> <p>Considering some specific scenarios of the user, such as <strong>the tablet needs to support the touch event, the tablet with mouse has to support the mouse event</strong>, In other words, if you need to listen to the touch and mouse events at the same time, then the instantiation of BetterScroll needs to be configured as follows:</p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token keyword">let</span> bs <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">BScroll</span><span class="token punctuation">(</span><span class="token string">'.wrapper'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
- <span class="token literal-property property">disableMouse</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
- <span class="token literal-property property">disableTouch</span><span class="token operator">:</span> <span class="token boolean">false</span>
- <span class="token punctuation">}</span><span class="token punctuation">)</span>
- </code></pre></div><p>Due to the different bottom-level implementation logic of different devices and different browser environments, BetterScroll's internal calculations of whether to listen to <code>touch</code> or <code>mouse</code> events may make wrong judgment, so you can solve this type of problem according to the above option configuration.</p></div> <h2 id="autoblur"><a href="#autoblur" class="header-anchor">#</a> autoBlur</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: <code>true</code></li> <li><strong>Usage</strong>: It will auto blur the active element(input、textarea) before scroll start.</li></ul> <h2 id="stoppropagation"><a href="#stoppropagation" class="header-anchor">#</a> stopPropagation</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: <code>false</code></li> <li><strong>Usage</strong>: Whether stop event propagation. It is often used in nested scroll scenes.</li></ul> <h2 id="bindtotarget"><a href="#bindtotarget" class="header-anchor">#</a> bindToTarget</h2> <ul><li><strong>Type</strong>: <code>boolean</code></li> <li><strong>Default</strong>: <code>false</code></li> <li><strong>Usage</strong>: Bind touch or mouse events to the <code>content</code> element instead of the container <code>wrapper</code>, which is mostly used in <a href="/docs/en-US/plugins/movable.html">movable</a>.</li></ul> <h2 id="autoenddistance"><a href="#autoenddistance" class="header-anchor">#</a> autoEndDistance</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>5</code></li> <li><strong>Usage</strong>: When the finger operation is crazy, the <code>touchend</code> event may not be triggered when sliding out of the viewport, so the function of autoEndDistance is to automatically call the touchend event when the finger is about to leave the current viewport. When the default distance is 5px from the boundary, the scrolling ends.</li></ul> <h2 id="outofboundarydampingfactor"><a href="#outofboundarydampingfactor" class="header-anchor">#</a> outOfBoundaryDampingFactor</h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>1 / 3</code></li> <li><strong>Usage</strong>: When out of boundary, the damping behavior is performed. The smaller the damping factor, the greater the resistance. Value range: [0, 1].</li></ul> <h2 id="specifiedindexascontent"><a href="#specifiedindexascontent" class="header-anchor">#</a> specifiedIndexAsContent <span class="badge tip" style="vertical-align:top;" data-v-15b7b770>2.0.4</span></h2> <ul><li><strong>Type</strong>: <code>number</code></li> <li><strong>Default</strong>: <code>0</code></li> <li><strong>Usage</strong>: Specify the child element corresponding to the index of the <code>wrapper</code> as the <code>content</code>. By default, BetterScroll uses the first child element of the <code>wrapper</code> as the content.</li></ul> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>wrapper<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>content1<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>conten1-item<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>1.1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>conten1-item<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>1.2<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>content2<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>conten2-item<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>2.1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>conten2-item<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>2.2<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- </code></pre></div><div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">// For the above DOM structure, when BetterScroll version <= 2.0.3, only div.content1 is used as content</span>
- <span class="token comment">// When the version is >= 2.0.4, content can be specified through 'specifiedIndexAsContent'</span>
- <span class="token keyword">let</span> bs <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">BScroll</span><span class="token punctuation">(</span><span class="token string">'.wrapper'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
- <span class="token literal-property property">specifiedIndexAsContent</span><span class="token operator">:</span> <span class="token number">1</span> <span class="token comment">// use div.content2 as BetterScroll's content</span>
- <span class="token punctuation">}</span><span class="token punctuation">)</span>
- </code></pre></div><h2 id="quadrant"><a href="#quadrant" class="header-anchor">#</a> quadrant <span class="badge tip" style="vertical-align:top;" data-v-15b7b770>2.3.0</span></h2> <ul><li><strong>Type</strong>: <code>1 | 2 | 3 | 4</code></li> <li><strong>Default</strong>: <code>1</code></li> <li><strong>Usage</strong>: When the ancestor elements of BetterScroll's wrapper DOM are forced to rotate by CSS, the original displacements in the x and y directions need to perform a certain transformation to ensure a reasonable interaction.</li></ul> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>style</span><span class="token punctuation">></span></span><span class="token style"><span class="token language-css">
- <span class="token comment">/* wrapper's parent DOM rotated*/</span>
- <span class="token selector">.container</span> <span class="token punctuation">{</span>
- <span class="token property">transform</span><span class="token punctuation">:</span> <span class="token function">rotate</span><span class="token punctuation">(</span>90deg<span class="token punctuation">)</span><span class="token punctuation">;</span>
- <span class="token punctuation">}</span>
- </span></span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>style</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>container<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>wrapper<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>content<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>content-item<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>1.1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>content-item<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>1.2<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- </code></pre></div><div class="language-js extra-class"><pre class="language-js"><code><span class="token keyword">let</span> bs <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">BScroll</span><span class="token punctuation">(</span><span class="token string">'.wrapper'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
- <span class="token literal-property property">quadrant</span><span class="token operator">:</span> <span class="token number">2</span>
- <span class="token punctuation">}</span><span class="token punctuation">)</span>
- </code></pre></div><ol><li>When the rotation angle of the parent element or ancestor element of the <code>wrapper</code> is (315, 45], the quadrant can keep the default value;</li> <li>When the rotation angle of the parent element or ancestor element of the <code>wrapper</code> is (45, 135],Especially <strong>90 degrees</strong>, the quadrant <strong>must</strong> be <code>2</code>;</li> <li>When the rotation angle of the parent element or ancestor element of the <code>wrapper</code> is (135, 225],Especially <strong>180 degrees</strong>, the quadrant <strong>must</strong> be <code>3</code>;</li> <li>When the rotation angle of the parent element or ancestor element of the <code>wrapper</code> is (225, 315],Especially <strong>270 degrees</strong>, the quadrant <strong>must</strong> be <code>4</code>;</li> <li>When the rotation angle is special, such as 30 degrees or 200 degrees, you may not be satisfied with the built-in transformation logic. You can customize your own transformation logic through the <code>coordinateTransformation</code> hook.</li></ol> <div class="language-js extra-class"><pre class="language-js"><code><span class="token keyword">let</span> bs <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">BScroll</span><span class="token punctuation">(</span><span class="token string">'.wrapper'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
- <span class="token literal-property property">quadrant</span><span class="token operator">:</span> <span class="token number">1</span> <span class="token comment">// default value</span>
- <span class="token punctuation">}</span><span class="token punctuation">)</span>
- bs<span class="token punctuation">.</span>scroller<span class="token punctuation">.</span>actions<span class="token punctuation">.</span>hooks<span class="token punctuation">.</span><span class="token function">on</span><span class="token punctuation">(</span>
- bs<span class="token punctuation">.</span>scroller<span class="token punctuation">.</span>actions<span class="token punctuation">.</span>hooks<span class="token punctuation">.</span>eventTypes<span class="token punctuation">.</span>coordinateTransformation<span class="token punctuation">,</span>
- <span class="token punctuation">(</span><span class="token parameter">transformateDeltaData</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
- <span class="token comment">// get user finger moved distance</span>
- <span class="token keyword">const</span> originDeltaX <span class="token operator">=</span> transformateDeltaData<span class="token punctuation">.</span>deltaX
- <span class="token keyword">const</span> originDeltaY <span class="token operator">=</span> transformateDeltaData<span class="token punctuation">.</span>deltaY
- <span class="token comment">// apply transformation</span>
- transformateDeltaData<span class="token punctuation">.</span>deltaX <span class="token operator">=</span> originDeltaY
- transformateDeltaData<span class="token punctuation">.</span>deltaY <span class="token operator">=</span> originDeltaX
- <span class="token comment">// transformateDeltaData.deltaX will be used as content DOM style's translateX</span>
- <span class="token comment">// transformateDeltaData.deltaY will be used as content DOM style's translateY</span>
- <span class="token punctuation">}</span>
- <span class="token punctuation">)</span>
- </code></pre></div><p>For example: Use CSS to flip the horizontal scrolling BetterScroll.</p> <div class="demo-wrap"><div class="demo-nav"><i class="demo-nav-btn icon-code"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="#666"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"></path></svg></i> <div class="v-popover"><div class="trigger" style="display:inline-block;"><i class="demo-nav-btn icon-qrcode"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="#666"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M16 20h4M4 12h4m12 0h.01M5 8h2a1 1 0 001-1V5a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1zm12 0h2a1 1 0 001-1V5a1 1 0 00-1-1h-2a1 1 0 00-1 1v2a1 1 0 001 1zM5 20h2a1 1 0 001-1v-2a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1z"></path></svg></i> </div> <div id="popover_21fmsl5y0u" aria-hidden="true" tabindex="0" class="tooltip popover vue-popover-theme" style="visibility:hidden;"><div class="wrapper"><div class="tooltip-inner popover-inner" style="position:relative;"><div><div></div></div> <div tabindex="-1" class="resize-observer" data-v-8859cc6c></div></div> <div class="tooltip-arrow popover-arrow"></div></div></div></div> <i class="demo-nav-btn icon-preview"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="#666"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path></svg></i></div> <div class="demo-code" style="display:none;"><div class="demo-code-nav"><button class="demo-code-btn active">Template</button><button class="demo-code-btn">Script</button><button class="demo-code-btn">Style</button></div> <div class="demo-code-content"><div class="demo-code-item" style="display:;"><div class="language-vue extra-class"><pre class="language-vue"><code><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>template</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>horizontal-rotated-container<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>description<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Flipping layout via CSS<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>scroll-wrapper<span class="token punctuation">"</span></span> <span class="token attr-name">ref</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>scroll<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>scroll-content<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>scroll-item<span class="token punctuation">"</span></span> <span class="token attr-name">v-for</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>num in nums<span class="token punctuation">"</span></span> <span class="token attr-name">:key</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>num<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>{{num}}<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>template</span><span class="token punctuation">></span></span></code></pre></div></div><div class="demo-code-item" style="display:none;"><div class="language-vue extra-class"><pre class="language-vue"><code><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>script</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>text/ecmascript-6<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"><span class="token language-javascript">
- <span class="token keyword">import</span> BScroll <span class="token keyword">from</span> <span class="token string">'@better-scroll/core'</span>
- <span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
- <span class="token function">data</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
- <span class="token keyword">return</span> <span class="token punctuation">{</span>
- <span class="token literal-property property">nums</span><span class="token operator">:</span> <span class="token number">8</span>
- <span class="token punctuation">}</span>
- <span class="token punctuation">}</span><span class="token punctuation">,</span>
- <span class="token function">mounted</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
- <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">init</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
- <span class="token punctuation">}</span><span class="token punctuation">,</span>
- <span class="token function">beforeDestroy</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
- <span class="token keyword">this</span><span class="token punctuation">.</span>bs<span class="token punctuation">.</span><span class="token function">destroy</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
- <span class="token punctuation">}</span><span class="token punctuation">,</span>
- <span class="token literal-property property">methods</span><span class="token operator">:</span> <span class="token punctuation">{</span>
- <span class="token function">init</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
- <span class="token keyword">this</span><span class="token punctuation">.</span>bs <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">BScroll</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>$refs<span class="token punctuation">.</span>scroll<span class="token punctuation">,</span> <span class="token punctuation">{</span>
- <span class="token literal-property property">scrollX</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
- <span class="token literal-property property">scrollY</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
- <span class="token comment">// v2.3.0</span>
- <span class="token literal-property property">quadrant</span><span class="token operator">:</span> <span class="token number">3</span> <span class="token comment">// rotate180</span>
- <span class="token punctuation">}</span><span class="token punctuation">)</span>
- <span class="token punctuation">}</span>
- <span class="token punctuation">}</span>
- <span class="token punctuation">}</span>
- </span></span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>script</span><span class="token punctuation">></span></span></code></pre></div></div><div class="demo-code-item" style="display:none;"><div class="language-styl extra-class"><pre class="language-styl"><code><style lang=<span class="token string">"stylus"</span> rel=<span class="token string">"stylesheet/stylus"</span> scoped>
- <span class="token selector"><span class="token comment">/* flipping by CSS */</span>
- .scroll-wrapper</span>
- <span class="token property-declaration"><span class="token property">transform</span> <span class="token func"><span class="token function">rotate</span><span class="token punctuation">(</span><span class="token number">180</span><span class="token unit">deg</span><span class="token punctuation">)</span></span></span>
- <span class="token selector">.horizontal-rotated-container</span>
- <span class="token selector">.description</span>
- <span class="token property-declaration"><span class="token property">margin-bottom</span> <span class="token number">40</span><span class="token unit">px</span></span>
- <span class="token property-declaration"><span class="token property">text-align</span> center</span>
- <span class="token selector">.scroll-wrapper</span>
- <span class="token property-declaration"><span class="token property">height</span> <span class="token number">100</span><span class="token unit">px</span></span>
- <span class="token property-declaration"><span class="token property">width</span> <span class="token number">250</span><span class="token unit">px</span></span>
- <span class="token property-declaration"><span class="token property">position</span> relative</span>
- <span class="token property-declaration"><span class="token property">overflow</span> hidden</span>
- <span class="token property-declaration"><span class="token property">white-space</span> nowrap</span>
- <span class="token property-declaration"><span class="token property">margin</span> <span class="token number">0</span> auto</span>
- <span class="token property-declaration"><span class="token property">border</span> <span class="token number">1</span><span class="token unit">px</span> solid <span class="token hexcode">#ccc</span></span>
- <span class="token selector">.scroll-content</span>
- <span class="token property-declaration"><span class="token property">display</span> inline-block</span>
- <span class="token selector">.scroll-item</span>
- <span class="token property-declaration"><span class="token property">height</span> <span class="token number">100</span><span class="token unit">px</span></span>
- <span class="token property-declaration"><span class="token property">width</span> <span class="token number">100</span><span class="token unit">px</span></span>
- <span class="token property-declaration"><span class="token property">line-height</span> <span class="token number">100</span><span class="token unit">px</span></span>
- <span class="token property-declaration"><span class="token property">font-size</span> <span class="token number">24</span><span class="token unit">px</span></span>
- <span class="token property-declaration"><span class="token property">font-weight</span> bold</span>
- <span class="token property-declaration"><span class="token property">text-align</span> center</span>
- <span class="token property-declaration"><span class="token property">display</span> inline-block</span>
- <span class="token selector">&:nth-child(2n)</span>
- <span class="token property-declaration"><span class="token property">background-color</span> <span class="token hexcode">#f3f5f7</span></span>
- <span class="token selector">&:nth-child(2n+1)</span>
- <span class="token property-declaration"><span class="token property">background-color</span> <span class="token hexcode">#42b983</span></span>
- </style></code></pre></div></div> <i class="demo-code-content-copy"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="#ccc"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg></i> <!----></div></div> <div class="demo-main"><div class="demo-component-wrap"></div></div></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/ustbhuangyi/better-scroll/edit/dev/packages/vuepress-docs/docs/en-US/guide/base-scroll-options.md" target="_blank" rel="noopener noreferrer">Edit this page on GitHub</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">Last Updated:</span> <span class="time">4/19/2021, 8:15:26 PM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
- ←
- <a href="/docs/en-US/guide/base-scroll.html" class="prev">
- base-scroll
- </a></span> <span class="next"><a href="/docs/en-US/guide/base-scroll-api.html">
- API
- </a>
- →
- </span></p></div> </main></div><div class="global-ui"><!----></div></div>
- <script src="/docs/assets/js/app.c71b64d3.js" defer></script><script src="/docs/assets/js/5.d6412664.js" defer></script><script src="/docs/assets/js/4.4855b9ef.js" defer></script><script src="/docs/assets/js/3.481632b4.js" defer></script><script src="/docs/assets/js/79.025583e1.js" defer></script><script src="/docs/assets/js/7.518ccda7.js" defer></script><script src="/docs/assets/js/56.cd04bae9.js" defer></script>
- </body>
- </html>
|