Skip to content

Commit

Permalink
feat: 调整代码结构,模块化组织子组件
Browse files Browse the repository at this point in the history
  • Loading branch information
yaohaixiao committed Sep 4, 2024
1 parent 28f81dc commit be5f17e
Show file tree
Hide file tree
Showing 132 changed files with 5,864 additions and 5,043 deletions.
34 changes: 0 additions & 34 deletions anchors.css

This file was deleted.

2 changes: 0 additions & 2 deletions anchors.min.css

This file was deleted.

2 changes: 0 additions & 2 deletions anchors.min.js

This file was deleted.

1 change: 0 additions & 1 deletion anchors.min.js.map

This file was deleted.

1 change: 1 addition & 0 deletions anchors/anchors.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 29 additions & 22 deletions anchors.js → anchors/anchors.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
import isString from './utils/types/isString'
import isFunction from './utils/types/isFunction'
import isElement from './utils/types/isElement'
import cloneDeep from './utils/lang/cloneDeep'
import timeSlice from './utils/lang/timeSlice'
import later from './utils/lang/later'
import scrollTo from './utils/dom/scrollTo'
import _getScrollElement from './utils/dom/_getScrollElement'
import offsetTop from './utils/dom/offsetTop'
import on from './utils/event/on'
import off from './utils/event/off'
import stop from './utils/event/stop'
import paint from './utils/icons/paint'

import _updateHeading from './_updateHeading'
import _removeHeading from './_removeHeading'
import getChapters from './getChapters'

import Base from './base'

class Anchors extends Base {
import isString from '@/utils/types/isString'
import isFunction from '@/utils/types/isFunction'
import isElement from '@/utils/types/isElement'

import cloneDeep from '@/utils/lang/cloneDeep'
import timeSlice from '@/utils/lang/timeSlice'
import later from '@/utils/lang/later'

import scrollTo from '@/utils/dom/scrollTo'
import getScrollElement from '@/utils/dom/getScrollElement'
import offsetTop from '@/utils/dom/offsetTop'

import on from '@/utils/event/on'
import off from '@/utils/event/off'
import stop from '@/utils/event/stop'

import paint from '@/utils/icons/paint'

import getChapters from '@/chapters/getChapters'

import Component from '@/component'

import _updateHeading from './utils/_updateHeading'
import _removeHeading from './utils/_removeHeading'

import './anchors.less'

class Anchors extends Component {
constructor(options) {
super()

Expand Down Expand Up @@ -62,7 +69,7 @@ class Anchors extends Base {
}

this.$articleElement = $articleElement
this.$scrollElement = _getScrollElement(scrollElement)
this.$scrollElement = getScrollElement(scrollElement)
this.$headings = this.getHeadings()

if (this.$headings.length < 1) {
Expand Down
42 changes: 42 additions & 0 deletions anchors/anchors.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@import '../theme/colors';

.outline-heading {
position: relative;
z-index: 1;
overflow: hidden;

&__anchor {
display: none;

&:link,
&:visited,
&:hover {
color: @fourth_text_color;
text-decoration: none;
}

&:hover {
color: @primary_color;
}
}

&:hover {
.outline-heading__anchor {
display: inline-block;
}
}

&_start {
&:hover {
overflow: visible;
}

.outline-heading__anchor {
position: absolute;
z-index: 2;
top: 50%;
transform: translateY(-50%);
left: -1em;
}
}
}
Loading

0 comments on commit be5f17e

Please sign in to comment.