Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix anchor link positioning #283

Closed
wants to merge 1 commit into from
Closed

Conversation

qjebbs
Copy link

@qjebbs qjebbs commented Feb 10, 2023

Suppose we have an article:

# header1
any text...
![](img1.png)

# header2
any text...
![](img2.png)

# header3
any text...
![](img3.png)

Now we want to visitor the anchor link: See also [header3](https://host/page#header3), which is very common in a document site.

Because of the lazysize.js, the Browser cannot detect the real sizes of img1, img2:

  1. The Browser scroll to #header3
  2. lazysize.js runs, updates img1, img2
  3. Updated img1, img2 push the scroll position, users can not find the expected #header3 title.

Standard MarkDown syntax of image supports only one image, which means we don't need lazysize.js in most cases, this is what this PR does to fix anchor link positioning.

Suppose we have an article:

```md
# header1
any text...
![](img1.png)

# header2
any text...
![](img2.png)

# header3
any text...
![](img3.png)
```

Now we want to visitor the anchor link: `See also [header3](https://host/page#header3)`, which is very common in a document site.

Because of the `lazysize.js`, the Browser cannot detect the real sizes of `img1`, `img2`:

1. The Browser scroll to `#header3`
1. `lazysize.js` runs, updates `img1`, `img2`
1. Updated `img1`, `img2` push the scroll position, users can not find the expected `#header3` title.

Standard MarkDown syntax of image supports only one image, which means we don't need `lazysize.js` in most cases, this is what this PR does to fix anchor link positioning.
@vercel
Copy link

vercel bot commented Feb 10, 2023

@qjebbs is attempting to deploy a commit to the FixIt Team on Vercel.

A member of the Team first needs to authorize it.

@Lruihao
Copy link
Member

Lruihao commented Feb 10, 2023

I'm also aware of this bug, your handling solves the problem, but also gives up the lazy loading feature of images.
Let me see, there should be a better way to fix the bug.

@Lruihao Lruihao self-assigned this Feb 10, 2023
@Lruihao Lruihao added the bug Something isn't working label Feb 10, 2023
@Lruihao Lruihao added this to the v0.2.18 milestone Feb 10, 2023
@Lruihao
Copy link
Member

Lruihao commented Feb 10, 2023

I want to use native lazy loading and remove lazysize.js.

@qjebbs
Copy link
Author

qjebbs commented Feb 10, 2023

I want to use native lazy loading and remove lazysize.js.

I'm looking forward to it. Should I close this PR now?

@Lruihao
Copy link
Member

Lruihao commented Feb 10, 2023

I'm looking forward to it. Should I close this PR now?

yes

@qjebbs qjebbs closed this Feb 10, 2023
Lruihao added a commit that referenced this pull request Feb 10, 2023
Lruihao added a commit that referenced this pull request Feb 10, 2023
@Lruihao
Copy link
Member

Lruihao commented Feb 10, 2023

fixed via 934c57c, preview demo

@qjebbs
Copy link
Author

qjebbs commented Feb 11, 2023

fixed via 934c57c, preview demo

Confirmed to fix the issue, thanks!

@qjebbs
Copy link
Author

qjebbs commented Feb 13, 2023

fixed via 934c57c, preview demo

抱歉,似乎还有个小问题。

我的 config/production/config.yaml 如下:

baseURL: "/docs/"

即整个站点发布在 https://host/docs/ 子路径下,但图片的加载背景请求的是 https://host/svg/loading.min.svg,预期应该是 https://host/docs/svg/loading.min.svg

@Lruihao
Copy link
Member

Lruihao commented Feb 13, 2023

fixed via 934c57c, preview demo

抱歉,似乎还有个小问题。

我的 config/production/config.yaml 如下:

baseURL: "/docs/"

即整个站点发布在 https://host/docs/ 子路径下,但图片的加载背景请求的是 https://host/svg/loading.min.svg,预期应该是 https://host/docs/svg/loading.min.svg

由于scss中传递hugo参数目前还需要额外的插件,现改为style中加载loading,你更新一下最新版本

@qjebbs
Copy link
Author

qjebbs commented Feb 13, 2023

是我草率了,没尝试最新的😂。 太感谢你了,回复超快的!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants