Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

feat(anchor): 锚点组件增加固定模式,修复示例文档bug问题 #21

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/anchor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { addClass, removeClass } from '@opentiny/vue-renderless/common/deps/dom'


const setFixAnchor = ({ vm }) => {
const { anchorRef } = vm.$refs
if (anchorRef) {
anchorRef.style.position = 'fixed'
anchorRef.style.top = anchorRef.offsetTop
const { fixRef } = vm.$refs
if (fixRef) {
fixRef.style.position = 'fixed'
fixRef.style.top = fixRef.offsetTop
}
}

Expand Down Expand Up @@ -46,7 +46,7 @@ const setScrollContainer = ({ state, api, cb = null }) => {

const updateSkidPosition = ({ vm, state, emit }) => {
const { currentLink } = state
const activeEl = document.querySelector(`a[href='${currentLink}']`)
const activeEl = vm.$refs[currentLink]
const { skidRef, maskRef, anchorRef } = vm.$refs

if (!activeEl || !anchorRef) {
Expand Down