![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@json_web_component/infinitscrollpagination
Advanced tools
Readme
这个自定义 Web 组件可以在网页应用中实现流畅的滚动分页功能。它支持双向加载新条目,并提供清晰的加载状态指示。
InfinitScrollPagination 组件可以通过以下属性进行配置:
reverse
属性)的距离,值为0-1, 具体请查阅 MDN。InfinitScrollPagination 组件提供以下方法:
threshold
时触发。负责获取新数据并追加到内容容器中。<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script type="module" src="https://unpkg.com/@json_web_component/infinitscrollpagination/dist/main.min.js"></script>
<title>Title</title>
<script type="module">
</script>
<style>
.scroll-container {}
</style>
</head>
<body>
<infinit-scroll class="scroll-container" height="200px">
</infinit-scroll>
<script>
const container = document.querySelector('.scroll-container');
let loading = false;
let hasMore = true;
container.setAttribute('has-more', hasMore);
container.setAttribute('loading', loading);
container.addEventListener('load', getListData)
function getListData(page) {
loading = true;
container.setAttribute('loading', loading);
setTimeout(() => {
loading = false;
hasMore = false;
container.setAttribute('has-more', hasMore);
container.setAttribute('loading', loading);
console.log(page, '获取到数据');
for (let i = 0; i < 12; i++) {
const item = document.createElement('div');
const styles = {
height: '80px',
background: '#eee',
marginBottom: '10px'
}
for (const key in styles) {
if (Object.hasOwnProperty.call(styles, key)) {
const val = styles[key];
item.style[key] = val;
}
}
// 如果 reverse 为 true
container.append(item);
// 如果 reverse 为 false
// container.prepend(item)
// 如果需要滚动到底部
// container.scrollToEnd();
// 如果需要滚动到顶部
// container.scrollToTop();
}
}, 800)
}
</script>
</body>
</html>
<!-- 原生 html 引用 -->
<script type="module" src="https://unpkg.com/@json_web_component/infinitscrollpagination/dist/main.min.js"></script>
// vue3 vite处理
export default defineConfig({
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: tag => tag === 'infinit-scroll'
}
}
})
]
})
// vue 或 react只需在 main.js 中引用
import "@json_web_component/infinitscrollpagination";
// 其他使用方法请参考html的写法结合 vue 的写法
// tsconfig 中添加 include
{
"compilerOptions":{},
"include": ["node_modules/@json_web_component/infinitscrollpagination/dist/global.d.ts"],
}
// react 使用问题
// 如果ts报错: Property 'infinit-scroll' does not exist on type 'JSX.IntrinsicElements'.
// 1. 创建一个全局类型文件 例如 global.d.ts
// 2. 在tsconfig 中include 中加入该全局类型文件
// 该全局文件的内容如下:
declare namespace JSX {
interface IntrinsicElements {
'infinit-scroll': React.DetailedHTMLProps<InfinitScrollPaginationProps, HTMLElement>;
}
}
// 如果需要在定义当前元素的ref类型
// vue
const cusref = ref<InfinitScrollPaginationElement | null>(null);
// react
const cusref = useRef<InfinitScrollPaginationElement | null>(null)
FAQs
一个国际化的web component库, 可无感切换语言; An internationalized web component library with senseless language switching.
The npm package @json_web_component/infinitscrollpagination receives a total of 2 weekly downloads. As such, @json_web_component/infinitscrollpagination popularity was classified as not popular.
We found that @json_web_component/infinitscrollpagination demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.