Code Monkey home page Code Monkey logo

alphabet-sidenav's Introduction

通讯录样式的边栏字母导航

简介

创建一个通讯录边栏样式的字母导航

导航

DEMO

请扫描二维码在移动设备上查看

DEMO

使用

1.模块化调用

使用 browserify 或 seajs 等模块加载器,引入alphabetnav

var alphabetNav = require('alphabetnav');
alphabetNav.init("attrName");

2.使用script标签全局引用

<script type="text/javascript" src="script/alphabetNav.js"></script>
<script type="text/javascript">
	alphabetNav.init("attrName");
</script>

3.方法调用1(推荐)

alphabetNav.init("attrName",{options})

其中,attrName 为属性名,options 为配置项。元素属性名的对应属性值将作为导航显示内容。该调用方式下 URL Hash 跳转特性不可用。

DEMO:

<section nav="A">
<section nav="B">
……
<section nav="Z">

<script type="text/javascript">
alphabetNav.init("nav");
</script>

3.方法调用2

alphabetNav.init([navItem],{options})

其中,navItem 为对象数组,对象包括 display 和 id 两个属性,display 为导航显示名称,id 为对应页面锚点名称。

DEMO:

<section id="a">
<section id="b">
<section id="c">

<script type="text/javascript">
alphabetNav.init([
		{display:"A", id:"a"},
		{display:"B", id:"b"},
		{display:"C", id:"c"}
		]);
</script>

配置项

options 可选配置包括:

  • top:数字或字符串,设置边栏的 top 属性。
  • bottom:数字或字符串,设置边栏的 bottom 属性,top 和 bottom 均没有配置时,slideNav 将居中显示。
  • showIndicator:布尔型,默认值 true,设置是否显示字母指示器。
  • useHash:布尔型,默认值 false,是否使用 URLHash 进行跳转。注意使用 URLHash 进行跳转时,只在 URLHash 改变时跳转才会发生,这将导致某些情况下不能跳转到正确位置

alphabet-sidenav's People

Contributors

coolzjy avatar katherina-miao avatar

Watchers

朝夕 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.