diff --git a/examples/app.vue b/examples/app.vue
index e8cc10b..4da48f6 100644
--- a/examples/app.vue
+++ b/examples/app.vue
@@ -18,6 +18,7 @@ nav {
- Layout
- Affix
+ - Anchor
- Grid
- Button
- Input
diff --git a/examples/main.js b/examples/main.js
index 9d7c0e2..e69e585 100644
--- a/examples/main.js
+++ b/examples/main.js
@@ -28,6 +28,10 @@ const router = new VueRouter({
component: (resolve) => require(['./routers/affix.vue'], resolve)
},
{
+ path: '/anchor',
+ component: (resolve) => require(['./routers/anchor.vue'], resolve)
+ },
+ {
path: '/grid',
component: (resolve) => require(['./routers/grid.vue'], resolve)
},
diff --git a/examples/routers/anchor.vue b/examples/routers/anchor.vue
new file mode 100644
index 0000000..15e59b1
--- /dev/null
+++ b/examples/routers/anchor.vue
@@ -0,0 +1,99 @@
+
+
+
+
+
+
+ {{ `title-${i}` }}
+ {{ `title-${i}` }}
+ {{ `title-${i}` }}
+ {{ `content-row-index-${i}` }}
+
+
+ 史蒂夫·乔布斯
+ {{ index }}
+
+
+ 斯蒂夫·盖瑞·沃兹尼亚克
+ 斯蒂夫·盖瑞·沃兹尼亚克(Stephen Gary Wozniak),美国电脑工程师,曾与史蒂夫·乔布斯合伙创立苹果电脑(今之苹果公司)。斯蒂夫·盖瑞·沃兹尼亚克曾就读于美国科罗拉多大学,后转学入美国著名高等学府加州大学伯克利分校(UC Berkeley)并获得电机工程及计算机(EECS)本科学位(1987年)。
+
+
+ 乔纳森·伊夫
+ 乔纳森·伊夫是一位工业设计师,现任Apple公司设计师兼资深副总裁,英国爵士。他曾参与设计了iPod,iMac,iPhone,iPad等众多苹果产品。除了乔布斯,他是对苹果那些著名的产品最有影响力的人。
+
+
+
+
+
+
+ {{ `title-${i}` }}
+ {{ `title-${i}` }}
+ {{ `title-${i}` }}
+ {{ `content-row-index-${i}` }}
+
+
+ 史蒂夫·乔布斯
+ {{ index }}
+
+
+ 斯蒂夫·盖瑞·沃兹尼亚克
+ 斯蒂夫·盖瑞·沃兹尼亚克(Stephen Gary Wozniak),美国电脑工程师,曾与史蒂夫·乔布斯合伙创立苹果电脑(今之苹果公司)。斯蒂夫·盖瑞·沃兹尼亚克曾就读于美国科罗拉多大学,后转学入美国著名高等学府加州大学伯克利分校(UC Berkeley)并获得电机工程及计算机(EECS)本科学位(1987年)。
+
+
+ 乔纳森·伊夫
+ 乔纳森·伊夫是一位工业设计师,现任Apple公司设计师兼资深副总裁,英国爵士。他曾参与设计了iPod,iMac,iPhone,iPad等众多苹果产品。除了乔布斯,他是对苹果那些著名的产品最有影响力的人。
+
+
+
+
+
+
+
+
+
diff --git a/src/components/anchor-link/index.js b/src/components/anchor-link/index.js
new file mode 100644
index 0000000..aa60209
--- /dev/null
+++ b/src/components/anchor-link/index.js
@@ -0,0 +1,2 @@
+import AnchorLink from '../anchor/anchor-link.vue';
+export default AnchorLink;
diff --git a/src/components/anchor/anchor-link.vue b/src/components/anchor/anchor-link.vue
new file mode 100644
index 0000000..445a3f0
--- /dev/null
+++ b/src/components/anchor/anchor-link.vue
@@ -0,0 +1,45 @@
+
+
+
+
diff --git a/src/components/anchor/anchor.vue b/src/components/anchor/anchor.vue
new file mode 100644
index 0000000..38529ac
--- /dev/null
+++ b/src/components/anchor/anchor.vue
@@ -0,0 +1,189 @@
+
+
+
+
+
+
diff --git a/src/components/anchor/index.js b/src/components/anchor/index.js
new file mode 100644
index 0000000..cb29acf
--- /dev/null
+++ b/src/components/anchor/index.js
@@ -0,0 +1,2 @@
+import Anchor from './anchor.vue';
+export default Anchor;
diff --git a/src/index.js b/src/index.js
index ee7d67d..e87f217 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,5 +1,7 @@
import Affix from './components/affix';
import Alert from './components/alert';
+import Anchor from './components/anchor';
+import AnchorLink from './components/anchor-link';
import AutoComplete from './components/auto-complete';
import Avatar from './components/avatar';
import BackTop from './components/back-top';
@@ -55,6 +57,8 @@ import locale from './locale/index';
const components = {
Affix,
Alert,
+ Anchor,
+ AnchorLink,
AutoComplete,
Avatar,
BackTop,
diff --git a/src/styles/components/anchor.less b/src/styles/components/anchor.less
new file mode 100644
index 0000000..cbb47fb
--- /dev/null
+++ b/src/styles/components/anchor.less
@@ -0,0 +1,75 @@
+@anchor-prefix: ~"@{css-prefix}anchor";
+
+.@{anchor-prefix}{
+ &-wrapper{
+ background-color: @body-background;
+ overflow: auto;
+ padding-left: 4px;
+ margin-left: -4px;
+ }
+
+ &{
+ position: relative;
+ padding-left: @anchor-border-width;
+
+ &-ink {
+ position: absolute;
+ height: 100%;
+ left: 0;
+ top: 0;
+ &:before {
+ content: ' ';
+ position: relative;
+ width: @anchor-border-width;
+ height: 100%;
+ display: block;
+ background-color: @border-color-split;
+ margin: 0 auto;
+ }
+ &-ball {
+ display: inline-block;
+ position: absolute;
+ width: 8px;
+ height: 8px;
+ border-radius: 8px;
+ border: 2px solid @primary-color;
+ background-color: @body-background;
+ left: 50%;
+ transition: top .3s ease-in-out;
+ transform: translate(-50%, 2px);
+ }
+ }
+
+ &.fixed &-ink &-ink-ball {
+ display: none;
+ }
+ }
+
+ &-link {
+ padding: 8px 0 8px 16px;
+ line-height: 1;
+
+ &-title {
+ display: block;
+ position: relative;
+ transition: all .3s;
+ color: @text-color;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ margin-bottom: 8px;
+ &:only-child {
+ margin-bottom: 0;
+ }
+ }
+
+ &-active > &-title {
+ color: @primary-color;
+ }
+ }
+
+ &-link &-link {
+ padding-top: 6px;
+ padding-bottom: 6px;
+ }
+}
diff --git a/src/styles/components/index.less b/src/styles/components/index.less
index cb877ad..2e1b46e 100644
--- a/src/styles/components/index.less
+++ b/src/styles/components/index.less
@@ -44,3 +44,4 @@
@import "avatar";
@import "color-picker";
@import "auto-complete";
+@import "anchor";
diff --git a/src/styles/custom.less b/src/styles/custom.less
index b47c345..954efb9 100644
--- a/src/styles/custom.less
+++ b/src/styles/custom.less
@@ -184,4 +184,7 @@
@avatar-font-size-sm: 14px;
@avatar-bg: #ccc;
@avatar-color: #fff;
-@avatar-border-radius: @border-radius-small;
\ No newline at end of file
+@avatar-border-radius: @border-radius-small;
+
+// Anchor
+@anchor-border-width: 2px;
diff --git a/src/utils/assist.js b/src/utils/assist.js
index b7b7388..91cf3de 100644
--- a/src/utils/assist.js
+++ b/src/utils/assist.js
@@ -138,7 +138,7 @@ function deepCopy(data) {
export {deepCopy};
// scrollTop animation
-export function scrollTop(el, from = 0, to, duration = 500) {
+export function scrollTop(el, from = 0, to, duration = 500, endCallback) {
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = (
window.webkitRequestAnimationFrame ||
@@ -153,7 +153,10 @@ export function scrollTop(el, from = 0, to, duration = 500) {
const step = Math.ceil(difference / duration * 50);
function scroll(start, end, step) {
- if (start === end) return;
+ if (start === end) {
+ endCallback && endCallback();
+ return;
+ }
let d = (start + step > end) ? end : start + step;
if (start > end) {
@@ -322,3 +325,5 @@ export function setMatchMedia () {
window.matchMedia = window.matchMedia || matchMediaPolyfill;
}
}
+
+export const sharpMatcherRegx = /#([^#]+)$/;
diff --git a/src/utils/dom.js b/src/utils/dom.js
index 7f578e2..26a228e 100644
--- a/src/utils/dom.js
+++ b/src/utils/dom.js
@@ -33,4 +33,4 @@ export const off = (function() {
}
};
}
-})();
\ No newline at end of file
+})();
--
libgit2 0.21.4