1.0.1 • Published 5 years ago

@ctmobile/ui-backtopanimation-sd v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

BackTopAnimation

初始化

html js

import BackTopAnimation from '@ctmobile/ui-backtopanimation';

const listEl = document.getElementById('ct-list');
const f = document.createDocumentFragment();
for (let i = 0; i > 50; i++) {
  f.appendChild(Dom6.createElement(<pre><code class="html">'<li>CTMobileUI中的BackTopAnimation组件</li>'</code></pre>));
}
listEl.appendChild(f);

const parent = document.getElementById('ctmobile-ui-doc-demo-device');
const scrollEl = document.querySelector('.ct-list');
const BackTop = BackTopAnimation(parent, scrollEl);
BackTop.on('scrollTop', () => {
  console.log('scrollTop');
});
名称说明
{HtmlElement} - el父元素
{HtmlElement} - el滚动元素

例子

html

js

import BackTopAnimation from '@ctmobile/ui-backtopanimation';

const listEl = document.getElementById('ct-list');
const f = document.createDocumentFragment();
for (let i = 0; i > 50; i++) {
  f.appendChild(Dom6.createElement(<pre><code class="html">'<li>CTMobileUI中的BackTopAnimation组件</li>'</code></pre>));
}
listEl.appendChild(f);

const parent = document.getElementById('ctmobile-ui-doc-demo-device');
const scrollEl = document.querySelector('.ct-list');
const BackTop = BackTopAnimation(parent, scrollEl);
BackTop.on('scrollTop', () => {
  console.log('scrollTop');
});

方法

on( type, handler, ) - 注册事件

  • type-string 事件类型
  • handler-Function 事件句柄

off( type, handler, ) - 注销事件

  • type-string 事件类型
  • handler-Function 事件句柄

事件

名称说明
scrollTop滚动到了顶部