forked from tangly1024/NotionNext
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a874467
commit 5b52bc2
Showing
6 changed files
with
56 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,36 @@ | ||
import { isBrowser } from '@/lib/utils'; | ||
import { useEffect } from 'react'; | ||
|
||
/** | ||
* 样式调整的补丁 | ||
*/ | ||
const useAdjustStyle = () => { | ||
/** | ||
/** | ||
* 避免 callout 含有图片时溢出撑开父容器 | ||
*/ | ||
const adjustCalloutImg = () => { | ||
const callOuts = document.querySelectorAll('.notion-callout-text'); | ||
callOuts.forEach((callout) => { | ||
const images = callout.querySelectorAll('figure.notion-asset-wrapper.notion-asset-wrapper-image > div'); | ||
const calloutWidth = callout.offsetWidth; | ||
images.forEach((container) => { | ||
const imageWidth = container.offsetWidth; | ||
if (imageWidth + 50 > calloutWidth) { | ||
container.style.setProperty('width', '100%'); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
if (isBrowser) { | ||
adjustCalloutImg(); | ||
window.addEventListener('resize', adjustCalloutImg); | ||
return () => { | ||
window.removeEventListener('resize', adjustCalloutImg); | ||
}; | ||
const adjustCalloutImg = () => { | ||
const callOuts = document.querySelectorAll('.notion-callout-text'); | ||
callOuts.forEach((callout) => { | ||
const images = callout.querySelectorAll('figure.notion-asset-wrapper.notion-asset-wrapper-image > div'); | ||
const calloutWidth = callout.offsetWidth; | ||
images.forEach((container) => { | ||
const imageWidth = container.offsetWidth; | ||
if (imageWidth + 50 > calloutWidth) { | ||
container.style.setProperty('width', '100%'); | ||
} | ||
}, []); | ||
}); | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
if (isBrowser) { | ||
adjustCalloutImg(); | ||
window.addEventListener('resize', adjustCalloutImg); | ||
return () => { | ||
window.removeEventListener('resize', adjustCalloutImg); | ||
}; | ||
} | ||
}, []); | ||
}; | ||
|
||
export default useAdjustStyle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const { loadExternalResource } = require('./utils'); | ||
|
||
/** | ||
* WOWjs动画,结合animate.css使用很方便 | ||
* 是data-aos的平替 aos ≈ wowjs + animate | ||
*/ | ||
export const loadWowJS = async () => { | ||
await loadExternalResource('https://cdnjs.cloudflare.com/ajax/libs/wow/1.1.2/wow.min.js', 'js'); | ||
// 配合animatecss 实现延时滚动动画,和AOS动画相似 | ||
const WOW = window.WOW; | ||
console.log('加载WOW动画', WOW) | ||
if (WOW) { | ||
new WOW().init(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters