vevet 5.1.4 → 5.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cdn/vevet.iife.min.js +13 -9
- package/lib/cjs/base/Callbacks/index.js +31 -3
- package/lib/cjs/base/Callbacks/index.js.map +1 -1
- package/lib/cjs/base/Module/index.js +40 -9
- package/lib/cjs/base/Module/index.js.map +1 -1
- package/lib/cjs/base/Responsive/index.js +10 -3
- package/lib/cjs/base/Responsive/index.js.map +1 -1
- package/lib/cjs/components/Canvas/index.js +19 -4
- package/lib/cjs/components/Canvas/index.js.map +1 -1
- package/lib/cjs/components/CanvasMedia/index.js +15 -2
- package/lib/cjs/components/CanvasMedia/index.js.map +1 -1
- package/lib/cjs/components/Cursor/index.js +54 -29
- package/lib/cjs/components/Cursor/index.js.map +1 -1
- package/lib/cjs/components/Cursor/styles.js +4 -3
- package/lib/cjs/components/Cursor/styles.js.map +1 -1
- package/lib/cjs/components/InView/index.js +17 -3
- package/lib/cjs/components/InView/index.js.map +1 -1
- package/lib/cjs/components/Marquee/index.js +47 -29
- package/lib/cjs/components/Marquee/index.js.map +1 -1
- package/lib/cjs/components/Pointers/index.js +4 -4
- package/lib/cjs/components/Pointers/index.js.map +1 -1
- package/lib/cjs/components/Pointers/styles.js +2 -1
- package/lib/cjs/components/Pointers/styles.js.map +1 -1
- package/lib/cjs/components/Preloader/index.js +16 -5
- package/lib/cjs/components/Preloader/index.js.map +1 -1
- package/lib/cjs/components/ProgressPreloader/index.js +23 -14
- package/lib/cjs/components/ProgressPreloader/index.js.map +1 -1
- package/lib/cjs/components/Raf/index.js +16 -3
- package/lib/cjs/components/Raf/index.js.map +1 -1
- package/lib/cjs/components/ScrollProgress/index.js +12 -2
- package/lib/cjs/components/ScrollProgress/index.js.map +1 -1
- package/lib/cjs/components/Scrollbar/index.js +45 -25
- package/lib/cjs/components/Scrollbar/index.js.map +1 -1
- package/lib/cjs/components/Scrollbar/styles.js +3 -2
- package/lib/cjs/components/Scrollbar/styles.js.map +1 -1
- package/lib/cjs/components/Snap/Slide/index.js +18 -1
- package/lib/cjs/components/Snap/Slide/index.js.map +1 -1
- package/lib/cjs/components/Snap/SlideParallax/constants.js +101 -0
- package/lib/cjs/components/Snap/SlideParallax/constants.js.map +1 -0
- package/lib/cjs/components/Snap/SlideParallax/globals.js +5 -0
- package/lib/cjs/components/Snap/SlideParallax/globals.js.map +1 -0
- package/lib/cjs/components/Snap/SlideParallax/index.js +145 -0
- package/lib/cjs/components/Snap/SlideParallax/index.js.map +1 -0
- package/lib/cjs/components/Snap/SlideParallax/types.js +3 -0
- package/lib/cjs/components/Snap/SlideParallax/types.js.map +1 -0
- package/lib/cjs/components/Snap/Swipe/index.js +6 -4
- package/lib/cjs/components/Snap/Swipe/index.js.map +1 -1
- package/lib/cjs/components/Snap/Track/index.js +35 -6
- package/lib/cjs/components/Snap/Track/index.js.map +1 -1
- package/lib/cjs/components/Snap/Wheel/index.js +2 -1
- package/lib/cjs/components/Snap/Wheel/index.js.map +1 -1
- package/lib/cjs/components/Snap/index.js +30 -16
- package/lib/cjs/components/Snap/index.js.map +1 -1
- package/lib/cjs/components/SplitText/index.js +20 -6
- package/lib/cjs/components/SplitText/index.js.map +1 -1
- package/lib/cjs/components/SplitText/utils/isIgnored.js +2 -1
- package/lib/cjs/components/SplitText/utils/isIgnored.js.map +1 -1
- package/lib/cjs/components/SplitText/utils/saveInitialNodes.js +2 -1
- package/lib/cjs/components/SplitText/utils/saveInitialNodes.js.map +1 -1
- package/lib/cjs/components/SplitText/utils/splitBase.js +26 -8
- package/lib/cjs/components/SplitText/utils/splitBase.js.map +1 -1
- package/lib/cjs/components/SplitText/utils/wrapLetters.js +5 -3
- package/lib/cjs/components/SplitText/utils/wrapLetters.js.map +1 -1
- package/lib/cjs/components/SplitText/utils/wrapLines.js +7 -5
- package/lib/cjs/components/SplitText/utils/wrapLines.js.map +1 -1
- package/lib/cjs/components/SplitText/utils/wrapWords.js +12 -9
- package/lib/cjs/components/SplitText/utils/wrapWords.js.map +1 -1
- package/lib/cjs/components/Swipe/index.js +22 -13
- package/lib/cjs/components/Swipe/index.js.map +1 -1
- package/lib/cjs/components/Swipe/styles.js +2 -1
- package/lib/cjs/components/Swipe/styles.js.map +1 -1
- package/lib/cjs/components/Timeline/index.js +25 -11
- package/lib/cjs/components/Timeline/index.js.map +1 -1
- package/lib/cjs/core/handlers/createPageLoad/index.js +6 -5
- package/lib/cjs/core/handlers/createPageLoad/index.js.map +1 -1
- package/lib/cjs/core/handlers/createViewport/index.js +43 -20
- package/lib/cjs/core/handlers/createViewport/index.js.map +1 -1
- package/lib/cjs/core/index.js +12 -8
- package/lib/cjs/core/index.js.map +1 -1
- package/lib/cjs/global/initVevet.js +2 -1
- package/lib/cjs/global/initVevet.js.map +1 -1
- package/lib/cjs/index.js +2 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/internal/cn.js +19 -0
- package/lib/cjs/internal/cn.js.map +1 -0
- package/lib/cjs/internal/env.js +8 -0
- package/lib/cjs/internal/env.js.map +1 -0
- package/lib/cjs/internal/isNumber.js +7 -0
- package/lib/cjs/internal/isNumber.js.map +1 -0
- package/lib/cjs/internal/isString.js +7 -0
- package/lib/cjs/internal/isString.js.map +1 -0
- package/lib/cjs/internal/isUndefined.js +7 -0
- package/lib/cjs/internal/isUndefined.js.map +1 -0
- package/lib/cjs/internal/noopIfDestroyed.js +20 -0
- package/lib/cjs/internal/noopIfDestroyed.js.map +1 -0
- package/lib/cjs/internal/textDirection.js +7 -0
- package/lib/cjs/internal/textDirection.js.map +1 -0
- package/lib/cjs/manifest.json +1 -1
- package/lib/cjs/utils/common/toPixels.js +4 -3
- package/lib/cjs/utils/common/toPixels.js.map +1 -1
- package/lib/esm/base/Callbacks/index.js +30 -3
- package/lib/esm/base/Callbacks/index.js.map +1 -1
- package/lib/esm/base/Module/index.js +37 -9
- package/lib/esm/base/Module/index.js.map +1 -1
- package/lib/esm/base/Responsive/index.js +10 -3
- package/lib/esm/base/Responsive/index.js.map +1 -1
- package/lib/esm/components/Canvas/index.js +19 -4
- package/lib/esm/components/Canvas/index.js.map +1 -1
- package/lib/esm/components/CanvasMedia/index.js +15 -2
- package/lib/esm/components/CanvasMedia/index.js.map +1 -1
- package/lib/esm/components/Cursor/index.js +54 -29
- package/lib/esm/components/Cursor/index.js.map +1 -1
- package/lib/esm/components/Cursor/styles.js +7 -2
- package/lib/esm/components/Cursor/styles.js.map +1 -1
- package/lib/esm/components/InView/index.js +17 -3
- package/lib/esm/components/InView/index.js.map +1 -1
- package/lib/esm/components/Marquee/index.js +47 -29
- package/lib/esm/components/Marquee/index.js.map +1 -1
- package/lib/esm/components/Pointers/index.js +4 -4
- package/lib/esm/components/Pointers/index.js.map +1 -1
- package/lib/esm/components/Pointers/styles.js +2 -1
- package/lib/esm/components/Pointers/styles.js.map +1 -1
- package/lib/esm/components/Preloader/index.js +16 -5
- package/lib/esm/components/Preloader/index.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/index.js +23 -14
- package/lib/esm/components/ProgressPreloader/index.js.map +1 -1
- package/lib/esm/components/Raf/index.js +16 -3
- package/lib/esm/components/Raf/index.js.map +1 -1
- package/lib/esm/components/ScrollProgress/index.js +12 -2
- package/lib/esm/components/ScrollProgress/index.js.map +1 -1
- package/lib/esm/components/Scrollbar/index.js +45 -25
- package/lib/esm/components/Scrollbar/index.js.map +1 -1
- package/lib/esm/components/Scrollbar/styles.js +3 -2
- package/lib/esm/components/Scrollbar/styles.js.map +1 -1
- package/lib/esm/components/Snap/Slide/index.js +18 -1
- package/lib/esm/components/Snap/Slide/index.js.map +1 -1
- package/lib/esm/components/Snap/SlideParallax/constants.js +95 -0
- package/lib/esm/components/Snap/SlideParallax/constants.js.map +1 -0
- package/lib/esm/components/Snap/SlideParallax/globals.js +2 -0
- package/lib/esm/components/Snap/SlideParallax/globals.js.map +1 -0
- package/lib/esm/components/Snap/SlideParallax/index.js +122 -0
- package/lib/esm/components/Snap/SlideParallax/index.js.map +1 -0
- package/lib/esm/components/Snap/SlideParallax/types.js +2 -0
- package/lib/esm/components/Snap/SlideParallax/types.js.map +1 -0
- package/lib/esm/components/Snap/Swipe/index.js +6 -4
- package/lib/esm/components/Snap/Swipe/index.js.map +1 -1
- package/lib/esm/components/Snap/Track/index.js +31 -6
- package/lib/esm/components/Snap/Track/index.js.map +1 -1
- package/lib/esm/components/Snap/Wheel/index.js +2 -1
- package/lib/esm/components/Snap/Wheel/index.js.map +1 -1
- package/lib/esm/components/Snap/index.js +30 -16
- package/lib/esm/components/Snap/index.js.map +1 -1
- package/lib/esm/components/SplitText/index.js +20 -6
- package/lib/esm/components/SplitText/index.js.map +1 -1
- package/lib/esm/components/SplitText/utils/isIgnored.js +2 -1
- package/lib/esm/components/SplitText/utils/isIgnored.js.map +1 -1
- package/lib/esm/components/SplitText/utils/saveInitialNodes.js +2 -1
- package/lib/esm/components/SplitText/utils/saveInitialNodes.js.map +1 -1
- package/lib/esm/components/SplitText/utils/splitBase.js +16 -8
- package/lib/esm/components/SplitText/utils/splitBase.js.map +1 -1
- package/lib/esm/components/SplitText/utils/wrapLetters.js +5 -3
- package/lib/esm/components/SplitText/utils/wrapLetters.js.map +1 -1
- package/lib/esm/components/SplitText/utils/wrapLines.js +7 -5
- package/lib/esm/components/SplitText/utils/wrapLines.js.map +1 -1
- package/lib/esm/components/SplitText/utils/wrapWords.js +13 -10
- package/lib/esm/components/SplitText/utils/wrapWords.js.map +1 -1
- package/lib/esm/components/Swipe/index.js +22 -13
- package/lib/esm/components/Swipe/index.js.map +1 -1
- package/lib/esm/components/Swipe/styles.js +2 -1
- package/lib/esm/components/Swipe/styles.js.map +1 -1
- package/lib/esm/components/Timeline/index.js +25 -11
- package/lib/esm/components/Timeline/index.js.map +1 -1
- package/lib/esm/core/handlers/createPageLoad/index.js +6 -5
- package/lib/esm/core/handlers/createPageLoad/index.js.map +1 -1
- package/lib/esm/core/handlers/createViewport/index.js +43 -20
- package/lib/esm/core/handlers/createViewport/index.js.map +1 -1
- package/lib/esm/core/index.js +16 -8
- package/lib/esm/core/index.js.map +1 -1
- package/lib/esm/global/initVevet.js +2 -1
- package/lib/esm/global/initVevet.js.map +1 -1
- package/lib/esm/index.js +2 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/internal/cn.js +13 -0
- package/lib/esm/internal/cn.js.map +1 -0
- package/lib/esm/internal/env.js +5 -0
- package/lib/esm/internal/env.js.map +1 -0
- package/lib/esm/internal/isNumber.js +4 -0
- package/lib/esm/internal/isNumber.js.map +1 -0
- package/lib/esm/internal/isString.js +4 -0
- package/lib/esm/internal/isString.js.map +1 -0
- package/lib/esm/internal/isUndefined.js +4 -0
- package/lib/esm/internal/isUndefined.js.map +1 -0
- package/lib/esm/internal/noopIfDestroyed.js +13 -0
- package/lib/esm/internal/noopIfDestroyed.js.map +1 -0
- package/lib/esm/internal/textDirection.js +4 -0
- package/lib/esm/internal/textDirection.js.map +1 -0
- package/lib/esm/manifest.json +1 -1
- package/lib/esm/utils/common/toPixels.js +3 -2
- package/lib/esm/utils/common/toPixels.js.map +1 -1
- package/lib/types/base/Callbacks/index.d.ts +9 -5
- package/lib/types/base/Callbacks/index.d.ts.map +1 -1
- package/lib/types/base/Callbacks/types.d.ts +9 -5
- package/lib/types/base/Callbacks/types.d.ts.map +1 -1
- package/lib/types/base/Module/index.d.ts +5 -5
- package/lib/types/base/Module/index.d.ts.map +1 -1
- package/lib/types/base/Module/types.d.ts +4 -1
- package/lib/types/base/Module/types.d.ts.map +1 -1
- package/lib/types/base/Responsive/index.d.ts.map +1 -1
- package/lib/types/base/Responsive/types.d.ts +2 -2
- package/lib/types/base/Responsive/types.d.ts.map +1 -1
- package/lib/types/components/Canvas/index.d.ts +5 -5
- package/lib/types/components/Canvas/index.d.ts.map +1 -1
- package/lib/types/components/CanvasMedia/index.d.ts +5 -4
- package/lib/types/components/CanvasMedia/index.d.ts.map +1 -1
- package/lib/types/components/Cursor/index.d.ts +5 -5
- package/lib/types/components/Cursor/index.d.ts.map +1 -1
- package/lib/types/components/Cursor/styles.d.ts.map +1 -1
- package/lib/types/components/InView/index.d.ts +5 -5
- package/lib/types/components/InView/index.d.ts.map +1 -1
- package/lib/types/components/InView/types.d.ts.map +1 -1
- package/lib/types/components/Marquee/index.d.ts +5 -5
- package/lib/types/components/Marquee/index.d.ts.map +1 -1
- package/lib/types/components/Pointers/index.d.ts +5 -5
- package/lib/types/components/Pointers/index.d.ts.map +1 -1
- package/lib/types/components/Pointers/styles.d.ts.map +1 -1
- package/lib/types/components/Preloader/index.d.ts +5 -5
- package/lib/types/components/Preloader/index.d.ts.map +1 -1
- package/lib/types/components/ProgressPreloader/index.d.ts +5 -4
- package/lib/types/components/ProgressPreloader/index.d.ts.map +1 -1
- package/lib/types/components/Raf/index.d.ts +5 -5
- package/lib/types/components/Raf/index.d.ts.map +1 -1
- package/lib/types/components/ScrollProgress/index.d.ts +5 -5
- package/lib/types/components/ScrollProgress/index.d.ts.map +1 -1
- package/lib/types/components/Scrollbar/index.d.ts +7 -5
- package/lib/types/components/Scrollbar/index.d.ts.map +1 -1
- package/lib/types/components/Scrollbar/styles.d.ts.map +1 -1
- package/lib/types/components/Snap/Slide/index.d.ts +5 -0
- package/lib/types/components/Snap/Slide/index.d.ts.map +1 -1
- package/lib/types/components/Snap/SlideParallax/constants.d.ts +7 -0
- package/lib/types/components/Snap/SlideParallax/constants.d.ts.map +1 -0
- package/lib/types/components/Snap/SlideParallax/globals.d.ts +2 -0
- package/lib/types/components/Snap/SlideParallax/globals.d.ts.map +1 -0
- package/lib/types/components/Snap/SlideParallax/index.d.ts +25 -0
- package/lib/types/components/Snap/SlideParallax/index.d.ts.map +1 -0
- package/lib/types/components/Snap/SlideParallax/types.d.ts +22 -0
- package/lib/types/components/Snap/SlideParallax/types.d.ts.map +1 -0
- package/lib/types/components/Snap/Swipe/index.d.ts.map +1 -1
- package/lib/types/components/Snap/Swipe/types.d.ts +1 -6
- package/lib/types/components/Snap/Swipe/types.d.ts.map +1 -1
- package/lib/types/components/Snap/Track/index.d.ts +10 -1
- package/lib/types/components/Snap/Track/index.d.ts.map +1 -1
- package/lib/types/components/Snap/Wheel/index.d.ts.map +1 -1
- package/lib/types/components/Snap/index.d.ts +5 -5
- package/lib/types/components/Snap/index.d.ts.map +1 -1
- package/lib/types/components/Snap/types.d.ts +1 -1
- package/lib/types/components/SplitText/index.d.ts +5 -5
- package/lib/types/components/SplitText/index.d.ts.map +1 -1
- package/lib/types/components/SplitText/types.d.ts +27 -0
- package/lib/types/components/SplitText/types.d.ts.map +1 -1
- package/lib/types/components/SplitText/utils/isIgnored.d.ts.map +1 -1
- package/lib/types/components/SplitText/utils/saveInitialNodes.d.ts.map +1 -1
- package/lib/types/components/SplitText/utils/splitBase.d.ts +3 -3
- package/lib/types/components/SplitText/utils/splitBase.d.ts.map +1 -1
- package/lib/types/components/SplitText/utils/wrapLetters.d.ts.map +1 -1
- package/lib/types/components/SplitText/utils/wrapLines.d.ts.map +1 -1
- package/lib/types/components/SplitText/utils/wrapWords.d.ts +3 -3
- package/lib/types/components/SplitText/utils/wrapWords.d.ts.map +1 -1
- package/lib/types/components/Swipe/index.d.ts +5 -5
- package/lib/types/components/Swipe/index.d.ts.map +1 -1
- package/lib/types/components/Swipe/styles.d.ts.map +1 -1
- package/lib/types/components/Swipe/types.d.ts +10 -0
- package/lib/types/components/Swipe/types.d.ts.map +1 -1
- package/lib/types/components/Timeline/index.d.ts +5 -5
- package/lib/types/components/Timeline/index.d.ts.map +1 -1
- package/lib/types/core/global.d.ts +4 -0
- package/lib/types/core/global.d.ts.map +1 -1
- package/lib/types/core/handlers/createPageLoad/index.d.ts.map +1 -1
- package/lib/types/core/handlers/createViewport/index.d.ts +2 -1
- package/lib/types/core/handlers/createViewport/index.d.ts.map +1 -1
- package/lib/types/core/index.d.ts.map +1 -1
- package/lib/types/global/initVevet.d.ts.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/internal/cn.d.ts +5 -0
- package/lib/types/internal/cn.d.ts.map +1 -0
- package/lib/types/internal/env.d.ts +5 -0
- package/lib/types/internal/env.d.ts.map +1 -0
- package/lib/types/internal/isNumber.d.ts +2 -0
- package/lib/types/internal/isNumber.d.ts.map +1 -0
- package/lib/types/internal/isString.d.ts +2 -0
- package/lib/types/internal/isString.d.ts.map +1 -0
- package/lib/types/internal/isUndefined.d.ts +2 -0
- package/lib/types/internal/isUndefined.d.ts.map +1 -0
- package/lib/types/internal/noopIfDestroyed.d.ts +2 -0
- package/lib/types/internal/noopIfDestroyed.d.ts.map +1 -0
- package/lib/types/internal/textDirection.d.ts +2 -0
- package/lib/types/internal/textDirection.d.ts.map +1 -0
- package/lib/types/utils/common/toPixels.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/base/Callbacks/index.ts +26 -7
- package/src/base/Callbacks/types.ts +12 -7
- package/src/base/Module/index.ts +44 -12
- package/src/base/Module/types.ts +5 -1
- package/src/base/Responsive/index.ts +2 -4
- package/src/base/Responsive/types.ts +4 -5
- package/src/components/Canvas/index.ts +21 -13
- package/src/components/CanvasMedia/index.ts +17 -10
- package/src/components/Cursor/index.ts +56 -38
- package/src/components/Cursor/styles.ts +8 -2
- package/src/components/InView/index.ts +19 -12
- package/src/components/InView/types.ts +2 -6
- package/src/components/Marquee/index.ts +50 -39
- package/src/components/Pointers/index.ts +16 -13
- package/src/components/Pointers/styles.ts +3 -2
- package/src/components/Preloader/index.ts +31 -14
- package/src/components/ProgressPreloader/index.ts +25 -27
- package/src/components/Raf/index.ts +20 -14
- package/src/components/ScrollProgress/index.ts +16 -13
- package/src/components/Scrollbar/index.ts +52 -36
- package/src/components/Scrollbar/styles.ts +4 -2
- package/src/components/Snap/Slide/index.ts +26 -0
- package/src/components/Snap/SlideParallax/constants.ts +100 -0
- package/src/components/Snap/SlideParallax/globals.ts +1 -0
- package/src/components/Snap/SlideParallax/index.ts +184 -0
- package/src/components/Snap/SlideParallax/types.ts +24 -0
- package/src/components/Snap/Swipe/index.ts +8 -4
- package/src/components/Snap/Swipe/types.ts +1 -7
- package/src/components/Snap/Track/index.ts +45 -6
- package/src/components/Snap/Wheel/index.ts +2 -1
- package/src/components/Snap/index.ts +31 -32
- package/src/components/Snap/types.ts +1 -1
- package/src/components/SplitText/index.ts +36 -15
- package/src/components/SplitText/types.ts +30 -0
- package/src/components/SplitText/utils/isIgnored.ts +2 -1
- package/src/components/SplitText/utils/saveInitialNodes.ts +3 -1
- package/src/components/SplitText/utils/splitBase.ts +10 -3
- package/src/components/SplitText/utils/wrapLetters.ts +5 -3
- package/src/components/SplitText/utils/wrapLines.ts +7 -5
- package/src/components/SplitText/utils/wrapWords.ts +29 -13
- package/src/components/Swipe/index.ts +35 -20
- package/src/components/Swipe/styles.ts +3 -2
- package/src/components/Swipe/types.ts +12 -0
- package/src/components/Timeline/index.ts +23 -22
- package/src/core/global.ts +5 -0
- package/src/core/handlers/createPageLoad/index.ts +6 -5
- package/src/core/handlers/createViewport/index.ts +44 -21
- package/src/core/index.ts +17 -11
- package/src/global/initVevet.ts +2 -1
- package/src/index.ts +2 -3
- package/src/internal/cn.ts +15 -0
- package/src/internal/env.ts +7 -0
- package/src/internal/isNumber.ts +3 -0
- package/src/internal/isString.ts +3 -0
- package/src/internal/isUndefined.ts +3 -0
- package/src/internal/noopIfDestroyed.ts +19 -0
- package/src/internal/textDirection.ts +3 -0
- package/src/manifest.json +1 -1
- package/src/utils/common/toPixels.ts +3 -3
|
@@ -5,6 +5,23 @@ import { toPixels } from '@/utils';
|
|
|
5
5
|
export class SnapTrack {
|
|
6
6
|
constructor(protected snap: Snap) {}
|
|
7
7
|
|
|
8
|
+
/** Interpolation influence */
|
|
9
|
+
protected _influence = {
|
|
10
|
+
current: 0,
|
|
11
|
+
target: 0,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** Gets the interpolation influence */
|
|
15
|
+
get influence() {
|
|
16
|
+
return this._influence.current;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Sets the interpolation influence */
|
|
20
|
+
set influence(value: number) {
|
|
21
|
+
this._influence.current = value;
|
|
22
|
+
this._influence.target = value;
|
|
23
|
+
}
|
|
24
|
+
|
|
8
25
|
/** The current track value */
|
|
9
26
|
protected _current = 0;
|
|
10
27
|
|
|
@@ -28,13 +45,21 @@ export class SnapTrack {
|
|
|
28
45
|
|
|
29
46
|
/** Sets the target track value */
|
|
30
47
|
set target(value: number) {
|
|
48
|
+
const { domSize } = this.snap;
|
|
49
|
+
const diff = value - this._target;
|
|
50
|
+
|
|
31
51
|
this._target = value;
|
|
52
|
+
|
|
53
|
+
this._influence.target += domSize ? diff / domSize : 0;
|
|
54
|
+
this._influence.target = clamp(this._influence.target, -0.2, 0.2);
|
|
32
55
|
}
|
|
33
56
|
|
|
34
57
|
/** Set a value to current & target value instantly */
|
|
35
58
|
public set(value: number) {
|
|
36
59
|
this.current = value;
|
|
37
60
|
this.target = value;
|
|
61
|
+
this._influence.current = 0;
|
|
62
|
+
this._influence.target = 0;
|
|
38
63
|
}
|
|
39
64
|
|
|
40
65
|
/** If can loop */
|
|
@@ -65,10 +90,13 @@ export class SnapTrack {
|
|
|
65
90
|
}
|
|
66
91
|
|
|
67
92
|
/** Interpolate the current track value */
|
|
68
|
-
public lerp(
|
|
93
|
+
public lerp(initialFactor: number) {
|
|
69
94
|
let { target } = this;
|
|
70
95
|
const { snap, min, max } = this;
|
|
71
96
|
|
|
97
|
+
let lerpFactor = initialFactor;
|
|
98
|
+
const influence = this._influence;
|
|
99
|
+
|
|
72
100
|
// Edge space & resistance
|
|
73
101
|
|
|
74
102
|
if (!snap.props.loop) {
|
|
@@ -89,20 +117,31 @@ export class SnapTrack {
|
|
|
89
117
|
// Interpolate current value
|
|
90
118
|
|
|
91
119
|
const rest = Math.abs(this.current - target);
|
|
92
|
-
const fastThreshold =
|
|
120
|
+
const fastThreshold = 3;
|
|
93
121
|
|
|
94
122
|
if (rest < fastThreshold) {
|
|
95
123
|
const fastProgress = 1 - rest / fastThreshold;
|
|
96
|
-
const additionalFactor = (1 -
|
|
97
|
-
|
|
124
|
+
const additionalFactor = (1 - lerpFactor) / 15;
|
|
125
|
+
lerpFactor += additionalFactor * fastProgress;
|
|
98
126
|
}
|
|
99
127
|
|
|
100
|
-
this.current = lerp(this.current, target,
|
|
128
|
+
this.current = lerp(this.current, target, lerpFactor, 0.000001);
|
|
129
|
+
|
|
130
|
+
// Interpolate influence
|
|
131
|
+
|
|
132
|
+
influence.target = lerp(influence.target, 0, initialFactor, 0.000001);
|
|
133
|
+
|
|
134
|
+
influence.current = lerp(
|
|
135
|
+
influence.current,
|
|
136
|
+
influence.target,
|
|
137
|
+
lerpFactor,
|
|
138
|
+
0.000001,
|
|
139
|
+
);
|
|
101
140
|
}
|
|
102
141
|
|
|
103
142
|
/** Whether the track is interpolated */
|
|
104
143
|
get isInterpolated() {
|
|
105
|
-
return this.current === this.target;
|
|
144
|
+
return this.current === this.target && this._influence.current === 0;
|
|
106
145
|
}
|
|
107
146
|
|
|
108
147
|
/** Get minimum track value */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { addEventListener, clamp, normalizeWheel } from '@/utils';
|
|
2
2
|
import { Snap } from '..';
|
|
3
3
|
import { initVevet } from '@/global/initVevet';
|
|
4
|
+
import { isNumber } from '@/internal/isNumber';
|
|
4
5
|
|
|
5
6
|
const deltasCount = 6;
|
|
6
7
|
|
|
@@ -235,7 +236,7 @@ export class SnapWheel {
|
|
|
235
236
|
|
|
236
237
|
// NUMBER
|
|
237
238
|
|
|
238
|
-
if (
|
|
239
|
+
if (isNumber(wheelThrottle)) {
|
|
239
240
|
return timeDiff < wheelThrottle;
|
|
240
241
|
}
|
|
241
242
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Module } from '@/base';
|
|
1
|
+
import { Module, TModuleOnCallbacksProps } from '@/base';
|
|
2
2
|
import { Timeline } from '../Timeline';
|
|
3
3
|
import {
|
|
4
4
|
ISnapCallbacksMap,
|
|
@@ -28,15 +28,15 @@ import { SnapWheel } from './Wheel';
|
|
|
28
28
|
import { SnapSwipe } from './Swipe';
|
|
29
29
|
import { SnapTrack } from './Track';
|
|
30
30
|
import { SnapKeyboard } from './Keyboard';
|
|
31
|
+
import { noopIfDestroyed } from '@/internal/noopIfDestroyed';
|
|
32
|
+
import { isUndefined } from '@/internal/isUndefined';
|
|
33
|
+
import { isNumber } from '@/internal/isNumber';
|
|
34
|
+
import { isString } from '@/internal/isString';
|
|
31
35
|
import { initVevet } from '@/global/initVevet';
|
|
32
36
|
|
|
33
37
|
export * from './types';
|
|
34
38
|
export * from './Slide';
|
|
35
39
|
|
|
36
|
-
// todo: add examples for freemode: sticky
|
|
37
|
-
|
|
38
|
-
// todo: fix freemode with negative swipeSpeed
|
|
39
|
-
|
|
40
40
|
// todo: jsdoc
|
|
41
41
|
|
|
42
42
|
/**
|
|
@@ -50,21 +50,21 @@ export * from './Slide';
|
|
|
50
50
|
* @group Components
|
|
51
51
|
*/
|
|
52
52
|
export class Snap<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
> extends Module<
|
|
53
|
+
C extends ISnapCallbacksMap = ISnapCallbacksMap,
|
|
54
|
+
S extends ISnapStaticProps = ISnapStaticProps,
|
|
55
|
+
M extends ISnapMutableProps = ISnapMutableProps,
|
|
56
|
+
> extends Module<C, S, M> {
|
|
57
57
|
/** Retrieves the default static properties. */
|
|
58
|
-
public _getStatic(): TRequiredProps<
|
|
58
|
+
public _getStatic(): TRequiredProps<S> {
|
|
59
59
|
return {
|
|
60
60
|
...super._getStatic(),
|
|
61
61
|
eventsEmitter: null,
|
|
62
62
|
activeIndex: 0,
|
|
63
|
-
} as TRequiredProps<
|
|
63
|
+
} as TRequiredProps<S>;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/** Retrieves the default mutable properties. */
|
|
67
|
-
public _getMutable(): TRequiredProps<
|
|
67
|
+
public _getMutable(): TRequiredProps<M> {
|
|
68
68
|
return {
|
|
69
69
|
...super._getMutable(),
|
|
70
70
|
slides: false,
|
|
@@ -72,7 +72,7 @@ export class Snap<
|
|
|
72
72
|
centered: false,
|
|
73
73
|
loop: false,
|
|
74
74
|
gap: 0,
|
|
75
|
-
lerp: 0.2,
|
|
75
|
+
lerp: initVevet().mobile ? 1 : 0.2,
|
|
76
76
|
freemode: false,
|
|
77
77
|
stickOnResize: true,
|
|
78
78
|
friction: 0,
|
|
@@ -88,11 +88,10 @@ export class Snap<
|
|
|
88
88
|
shortSwipesDuration: 300,
|
|
89
89
|
shortSwipesThreshold: 30,
|
|
90
90
|
swipeFriction: false,
|
|
91
|
-
swipeLerp: initVevet().mobile ? 1 : 0.6,
|
|
92
91
|
swipeThreshold: 5,
|
|
93
92
|
swipeMinTime: 0,
|
|
94
93
|
swipeInertiaDuration: (distance) => clamp(distance, 500, 2000),
|
|
95
|
-
swipeInertiaRatio: 0.
|
|
94
|
+
swipeInertiaRatio: 0.5,
|
|
96
95
|
wheel: false,
|
|
97
96
|
wheelSpeed: 1,
|
|
98
97
|
wheelAxis: 'auto',
|
|
@@ -101,7 +100,7 @@ export class Snap<
|
|
|
101
100
|
stickOnWheelEnd: true,
|
|
102
101
|
stickOnWheelEndThreshold: 30,
|
|
103
102
|
slideSize: 'auto',
|
|
104
|
-
} as TRequiredProps<
|
|
103
|
+
} as TRequiredProps<M>;
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
/** Animation frame for smooth animations */
|
|
@@ -140,8 +139,11 @@ export class Snap<
|
|
|
140
139
|
/** Target slide index */
|
|
141
140
|
protected _targetIndex?: number;
|
|
142
141
|
|
|
143
|
-
constructor(
|
|
144
|
-
|
|
142
|
+
constructor(
|
|
143
|
+
props?: S & M,
|
|
144
|
+
onCallbacks?: TModuleOnCallbacksProps<C, Snap<C, S, M>>,
|
|
145
|
+
) {
|
|
146
|
+
super(props, onCallbacks as any);
|
|
145
147
|
|
|
146
148
|
const { container, activeIndex } = this.props;
|
|
147
149
|
|
|
@@ -213,6 +215,7 @@ export class Snap<
|
|
|
213
215
|
}
|
|
214
216
|
|
|
215
217
|
/** Request resize (handled with debounce timeout) */
|
|
218
|
+
@noopIfDestroyed
|
|
216
219
|
public resize(isManual = false) {
|
|
217
220
|
if (isManual) {
|
|
218
221
|
this._resizeHandler.resize();
|
|
@@ -342,16 +345,10 @@ export class Snap<
|
|
|
342
345
|
return;
|
|
343
346
|
}
|
|
344
347
|
|
|
345
|
-
const { track, props
|
|
346
|
-
|
|
347
|
-
// Get lerp factor
|
|
348
|
-
const lerpFactor =
|
|
349
|
-
(swipe.isSwiping || swipe.hasInertia) && props.swipeLerp
|
|
350
|
-
? props.swipeLerp
|
|
351
|
-
: props.lerp;
|
|
348
|
+
const { track, props } = this;
|
|
352
349
|
|
|
353
350
|
// Interpolate track value
|
|
354
|
-
track.lerp(this._raf.lerpFactor(
|
|
351
|
+
track.lerp(this._raf.lerpFactor(props.lerp));
|
|
355
352
|
|
|
356
353
|
// Stop raf if target reached
|
|
357
354
|
if (track.isInterpolated) {
|
|
@@ -363,6 +360,7 @@ export class Snap<
|
|
|
363
360
|
}
|
|
364
361
|
|
|
365
362
|
/** Render slides */
|
|
363
|
+
@noopIfDestroyed
|
|
366
364
|
public render(frameDuration = 0) {
|
|
367
365
|
if (this.isEmpty) {
|
|
368
366
|
return;
|
|
@@ -381,7 +379,7 @@ export class Snap<
|
|
|
381
379
|
if (
|
|
382
380
|
magnet &&
|
|
383
381
|
magnet.slide.index !== this._activeIndex &&
|
|
384
|
-
(
|
|
382
|
+
(isUndefined(this._targetIndex) ||
|
|
385
383
|
magnet.slide.index === this._targetIndex)
|
|
386
384
|
) {
|
|
387
385
|
this._activeIndex = magnet.slide.index;
|
|
@@ -508,6 +506,7 @@ export class Snap<
|
|
|
508
506
|
}
|
|
509
507
|
|
|
510
508
|
/** Stick to the nearest magnet */
|
|
509
|
+
@noopIfDestroyed
|
|
511
510
|
public stick() {
|
|
512
511
|
const { magnet } = this;
|
|
513
512
|
|
|
@@ -520,7 +519,7 @@ export class Snap<
|
|
|
520
519
|
|
|
521
520
|
/** Go to a definite coordinate */
|
|
522
521
|
public toCoord(coordinate: number, options?: ISnapTransitionArg) {
|
|
523
|
-
if (this.isEmpty) {
|
|
522
|
+
if (this.isEmpty || this.isDestroyed) {
|
|
524
523
|
return false;
|
|
525
524
|
}
|
|
526
525
|
|
|
@@ -534,8 +533,7 @@ export class Snap<
|
|
|
534
533
|
|
|
535
534
|
const durationProp = options?.duration ?? props.duration;
|
|
536
535
|
|
|
537
|
-
let duration =
|
|
538
|
-
typeof durationProp === 'number' ? durationProp : durationProp(diff);
|
|
536
|
+
let duration = isNumber(durationProp) ? durationProp : durationProp(diff);
|
|
539
537
|
if (diff === 0) {
|
|
540
538
|
duration = 0;
|
|
541
539
|
}
|
|
@@ -554,6 +552,7 @@ export class Snap<
|
|
|
554
552
|
tm.on('update', (data) => {
|
|
555
553
|
track.current = lerp(start, end, data.eased);
|
|
556
554
|
track.target = track.current;
|
|
555
|
+
track.influence *= 1 - data.progress;
|
|
557
556
|
|
|
558
557
|
if (data.progress === 1) {
|
|
559
558
|
this._targetIndex = undefined;
|
|
@@ -591,7 +590,7 @@ export class Snap<
|
|
|
591
590
|
const { isEmpty, activeIndex, slides, track, props } = this;
|
|
592
591
|
const { current, max, loopCount } = track;
|
|
593
592
|
|
|
594
|
-
if (isEmpty) {
|
|
593
|
+
if (isEmpty || this.isDestroyed) {
|
|
595
594
|
return false;
|
|
596
595
|
}
|
|
597
596
|
|
|
@@ -635,7 +634,7 @@ export class Snap<
|
|
|
635
634
|
const targetMagnetMax = targetMagnet + max;
|
|
636
635
|
const allMagnets = [targetMagnetMin, targetMagnet, targetMagnetMax];
|
|
637
636
|
|
|
638
|
-
if (
|
|
637
|
+
if (isString(direction)) {
|
|
639
638
|
const magnets = allMagnets.filter((magnet) =>
|
|
640
639
|
direction === 'next' ? magnet >= current : magnet <= current,
|
|
641
640
|
);
|
|
@@ -9,10 +9,11 @@ import {
|
|
|
9
9
|
ISplitTextStaticProps,
|
|
10
10
|
ISplitTextWordMeta,
|
|
11
11
|
} from './types';
|
|
12
|
-
import { Module } from '@/base';
|
|
12
|
+
import { Module, TModuleOnCallbacksProps } from '@/base';
|
|
13
13
|
import { TRequiredProps } from '@/internal/requiredProps';
|
|
14
14
|
import { initVevet } from '@/global/initVevet';
|
|
15
15
|
import { saveInitialNodes } from './utils/saveInitialNodes';
|
|
16
|
+
import { noopIfDestroyed } from '@/internal/noopIfDestroyed';
|
|
16
17
|
|
|
17
18
|
export * from './types';
|
|
18
19
|
|
|
@@ -32,14 +33,14 @@ export * from './types';
|
|
|
32
33
|
* @group Components
|
|
33
34
|
*/
|
|
34
35
|
export class SplitText<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
> extends Module<
|
|
36
|
+
C extends ISplitTextCallbacksMap = ISplitTextCallbacksMap,
|
|
37
|
+
S extends ISplitTextStaticProps = ISplitTextStaticProps,
|
|
38
|
+
M extends ISplitTextMutableProps = ISplitTextMutableProps,
|
|
39
|
+
> extends Module<C, S, M> {
|
|
39
40
|
/**
|
|
40
41
|
* Retrieves the default static properties.
|
|
41
42
|
*/
|
|
42
|
-
public _getStatic(): TRequiredProps<
|
|
43
|
+
public _getStatic(): TRequiredProps<S> {
|
|
43
44
|
return {
|
|
44
45
|
...super._getStatic(),
|
|
45
46
|
letters: false,
|
|
@@ -54,14 +55,17 @@ export class SplitText<
|
|
|
54
55
|
lineWrapperClass: this._cn('__line-wrapper'),
|
|
55
56
|
resizeDebounce: 0,
|
|
56
57
|
ignore: null,
|
|
57
|
-
|
|
58
|
+
prepareText: (text) => text,
|
|
59
|
+
wordDelimiter: String.fromCharCode(32),
|
|
60
|
+
wordDelimiterOutput: null,
|
|
61
|
+
} as TRequiredProps<S>;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
/**
|
|
61
65
|
* Retrieves the default mutable properties.
|
|
62
66
|
*/
|
|
63
|
-
public _getMutable(): TRequiredProps<
|
|
64
|
-
return { ...super._getMutable() } as TRequiredProps<
|
|
67
|
+
public _getMutable(): TRequiredProps<M> {
|
|
68
|
+
return { ...super._getMutable() } as TRequiredProps<M>;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
/**
|
|
@@ -146,13 +150,17 @@ export class SplitText<
|
|
|
146
150
|
/**
|
|
147
151
|
* Initializes the SplitText instance and saves the initial state.
|
|
148
152
|
*/
|
|
149
|
-
constructor(
|
|
150
|
-
|
|
153
|
+
constructor(
|
|
154
|
+
props?: S & M,
|
|
155
|
+
onCallbacks?: TModuleOnCallbacksProps<C, SplitText<C, S, M>>,
|
|
156
|
+
) {
|
|
157
|
+
super(props, onCallbacks as any);
|
|
151
158
|
|
|
152
159
|
const { container } = this.props;
|
|
160
|
+
const { style } = container;
|
|
153
161
|
|
|
154
|
-
|
|
155
|
-
|
|
162
|
+
style.fontKerning = 'none';
|
|
163
|
+
style.display = 'block';
|
|
156
164
|
container.setAttribute('aria-label', container.textContent || '');
|
|
157
165
|
|
|
158
166
|
this._addTempClassName(container, this._cn(''));
|
|
@@ -192,6 +200,7 @@ export class SplitText<
|
|
|
192
200
|
/**
|
|
193
201
|
* Splits the text into letters, words, and optionally lines based on configuration.
|
|
194
202
|
*/
|
|
203
|
+
@noopIfDestroyed
|
|
195
204
|
public split() {
|
|
196
205
|
this.callbacks.emit('beforeSplit', undefined);
|
|
197
206
|
|
|
@@ -212,8 +221,17 @@ export class SplitText<
|
|
|
212
221
|
return;
|
|
213
222
|
}
|
|
214
223
|
|
|
215
|
-
const {
|
|
216
|
-
|
|
224
|
+
const {
|
|
225
|
+
container,
|
|
226
|
+
letterTag,
|
|
227
|
+
wordTag,
|
|
228
|
+
wordClass,
|
|
229
|
+
letterClass,
|
|
230
|
+
ignore,
|
|
231
|
+
prepareText,
|
|
232
|
+
wordDelimiter,
|
|
233
|
+
wordDelimiterOutput,
|
|
234
|
+
} = this.props;
|
|
217
235
|
|
|
218
236
|
this._isBaseSplit = true;
|
|
219
237
|
|
|
@@ -225,6 +243,9 @@ export class SplitText<
|
|
|
225
243
|
letterTag,
|
|
226
244
|
wordTag,
|
|
227
245
|
ignore,
|
|
246
|
+
prepareText,
|
|
247
|
+
wordDelimiter,
|
|
248
|
+
wordDelimiterOutput,
|
|
228
249
|
});
|
|
229
250
|
|
|
230
251
|
this._wordsMeta = wordsMeta;
|
|
@@ -82,6 +82,36 @@ export interface ISplitTextStaticProps extends IModuleStaticProps {
|
|
|
82
82
|
* @default null
|
|
83
83
|
*/
|
|
84
84
|
ignore?: string | HTMLElement[] | ((element: HTMLElement) => boolean) | null;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Optional callback to preprocess text before it is split into words.
|
|
88
|
+
* This function receives the original text and should return the modified text.
|
|
89
|
+
* It is useful for languages like Chinese where standard word splitting may not work correctly.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
*
|
|
93
|
+
* const segmenter = new Intl.Segmenter('zh', { granularity: 'word' });
|
|
94
|
+
*
|
|
95
|
+
* const instance = new SplitText({
|
|
96
|
+
* container,
|
|
97
|
+
* prepareText: (source) => [...segmenter.segment(source)].map((s) => s.segment).join(' '),
|
|
98
|
+
});
|
|
99
|
+
*/
|
|
100
|
+
prepareText?: (text: string) => string;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Specifies a custom delimiter used to split text into words.
|
|
104
|
+
* By default, splitting occurs on regular whitespace.
|
|
105
|
+
* @default " "
|
|
106
|
+
*/
|
|
107
|
+
wordDelimiter?: string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Provides an alternative delimiter to use when outputting the split words.
|
|
111
|
+
* Useful when a custom input delimiter is used but the output should differ.
|
|
112
|
+
* @default null
|
|
113
|
+
*/
|
|
114
|
+
wordDelimiterOutput?: string | null;
|
|
85
115
|
}
|
|
86
116
|
|
|
87
117
|
/** Mutable properties for the SplitText module */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isString } from '@/internal/isString';
|
|
1
2
|
import { ISplitTextStaticProps } from '../types';
|
|
2
3
|
|
|
3
4
|
export function isIgnored(
|
|
@@ -8,7 +9,7 @@ export function isIgnored(
|
|
|
8
9
|
return false;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
if (
|
|
12
|
+
if (isString(ignore)) {
|
|
12
13
|
return element.matches(ignore);
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { doc } from '@/internal/env';
|
|
2
|
+
|
|
1
3
|
interface IClone {
|
|
2
4
|
node: Node;
|
|
3
5
|
cssText: string | null;
|
|
@@ -25,7 +27,7 @@ export function saveInitialNodes(root: Node) {
|
|
|
25
27
|
// Return a function to restore the initial nodes
|
|
26
28
|
return {
|
|
27
29
|
restore: () => {
|
|
28
|
-
const fragment =
|
|
30
|
+
const fragment = doc.createDocumentFragment();
|
|
29
31
|
|
|
30
32
|
flatArray.forEach((element) => {
|
|
31
33
|
const { node, cssText } = element;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
import { doc } from '@/internal/env';
|
|
1
2
|
import { ISplitTextLetterMeta, ISplitTextStaticProps } from '../types';
|
|
2
3
|
import { wrapLetters } from './wrapLetters';
|
|
3
4
|
import { wrapWords } from './wrapWords';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
type TBaseProps = Pick<
|
|
7
|
+
ISplitTextStaticProps,
|
|
8
|
+
'ignore' | 'prepareText' | 'wordDelimiter' | 'wordDelimiterOutput'
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
interface IProps extends TBaseProps {
|
|
6
12
|
container: HTMLElement;
|
|
7
13
|
letterClassName: string;
|
|
8
14
|
wordClassName: string;
|
|
9
15
|
hasLetters: boolean;
|
|
10
16
|
letterTag: keyof HTMLElementTagNameMap;
|
|
11
17
|
wordTag: keyof HTMLElementTagNameMap;
|
|
12
|
-
ignore: ISplitTextStaticProps['ignore'];
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
/**
|
|
@@ -23,15 +28,17 @@ export function splitBase({
|
|
|
23
28
|
letterTag,
|
|
24
29
|
wordTag,
|
|
25
30
|
ignore,
|
|
31
|
+
...props
|
|
26
32
|
}: IProps) {
|
|
27
33
|
// Prepare the fragment
|
|
28
|
-
const prepareFragment =
|
|
34
|
+
const prepareFragment = doc.createDocumentFragment();
|
|
29
35
|
while (container.childNodes[0]) {
|
|
30
36
|
prepareFragment.appendChild(container.childNodes[0]);
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
// Wrap the text into words
|
|
34
40
|
const wordsMeta = wrapWords({
|
|
41
|
+
...props,
|
|
35
42
|
container: prepareFragment as any,
|
|
36
43
|
classname: wordClassName,
|
|
37
44
|
tagName: wordTag,
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
ISplitTextWordMeta,
|
|
6
6
|
} from '../types';
|
|
7
7
|
import { isIgnored } from './isIgnored';
|
|
8
|
+
import { cnAdd } from '@/internal/cn';
|
|
9
|
+
import { doc } from '@/internal/env';
|
|
8
10
|
|
|
9
11
|
interface IProps {
|
|
10
12
|
wordsMeta: ISplitTextWordMeta[];
|
|
@@ -19,9 +21,9 @@ interface IProps {
|
|
|
19
21
|
export function wrapLetters({ wordsMeta, classname, tagName, ignore }: IProps) {
|
|
20
22
|
const lettersMeta: ISplitTextLetterMeta[] = [];
|
|
21
23
|
|
|
22
|
-
const baseElement =
|
|
24
|
+
const baseElement = doc.createElement(tagName);
|
|
23
25
|
baseElement.style.display = 'inline-block';
|
|
24
|
-
baseElement
|
|
26
|
+
cnAdd(baseElement, classname);
|
|
25
27
|
|
|
26
28
|
// Iterate over each word to wrap its letters
|
|
27
29
|
wordsMeta.forEach((wordMeta) => {
|
|
@@ -45,7 +47,7 @@ export function wrapLetters({ wordsMeta, classname, tagName, ignore }: IProps) {
|
|
|
45
47
|
|
|
46
48
|
splitLetters.forEach((letterContents) => {
|
|
47
49
|
const element = baseElement.cloneNode(false) as HTMLElement;
|
|
48
|
-
element.appendChild(
|
|
50
|
+
element.appendChild(doc.createTextNode(letterContents));
|
|
49
51
|
|
|
50
52
|
// Append the letter element to the word's container
|
|
51
53
|
wordMeta.element.insertBefore(element, textNode);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { cnAdd } from '@/internal/cn';
|
|
1
2
|
import { ISplitTextLineMeta, ISplitTextWordMeta } from '../types';
|
|
2
3
|
import { getTextAalignment } from './getTextAalignment';
|
|
4
|
+
import { doc } from '@/internal/env';
|
|
3
5
|
|
|
4
6
|
interface IProps {
|
|
5
7
|
container: HTMLElement;
|
|
@@ -58,10 +60,10 @@ export function wrapLines({
|
|
|
58
60
|
let lineIndex = -1;
|
|
59
61
|
let lastBounding: DOMRect | null = null;
|
|
60
62
|
|
|
61
|
-
const baseElement =
|
|
63
|
+
const baseElement = doc.createElement(tagName);
|
|
62
64
|
baseElement.style.display = 'block';
|
|
63
65
|
baseElement.setAttribute('aria-hidden', 'true');
|
|
64
|
-
baseElement
|
|
66
|
+
cnAdd(baseElement, lineClassName);
|
|
65
67
|
|
|
66
68
|
const boundings = wordsMeta.map((wordMeta) =>
|
|
67
69
|
wordMeta.element.getBoundingClientRect(),
|
|
@@ -95,9 +97,9 @@ export function wrapLines({
|
|
|
95
97
|
let wrapper: HTMLElement | undefined;
|
|
96
98
|
|
|
97
99
|
if (hasLinesWrapper) {
|
|
98
|
-
wrapper =
|
|
100
|
+
wrapper = doc.createElement(tagName);
|
|
99
101
|
wrapper.style.display = 'block';
|
|
100
|
-
wrapper
|
|
102
|
+
cnAdd(wrapper, lineWrapperClassName);
|
|
101
103
|
wrapper.appendChild(element);
|
|
102
104
|
}
|
|
103
105
|
|
|
@@ -123,7 +125,7 @@ export function wrapLines({
|
|
|
123
125
|
linesMeta.forEach((line) => {
|
|
124
126
|
container.insertBefore(line.wrapper ?? line.element, line.nodes[0]);
|
|
125
127
|
|
|
126
|
-
const fragment =
|
|
128
|
+
const fragment = doc.createDocumentFragment();
|
|
127
129
|
fragment.append(...line.nodes);
|
|
128
130
|
line.element.append(fragment);
|
|
129
131
|
});
|