-
Notifications
You must be signed in to change notification settings - Fork 0
/
4947-2a6ab008b1bf639ff843.js
1 lines (1 loc) · 45.7 KB
/
4947-2a6ab008b1bf639ff843.js
1
(self.webpackChunkzent_docs=self.webpackChunkzent_docs||[]).push([[4947],{84947:(n,a,s)=>{"use strict";s.r(a),s.d(a,{default:()=>w});var t=s(73450),e=s(73118),o=s(27378),p=s(57318),c=s(33938),l=s(86446),u=s(39215),i=s(14623),r=s(24246);function k(n,a){var s=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable}))),s.push.apply(s,t)}return s}function d(n){for(var a=1;a<arguments.length;a++){var s=null!=arguments[a]?arguments[a]:{};a%2?k(Object(s),!0).forEach((function(a){(0,t.Z)(n,a,s[a])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(s)):k(Object(s)).forEach((function(a){Object.defineProperty(n,a,Object.getOwnPropertyDescriptor(s,a))}))}return n}var m=function(){function n(n){var s=o.useState(null),t=(0,e.Z)(s,2),p=t[0],u=t[1],i=o.useState(!0),k=(0,e.Z)(i,2),m=k[0],f=k[1],h=o.useCallback((()=>u("Waypoint 进入屏幕")),[]),v=o.useCallback((()=>u("Waypoint 离开屏幕")),[]),g=o.useCallback((n=>f(n.target.checked)),[]),y=o.useMemo((()=>m?{topOffset:"auto",bottomOffset:"auto"}:{}),[m]);return(0,r.jsxs)("div",{className:"waypoint-demo-basic",children:[(0,r.jsx)("div",{style:{marginBottom:16},children:(0,r.jsx)(c.X,{checked:m,onChange:g,children:"猜测 topOffset 和 bottomOffset"})}),p?(0,r.jsx)("div",{className:"waypoint-demo-basic__message",children:p}):null,(0,r.jsxs)("div",{className:"waypoint-demo-basic__scrollable-parent",children:[(0,r.jsx)(a,{}),(0,r.jsx)(a,{}),(0,r.jsx)(a,{}),(0,r.jsx)(a,{}),(0,r.jsx)(a,{}),(0,r.jsx)(a,{}),(0,r.jsx)(l.h,d({onEnter:h,onLeave:v},y)),(0,r.jsx)(a,{}),(0,r.jsx)(a,{}),(0,r.jsx)(a,{}),(0,r.jsx)(a,{}),(0,r.jsx)(a,{}),(0,r.jsx)(a,{})]})]})}function a(){return(0,r.jsx)("div",{className:"waypoint-demo-basic__spacer",children:(0,r.jsx)(u.J,{type:"down"})})}return(0,r.jsx)(n,{})},f=function(){function n(n){var a=o.useState(!1),s=(0,e.Z)(a,2),t=s[0],p=s[1],c=o.useCallback((()=>p(!0)),[]),u=o.useCallback((()=>p(!1)),[]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.h,{onEnter:c,onLeave:u}),(0,r.jsx)(i.Z,{in:t,timeout:500,classNames:"waypoint-demo-reveal",unmountOnExit:!0,children:n.children})]})}function a(a){return(0,r.jsx)("div",{className:"waypoint-demo-reveal",children:(0,r.jsxs)("div",{className:"waypoint-demo-reveal__scrollable-parent",children:[(0,r.jsx)(s,{}),(0,r.jsx)(s,{}),(0,r.jsx)(s,{}),(0,r.jsx)(n,{children:(0,r.jsx)("p",{className:"waypoint-demo-reveal-text",children:"Surely You're Joking, Mr. Feynman!"})}),(0,r.jsx)(s,{}),(0,r.jsx)(s,{}),(0,r.jsx)(s,{})]})})}function s(){return(0,r.jsx)("div",{className:"waypoint-demo-reveal__spacer",children:(0,r.jsx)(u.J,{type:"down",className:"waypoint-demo-reveal-pulse"})})}return(0,r.jsx)(a,{})};function h(n){return(0,r.jsx)(n.tag,d(d({},n.attributes),{},{dangerouslySetInnerHTML:{__html:n.html}}))}function v(n){return(0,r.jsx)(h,{tag:"section",html:n.html,attributes:{className:"zandoc-react-markdown"}})}function g(n){return(0,r.jsx)(h,{tag:"style",html:n.style})}function y(n,a){for(;n;)return n.offsetTop&&"static"!==getComputedStyle(n).position&&(a+=n.offsetTop),y(n.parentNode,a);return a}class b extends o.Component{constructor(...n){super(...n),(0,t.Z)(this,"state",{showCode:!1}),(0,t.Z)(this,"toggle",(()=>{this.setState({showCode:!this.state.showCode})}))}render(){var n=this.state.showCode,a=this.props,s=a.title,t=a.src,e=a.children;return(0,r.jsxs)("div",{className:"zandoc-react-demo",children:[(0,r.jsx)("div",{className:"zandoc-react-demo__preview",children:e}),(0,r.jsxs)("div",{className:"zandoc-react-demo__bottom",onClick:this.toggle,children:[(0,r.jsx)("div",{className:"zandoc-react-demo__title",children:(0,r.jsx)("p",{children:s||""})}),(0,r.jsx)("i",{className:"zenticon zenticon-caret-up zandoc-react-demo__toggle ".concat(n?"zandoc-react-demo__toggle-on":"zandoc-react-demo__toggle-off")})]}),n&&(0,r.jsx)("pre",{className:"zandoc-react-demo__code",children:(0,r.jsx)(h,{tag:"code",html:t,attributes:{className:"language-jsx"}})})]})}}class w extends o.Component{componentDidMount(){var n=location.hash;if(n){var a=document.querySelector('a[href="'.concat(n,'"]'));a&&(0,p.l)(document.documentElement,0,y(a,-9))}}render(){return o.createElement("div",{className:"zandoc-react-container"},o.createElement(g,{style:".waypoint-demo-basic .zent-waypoint-marker {\n\tdisplay: block;\n\theight: 4px;\n\tbackground: #d40000;\n}\n\n.waypoint-demo-basic__scrollable-parent {\n max-height: 400px;\n overflow: scroll;\n position: relative;\n\tborder: 20px solid rgba(21, 91, 212, 0.2);\n}\n\n.waypoint-demo-basic__spacer {\n color: #969799;\n font-size: 40px;\n line-height: 200px;\n text-align: center;\n}\n\n.waypoint-demo-basic__message {\n\tbox-sizing: border-box;\n background-color: #f2f3f5;\n color: #323233;\n opacity: 0.8;\n padding: 10px 0;\n pointer-events: none;\n text-align: center;\n width: 100%;\n}\n\n.waypoint-demo-reveal {\n position: relative;\n}\n\n.waypoint-demo-reveal__scrollable-parent {\n max-height: 400px;\n overflow: scroll;\n position: relative;\n}\n\n.waypoint-demo-reveal__spacer {\n color: #969799;\n font-size: 40px;\n line-height: 200px;\n text-align: center;\n}\n\n.waypoint-demo-reveal-text {\n\ttransition: opacity 500ms, transform 500ms;\n\ttext-align: center;\n\tpadding: 10px 0;\n}\n\n.waypoint-demo-reveal-enter {\n\topacity: 0;\n\ttransform: scale(0.1);\n}\n\n.waypoint-demo-reveal-enter-active {\n\topacity: 1;\n\ttransform: scale(1);\n}\n\n.waypoint-demo-reveal-exit {\n\topacity: 1;\n\ttransform: scale(0.9);\n}\n\n.waypoint-demo-reveal-exit-active {\n\topacity: 0;\n\ttransform: scale(0);\n}"}),o.createElement(v,{html:'<h2 class="anchor-heading"><a href="#waypoint">¶</a><a href="javascript:void(0)" id="waypoint" class="anchor-point"></a>Waypoint</h2>\n<p>当滚动到某个 DOM 元素时执行一个函数,支持任意可滚动的容器。</p>\n<p><strong>常见使用场景:</strong></p>\n<ul>\n<li>懒加载图片</li>\n<li>无限滚动</li>\n<li>固钉</li>\n</ul>\n<h3 class="anchor-heading"><a href="#dai-ma-yan-shi">¶</a><a href="javascript:void(0)" id="dai-ma-yan-shi" class="anchor-point"></a>代码演示</h3>'}),o.createElement(b,{title:"基础用法",id:"Demo01basic",src:'<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">Waypoint</span><span class="token punctuation">,</span> <span class="token maybe-class-name">Icon</span><span class="token punctuation">,</span> <span class="token maybe-class-name">Checkbox</span> <span class="token punctuation">}</span></span> <span class="token keyword module">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">function</span> <span class="token function"><span class="token maybe-class-name">Demo</span></span><span class="token punctuation">(</span><span class="token parameter">props</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword">const</span> <span class="token punctuation">[</span>msg<span class="token punctuation">,</span> setMsg<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token maybe-class-name">React</span><span class="token punctuation">.</span><span class="token method function property-access">useState</span><span class="token punctuation">(</span><span class="token keyword null nil">null</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token keyword">const</span> <span class="token punctuation">[</span>autoBorderWidth<span class="token punctuation">,</span> setAutoBorderWidth<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token maybe-class-name">React</span><span class="token punctuation">.</span><span class="token method function property-access">useState</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token keyword">const</span> setEnterMsg <span class="token operator">=</span> <span class="token maybe-class-name">React</span><span class="token punctuation">.</span><span class="token method function property-access">useCallback</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token function">setMsg</span><span class="token punctuation">(</span><span class="token string">\'Waypoint 进入屏幕\'</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 class="token punctuation">;</span>\n <span class="token keyword">const</span> setLeaveMsg <span class="token operator">=</span> <span class="token maybe-class-name">React</span><span class="token punctuation">.</span><span class="token method function property-access">useCallback</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token function">setMsg</span><span class="token punctuation">(</span><span class="token string">\'Waypoint 离开屏幕\'</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 class="token punctuation">;</span>\n <span class="token keyword">const</span> setAuto <span class="token operator">=</span> <span class="token maybe-class-name">React</span><span class="token punctuation">.</span><span class="token method function property-access">useCallback</span><span class="token punctuation">(</span><span class="token parameter">e</span> <span class="token arrow operator">=></span> <span class="token function">setAutoBorderWidth</span><span class="token punctuation">(</span>e<span class="token punctuation">.</span><span class="token property-access">target</span><span class="token punctuation">.</span><span class="token property-access">checked</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 class="token punctuation">;</span>\n <span class="token keyword">const</span> autoProps <span class="token operator">=</span> <span class="token maybe-class-name">React</span><span class="token punctuation">.</span><span class="token method function property-access">useMemo</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token keyword control-flow">return</span> autoBorderWidth <span class="token operator">?</span> <span class="token punctuation">{</span>\n topOffset<span class="token operator">:</span> <span class="token string">\'auto\'</span><span class="token punctuation">,</span>\n bottomOffset<span class="token operator">:</span> <span class="token string">\'auto\'</span>\n <span class="token punctuation">}</span> <span class="token operator">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">[</span>autoBorderWidth<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n\n <span class="token keyword control-flow">return</span> <span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>waypoint-demo-basic<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>marginBottom<span class="token operator">:</span> <span class="token number">16</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">checked</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>autoBorderWidth<span class="token punctuation">}</span></span> <span class="token attr-name">onChange</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>setAuto<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>\n 猜测 topOffset 和 bottomOffset\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token punctuation">{</span>msg <span class="token operator">?</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>waypoint-demo-basic__message<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span>msg<span class="token punctuation">}</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 operator">:</span> <span class="token keyword null nil">null</span><span class="token punctuation">}</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>waypoint-demo-basic__scrollable-parent<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Waypoint</span></span> <span class="token attr-name">onEnter</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>setEnterMsg<span class="token punctuation">}</span></span> <span class="token attr-name">onLeave</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>setLeaveMsg<span class="token punctuation">}</span></span> <span class="token spread"><span class="token punctuation">{</span><span class="token spread operator">...</span>autoProps<span class="token punctuation">}</span></span><span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token punctuation">)</span><span class="token punctuation">;</span>\n<span class="token punctuation">}</span>\n\n<span class="token keyword">function</span> <span class="token function"><span class="token maybe-class-name">Spacer</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword control-flow">return</span> <span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>waypoint-demo-basic__spacer<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Icon</span></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>down<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token punctuation">)</span><span class="token punctuation">;</span>\n<span class="token punctuation">}</span>\n\n<span class="token maybe-class-name">ReactDOM</span><span class="token punctuation">.</span><span class="token method function property-access">render</span><span class="token punctuation">(</span><span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Demo</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span>'},o.createElement(m)),o.createElement(b,{title:"Reveal",id:"Demo02reveal",src:'<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">Waypoint</span><span class="token punctuation">,</span> <span class="token maybe-class-name">Icon</span> <span class="token punctuation">}</span></span> <span class="token keyword module">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">CSSTransition</span> <span class="token punctuation">}</span></span> <span class="token keyword module">from</span> <span class="token string">\'react-transition-group\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">function</span> <span class="token function"><span class="token maybe-class-name">Reveal</span></span><span class="token punctuation">(</span><span class="token parameter">props</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword">const</span> <span class="token punctuation">[</span>revealed<span class="token punctuation">,</span> setRevealed<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token maybe-class-name">React</span><span class="token punctuation">.</span><span class="token method function property-access">useState</span><span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token keyword">const</span> reveal <span class="token operator">=</span> <span class="token maybe-class-name">React</span><span class="token punctuation">.</span><span class="token method function property-access">useCallback</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token function">setRevealed</span><span class="token punctuation">(</span><span class="token boolean">true</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 class="token punctuation">;</span>\n <span class="token keyword">const</span> hide <span class="token operator">=</span> <span class="token maybe-class-name">React</span><span class="token punctuation">.</span><span class="token method function property-access">useCallback</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token function">setRevealed</span><span class="token punctuation">(</span><span class="token boolean">false</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 class="token punctuation">;</span>\n <span class="token keyword control-flow">return</span> <span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Waypoint</span></span> <span class="token attr-name">onEnter</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>reveal<span class="token punctuation">}</span></span> <span class="token attr-name">onLeave</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>hide<span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">CSSTransition</span></span>\n <span class="token attr-name">in</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>revealed<span class="token punctuation">}</span></span>\n <span class="token attr-name">timeout</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token number">500</span><span class="token punctuation">}</span></span>\n <span class="token attr-name">classNames</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>waypoint-demo-reveal<span class="token punctuation">"</span></span>\n <span class="token attr-name">unmountOnExit</span>\n <span class="token punctuation">></span></span>\n <span class="token punctuation">{</span>props<span class="token punctuation">.</span><span class="token property-access">children</span><span class="token punctuation">}</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">CSSTransition</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span></span><span class="token punctuation">></span></span>\n <span class="token punctuation">)</span><span class="token punctuation">;</span>\n<span class="token punctuation">}</span>\n\n<span class="token keyword">function</span> <span class="token function"><span class="token maybe-class-name">Demo</span></span><span class="token punctuation">(</span><span class="token parameter">props</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword control-flow">return</span> <span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>waypoint-demo-reveal<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>waypoint-demo-reveal__scrollable-parent<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Reveal</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>waypoint-demo-reveal-text<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>\n <span class="token maybe-class-name">Surely</span> <span class="token maybe-class-name">You</span>\'re <span class="token maybe-class-name">Joking</span><span class="token punctuation">,</span> <span class="token maybe-class-name">Mr</span><span class="token punctuation">.</span> <span class="token property-access"><span class="token maybe-class-name">Feynman</span></span><span class="token operator">!</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Reveal</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Spacer</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token punctuation">)</span><span class="token punctuation">;</span>\n<span class="token punctuation">}</span>\n\n<span class="token keyword">function</span> <span class="token function"><span class="token maybe-class-name">Spacer</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword control-flow">return</span> <span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>waypoint-demo-reveal__spacer<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Icon</span></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>down<span class="token punctuation">"</span></span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>waypoint-demo-reveal-pulse<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token punctuation">)</span><span class="token punctuation">;</span>\n<span class="token punctuation">}</span>\n\n<span class="token maybe-class-name">ReactDOM</span><span class="token punctuation">.</span><span class="token method function property-access">render</span><span class="token punctuation">(</span><span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Demo</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span>'},o.createElement(f)),o.createElement(v,{html:'<h3 class="anchor-heading"><a href="#api">¶</a><a href="javascript:void(0)" id="api" class="anchor-point"></a>API</h3>\n<table class="table">\n<thead>\n<tr>\n<th>参数</th>\n<th>说明</th>\n<th>类型</th>\n<th>是否必须</th>\n<th>默认值</th>\n<th>备选值</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>onEnter</td>\n<td>元素滚动到屏幕内时的回调函数</td>\n<td><code>(data: IWaypointCallbackData) => void</code></td>\n<td>否</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>onLeave</td>\n<td>元素滚动到屏幕外时的回调函数</td>\n<td><code>(data: IWaypointCallbackData) => void</code></td>\n<td>否</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>onPositionChange</td>\n<td>元素位置变化时的回调函数</td>\n<td><code>(data: IWaypointCallbackData) => void</code></td>\n<td>否</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>topOffset</td>\n<td>距离容器顶部的距离</td>\n<td><code>number</code>\n \n|\n \n<code>\'auto\'</code>\n \n|\n \n<code>string</code></td>\n<td>否</td>\n<td><code>0</code></td>\n<td></td>\n</tr>\n<tr>\n<td>bottomOffset</td>\n<td>距离容器底部的距离</td>\n<td><code>number</code>\n \n|\n \n<code>\'auto\'</code>\n \n|\n \n<code>string</code></td>\n<td>否</td>\n<td><code>0</code></td>\n<td></td>\n</tr>\n<tr>\n<td>horizontal</td>\n<td>是否使用水平滚动模式</td>\n<td><code>boolean</code></td>\n<td>否</td>\n<td><code>false</code></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>scrollableAncestor</td>\n<td>指定滚动容器的 DOM 元素,一般当外层有多个滚动容器时才需要使用</td>\n<td><code>Element</code></td>\n<td>否</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>fireOnRapidScroll</td>\n<td>当快速滚动时是否触发 \n<code>onEnter</code>\n 和 \n<code>onLeave</code></td>\n<td><code>boolean</code></td>\n<td>否</td>\n<td><code>true</code></td>\n<td></td>\n</tr>\n<tr>\n<td>children</td>\n<td>待追踪的元素,不传时可以认为是追踪屏幕内一条线</td>\n<td><code>ReactNode</code></td>\n<td>否</td>\n<td></td>\n<td></td>\n</tr>\n</tbody>\n</table>\n<h4 class="anchor-heading"><a href="#topoffset-he-bottomoffset">¶</a><a href="javascript:void(0)" id="topoffset-he-bottomoffset" class="anchor-point"></a><code>topOffset</code> 和 <code>bottomOffset</code></h4>\n<ul>\n<li>容器的<a href="https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/Determining_the_dimensions_of_elements#what.27s_the_size_of_the_displayed_content.3f">可滚动区域</a> 是 <code>clientWidth</code>✖️<code>clientHeight</code>,但是 <code>getBoundingClientRect</code> 的返回值包含了 <code>border</code> 的宽度,如果容器设置了 <code>border</code> 就需要使用 <code>topOffset</code> 或者 <code>bottomOffset</code> 传入 <code>border</code> 宽度</li>\n<li><code>topOffset</code> 和 <code>bottomOffset</code> 可正可负,正负数效果和 <code>margin</code> 一样,正数往屏幕内偏移,负数往屏幕外偏移</li>\n<li><code>topOffset</code> 和 <code>bottomOffset</code> 可以是一个百分比,这个百分比是相对滚动容器大小的</li>\n<li>开启 <code>horizontal</code> 后,<code>topOffset</code> 其实是 <code>leftOffset</code>,而 <code>bottomOffset</code> 其实是 <code>rightOffset</code>,参数名特意没有变</li>\n<li><code>topOffset</code> 和 <code>bottomOffset</code> 可以设置为 <code>\'auto\'</code>,此时会尝试获取滚动容器的 <code>border</code> 宽度,目前仅支持解析<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/length#absolute_length_units">绝对长度单位</a>以及 <code>em</code> 和 <code>rem</code>,如果解析失败则使用默认值 <code>0</code>;不支持容器的 <code>transform</code> 属性,请不要一起使用</li>\n</ul>\n<h3 class="anchor-heading"><a href="#faqs">¶</a><a href="javascript:void(0)" id="faqs" class="anchor-point"></a>FAQs</h3>\n<ul>\n<li><a href="../../apidoc/interfaces/IWaypointCallbackData.html"><code>IWaypointCallbackData</code> 的定义</a></li>\n<li>快速滚动顾名思义就是滚动速度非常快,元素可能进入屏幕后立刻又出了屏幕</li>\n<li><code>children</code> 只能是<strong>一个</strong>元素,这个元素必须是原生组件、<code>React.forwardRef</code> 包装过的自定义组件,或者是接受一个 <code>innerRef</code> 参数的自定义组件,其中自定义组件必须把 <code>ref</code> 设置到需要跟踪位置的 DOM 元素上</li>\n</ul>'}))}}},33938:(n,a,s)=>{"use strict";s.d(a,{X:()=>k});var t=s(59312),e=s(24246),o=s(60042),p=s.n(o),c=s(27378),l=s(1535),u=s(23130),i=s(1348),r=s(4008);function k(n){var a=(0,c.useContext)(i.d),s=(0,c.useContext)(u.Z),o=(0,c.useRef)(n);o.current=n;var r,k=s&&s.onChange,d=(0,c.useCallback)((function(n){var a=o.current,s=a.value,e=a.onChange;if(k)k(s);else if(e){var p=Object.create(n);p.target=(0,t.pi)((0,t.pi)({},o.current),{type:"checkbox",checked:n.target.checked}),e(p)}}),[k]),m=(n.checked,n.className),f=n.style,h=(n.disabled,n.readOnly,n.children),v=n.indeterminate,g=n.width,y=(n.value,n.labelStyle),b=n.onMouseEnter,w=n.onMouseLeave,x=(0,t._T)(n,["checked","className","style","disabled","readOnly","children","indeterminate","width","value","labelStyle","onMouseEnter","onMouseLeave"]),j=function(n,a){return"boolean"==typeof a.readOnly?a.readOnly:!!n&&n.readOnly}(s,n),O=function(n,a,s){return"boolean"==typeof s.disabled?s.disabled:a?a.disabled:n.value}(a,s,n);if(s){var S=s.value,C=s.isValueEqual;r=-1!==S.findIndex((function(a){return C(a,n.value)}))}else r=!!n.checked;return(0,e.jsxs)("label",(0,t.pi)({className:p()("zent-checkbox-wrap",m,{"zent-checkbox-checked":!!r,"zent-checkbox-disabled":O||j,"zent-checkbox-indeterminate":v}),style:(0,t.pi)((0,t.pi)({},f),(0,l.Z)(g)),onMouseEnter:b,onMouseLeave:w,"data-zv":"9.12.16"},{children:[(0,e.jsxs)("span",(0,t.pi)({className:"zent-checkbox","data-zv":"9.12.16"},{children:[(0,e.jsx)("span",{className:"zent-checkbox-inner","data-zv":"9.12.16"},void 0),(0,e.jsx)("input",(0,t.pi)({},x,{type:"checkbox",checked:r&&!v,disabled:O,readOnly:j,onChange:d,"data-zv":"9.12.16"}),void 0)]}),void 0),null!=h&&!0!==h&&!1!==h?(0,e.jsx)("div",(0,t.pi)({className:"zent-checkbox-label",style:y,"data-zv":"9.12.16"},{children:h}),void 0):null]}),void 0)}k.Group=r.Z,a.Z=k},4008:(n,a,s)=>{"use strict";s.d(a,{c:()=>k});var t=s(59312),e=s(24246),o=s(27378),p=s(60042),c=s.n(p),l=s(41925),u=s(23130),i=s(1348),r=u.Z.Provider,k=function(n){function a(){var a=null!==n&&n.apply(this,arguments)||this;return a.getGroupContext=(0,l.Z)((function(n,s,t,e){return{value:Array.isArray(n)?n:[],disabled:s,readOnly:t,isValueEqual:e,onChange:a.onCheckboxChange}})),a.onCheckboxChange=function(n){var s=a.props,t=s.isValueEqual,e=s.onChange,o=s.value;if(e){var p=o?o.slice():[],c=p.findIndex((function(a){return t(a,n)}));-1!==c?p.splice(c,1):p.push(n),e(p)}},a}return(0,t.ZT)(a,n),a.prototype.render=function(){var n=this.props,a=n.className,s=n.style,o=n.children,p=n.value,l=n.disabled,u=void 0===l?this.context.value:l,i=n.readOnly,k=void 0!==i&&i,d=n.isValueEqual,m=c()("zent-checkbox-group",a);return(0,e.jsx)(r,(0,t.pi)({value:this.getGroupContext(p,u,k,d)},{children:(0,e.jsx)("div",(0,t.pi)({className:m,style:s,"data-zv":"9.12.16"},{children:o}),void 0)}),void 0)},a.defaultProps={isValueEqual:Object.is,value:[]},a.contextType=i.d,a}(o.Component);a.Z=k},23130:(n,a,s)=>{"use strict";var t=s(27378);a.Z=(0,t.createContext)(null)},55978:(n,a,s)=>{"use strict";function t(n){for(var a=[],s=1;s<arguments.length;s++)a[s-1]=arguments[s];var t=setTimeout((function(){return n.apply(void 0,a)}),1);return{cancel:function(){clearTimeout(t)}}}s.d(a,{Z:()=>t})},1535:(n,a,s)=>{"use strict";function t(n){return"string"==typeof n||"number"==typeof n?{width:n}:{}}s.d(a,{Z:()=>t})},86446:(n,a,s)=>{"use strict";s.d(a,{h:()=>v});var t=s(59312),e=s(24246),o=s(27378),p=s(49744),c=s(19185);function l(n){return(0,c.isElement)(n)&&"string"==typeof n.type}function u(n){return n.viewportBottom-n.viewportTop==0?3:n.viewportTop<=n.waypointTop&&n.waypointTop<=n.viewportBottom||n.viewportTop<=n.waypointBottom&&n.waypointBottom<=n.viewportBottom||n.waypointTop<=n.viewportTop&&n.viewportBottom<=n.waypointBottom?1:n.viewportBottom<n.waypointTop?2:n.waypointTop<n.viewportTop?0:3}var i=s(79352),r=s(55978);function k(n){return f(n.toLowerCase())}function d(n,a,s){var t=f(n=n.toLowerCase());return null!==t?t:function(n,a,s){var t=h.exec(n);if(t){var e=parseFloat(t[1]);switch(t[2]){case"em":return null!==(o=a())?o*e:null;case"rem":var o;return null!==(o=s())?o*e:null;default:return null}}return null}(n,a,s)}var m=/(^-?\d*\.?\d+)(cm|mm|in|px|pt|pc)$/;function f(n){var a=m.exec(n);if(a){var s=parseFloat(a[1]);switch(a[2]){case"cm":return 9600*s/254;case"mm":return 960*s/254;case"in":return 96*s;case"pt":return 4*s/3;case"pc":return 16*s;case"px":return s;default:return null}}return null}var h=/(^-?\d*\.?\d+)(em|rem)$/,v=function(n){function a(){var a=null!==n&&n.apply(this,arguments)||this;return a.refElement=(0,o.createRef)(),a.previousPosition=4,a.handleScroll=function(n){if(a.refElement.current){var s=a.getBounds(),t=u(s),e=a.previousPosition,o=a.props,p=o.onPositionChange,c=o.onEnter,l=o.onLeave,i=o.fireOnRapidScroll;if(a.previousPosition=t,e!==t){var r={currentPosition:t,previousPosition:e,event:n,waypointTop:s.waypointTop,waypointBottom:s.waypointBottom,viewportTop:s.viewportTop,viewportBottom:s.viewportBottom};null==p||p(r),1===t?null==c||c(r):1!==e&&4!==e||null==l||l(r),i&&(2===e&&0===t||0===e&&2===t)&&(null==c||c({currentPosition:1,previousPosition:e,event:n,waypointTop:s.waypointTop,waypointBottom:s.waypointBottom,viewportTop:s.viewportTop,viewportBottom:s.viewportBottom}),null==l||l({currentPosition:t,previousPosition:1,event:n,waypointTop:s.waypointTop,waypointBottom:s.waypointBottom,viewportTop:s.viewportTop,viewportBottom:s.viewportBottom}))}}},a}return(0,t.ZT)(a,n),a.prototype.componentDidMount=function(){var n=this;i.Z&&(this.cancelOnNextTick=(0,r.Z)((function(){n.cancelOnNextTick=null,function(n,a){if(n&&!l(n)&&!a)throw new Error("<Waypoint> needs a DOM element to compute boundaries. The child you passed is neither a DOM element (e.g. <div>) nor does it use the innerRef prop.\n")}(n.props.children,n.refElement.current),n.scrollableAncestor=n.findScrollableAncestor(),n.scrollEventListenerUnsubscribe=(0,p.Oo)(n.scrollableAncestor,"scroll",n.handleScroll,{passive:!0}),n.resizeEventListenerUnsubscribe=(0,p.Oo)(window,"resize",n.handleScroll,{passive:!0}),n.handleScroll(null)})))},a.prototype.componentDidUpdate=function(){var n=this;i.Z&&this.scrollableAncestor&&(this.cancelOnNextTick||(this.cancelOnNextTick=(0,r.Z)((function(){n.cancelOnNextTick=null,n.handleScroll(null)}))))},a.prototype.componentWillUnmount=function(){var n,a,s;i.Z&&(null===(n=this.scrollEventListenerUnsubscribe)||void 0===n||n.call(this),null===(a=this.resizeEventListenerUnsubscribe)||void 0===a||a.call(this),null===(s=this.cancelOnNextTick)||void 0===s||s.cancel())},a.prototype.findScrollableAncestor=function(){var n=this.props,a=n.horizontal,s=n.scrollableAncestor;if(s)return s;for(var t=this.refElement.current;t.parentNode;){if((t=t.parentNode)===document.body)return window;var e=getComputedStyle(t),o=(a?e.getPropertyValue("overflow-x"):e.getPropertyValue("overflow-y"))||e.getPropertyValue("overflow");if("auto"===o||"scroll"===o)return t}return window},a.prototype.getBounds=function(){var n,a,s=this.props.horizontal,t=this.refElement.current.getBoundingClientRect(),e=t.left,o=t.top,p=t.right,c=t.bottom,l=s?e:o,u=s?p:c;if(this.scrollableAncestor===window)n=s?window.innerWidth:window.innerHeight,a=0;else{var i=this.scrollableAncestor.getBoundingClientRect();n=s?i.width:i.height,a=s?i.left:i.top}return{waypointTop:l,waypointBottom:u,viewportTop:a+this.getOffset("top",n),viewportBottom:a+n-this.getOffset("bottom",n)}},a.prototype.getOffset=function(n,a){var s,t,e=this.props.horizontal,o=n+"Offset",p="top"===n?"border"+(e?"Left":"Top")+"Width":"border"+(e?"Right":"Bottom")+"Width",c=this.props[o];if("auto"!==c)return function(n,a){var s=function(n){var a;if(a="number"==typeof n?n:parseFloat(n),!Number.isNaN(a)&&Number.isFinite(a))return a}(n);if("number"==typeof s)return s;if("string"==typeof n){var t=function(n){if("%"===n.slice(-1))return parseFloat(n.slice(0,-1))/100}(n);if("number"==typeof t)return t*a}}(c,a);if(this.scrollableAncestor===window){var l=getComputedStyle(document.documentElement),u=function(){return k(l.fontSize)};return null!==(s=d(l[p],u,u))&&void 0!==s?s:0}var i=getComputedStyle(this.scrollableAncestor);return u=function(){return k(i.fontSize)},null!==(t=d(i[p],u,(function(){return k(getComputedStyle(document.documentElement).fontSize)})))&&void 0!==t?t:0},a.prototype.render=function(){var n=this,a=this.props.children;if(!a)return(0,e.jsx)("span",{ref:this.refElement,style:{fontSize:0},className:"zent-waypoint-marker","data-zv":"9.12.16"},void 0);var s=o.Children.only(a);return l(s)||(0,c.isForwardRef)(s)?(0,o.cloneElement)(s,{ref:function(a){n.refElement.current=a;var t=s.ref;t&&("function"==typeof t?t(a):t.current=a)}}):(0,o.cloneElement)(s,{innerRef:this.refElement})},a.defaultProps={topOffset:0,bottomOffset:0,horizontal:!1,fireOnRapidScroll:!0},a}(o.PureComponent)}}]);