or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
前言
聽到 收費廣告版位 最常想到的就是 Google Adsense,開發者可以在自己的網站上找位置串接 API,之後選擇廣告曝光來獲取收益,但這篇不是想討論如何串接,而是背後是如何觸發計價收費的,以及如果要自制站內廣告賣給廠商該如何實作。
常需要判定曝光定價的兩大邏輯
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →本篇的小調整
這篇是說明 IntersectionObserver 應用的尾篇,為了更接近工作方式,所以改採用現成的 Component 套件來嘗試實作,並試著使用 Code Sandbox 來 Demo 案例。接下來分享搜集資料過程中看到兩個套件的實作方式。
react-intersection-observer
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →發現此 Component README 寫得超級詳細的,甚至連 Intersection Observer 技術都有詳細圖解,看到心裡總是想著
那我幹嘛還寫那麼多這世上很溫暖呢解說案例:可見度百分比 threshold 偵測
參數設定
root
:未指定,使用預設裝置 viewportrootMargin
:未指定,使用當前 viewport 邊界threshold
:設定 [0, 0.25, 0.5, 0.75, 1] 五個 step,顯示達到這些數值則觸發事件disabled
:未指定,預設不封鎖onChnage
:變更 Nav 顏色及取得 intersectionRatio 顯示比例children
:填入會被 Observe 的元件(畫面黑色區塊)特性一:threshold 與 intersectionRatio
這個不是套件的特定,是 IntersectionOberser 原生的實作就會有的問題,原因是滾動 scrollbar 一個單位是不會無限切割的,多顯示或少顯示的元件比例不一定會剛好等於 threshold 的設定值,而是當 intersectionRatio 越過這個值時,去觸發事件。
特性二:Observer元件不會出現 DOM 物件
收費廣告版位應用
常需要判定曝光定價的兩大邏輯
步驟1:規劃 Component 介面
Props
State
串接成畫面測試看看
Hook
小結
參考資料
* react-intersection-observer
*