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.
Files changed (357) hide show
  1. package/lib/cdn/vevet.iife.min.js +13 -9
  2. package/lib/cjs/base/Callbacks/index.js +31 -3
  3. package/lib/cjs/base/Callbacks/index.js.map +1 -1
  4. package/lib/cjs/base/Module/index.js +40 -9
  5. package/lib/cjs/base/Module/index.js.map +1 -1
  6. package/lib/cjs/base/Responsive/index.js +10 -3
  7. package/lib/cjs/base/Responsive/index.js.map +1 -1
  8. package/lib/cjs/components/Canvas/index.js +19 -4
  9. package/lib/cjs/components/Canvas/index.js.map +1 -1
  10. package/lib/cjs/components/CanvasMedia/index.js +15 -2
  11. package/lib/cjs/components/CanvasMedia/index.js.map +1 -1
  12. package/lib/cjs/components/Cursor/index.js +54 -29
  13. package/lib/cjs/components/Cursor/index.js.map +1 -1
  14. package/lib/cjs/components/Cursor/styles.js +4 -3
  15. package/lib/cjs/components/Cursor/styles.js.map +1 -1
  16. package/lib/cjs/components/InView/index.js +17 -3
  17. package/lib/cjs/components/InView/index.js.map +1 -1
  18. package/lib/cjs/components/Marquee/index.js +47 -29
  19. package/lib/cjs/components/Marquee/index.js.map +1 -1
  20. package/lib/cjs/components/Pointers/index.js +4 -4
  21. package/lib/cjs/components/Pointers/index.js.map +1 -1
  22. package/lib/cjs/components/Pointers/styles.js +2 -1
  23. package/lib/cjs/components/Pointers/styles.js.map +1 -1
  24. package/lib/cjs/components/Preloader/index.js +16 -5
  25. package/lib/cjs/components/Preloader/index.js.map +1 -1
  26. package/lib/cjs/components/ProgressPreloader/index.js +23 -14
  27. package/lib/cjs/components/ProgressPreloader/index.js.map +1 -1
  28. package/lib/cjs/components/Raf/index.js +16 -3
  29. package/lib/cjs/components/Raf/index.js.map +1 -1
  30. package/lib/cjs/components/ScrollProgress/index.js +12 -2
  31. package/lib/cjs/components/ScrollProgress/index.js.map +1 -1
  32. package/lib/cjs/components/Scrollbar/index.js +45 -25
  33. package/lib/cjs/components/Scrollbar/index.js.map +1 -1
  34. package/lib/cjs/components/Scrollbar/styles.js +3 -2
  35. package/lib/cjs/components/Scrollbar/styles.js.map +1 -1
  36. package/lib/cjs/components/Snap/Slide/index.js +18 -1
  37. package/lib/cjs/components/Snap/Slide/index.js.map +1 -1
  38. package/lib/cjs/components/Snap/SlideParallax/constants.js +101 -0
  39. package/lib/cjs/components/Snap/SlideParallax/constants.js.map +1 -0
  40. package/lib/cjs/components/Snap/SlideParallax/globals.js +5 -0
  41. package/lib/cjs/components/Snap/SlideParallax/globals.js.map +1 -0
  42. package/lib/cjs/components/Snap/SlideParallax/index.js +145 -0
  43. package/lib/cjs/components/Snap/SlideParallax/index.js.map +1 -0
  44. package/lib/cjs/components/Snap/SlideParallax/types.js +3 -0
  45. package/lib/cjs/components/Snap/SlideParallax/types.js.map +1 -0
  46. package/lib/cjs/components/Snap/Swipe/index.js +6 -4
  47. package/lib/cjs/components/Snap/Swipe/index.js.map +1 -1
  48. package/lib/cjs/components/Snap/Track/index.js +35 -6
  49. package/lib/cjs/components/Snap/Track/index.js.map +1 -1
  50. package/lib/cjs/components/Snap/Wheel/index.js +2 -1
  51. package/lib/cjs/components/Snap/Wheel/index.js.map +1 -1
  52. package/lib/cjs/components/Snap/index.js +30 -16
  53. package/lib/cjs/components/Snap/index.js.map +1 -1
  54. package/lib/cjs/components/SplitText/index.js +20 -6
  55. package/lib/cjs/components/SplitText/index.js.map +1 -1
  56. package/lib/cjs/components/SplitText/utils/isIgnored.js +2 -1
  57. package/lib/cjs/components/SplitText/utils/isIgnored.js.map +1 -1
  58. package/lib/cjs/components/SplitText/utils/saveInitialNodes.js +2 -1
  59. package/lib/cjs/components/SplitText/utils/saveInitialNodes.js.map +1 -1
  60. package/lib/cjs/components/SplitText/utils/splitBase.js +26 -8
  61. package/lib/cjs/components/SplitText/utils/splitBase.js.map +1 -1
  62. package/lib/cjs/components/SplitText/utils/wrapLetters.js +5 -3
  63. package/lib/cjs/components/SplitText/utils/wrapLetters.js.map +1 -1
  64. package/lib/cjs/components/SplitText/utils/wrapLines.js +7 -5
  65. package/lib/cjs/components/SplitText/utils/wrapLines.js.map +1 -1
  66. package/lib/cjs/components/SplitText/utils/wrapWords.js +12 -9
  67. package/lib/cjs/components/SplitText/utils/wrapWords.js.map +1 -1
  68. package/lib/cjs/components/Swipe/index.js +22 -13
  69. package/lib/cjs/components/Swipe/index.js.map +1 -1
  70. package/lib/cjs/components/Swipe/styles.js +2 -1
  71. package/lib/cjs/components/Swipe/styles.js.map +1 -1
  72. package/lib/cjs/components/Timeline/index.js +25 -11
  73. package/lib/cjs/components/Timeline/index.js.map +1 -1
  74. package/lib/cjs/core/handlers/createPageLoad/index.js +6 -5
  75. package/lib/cjs/core/handlers/createPageLoad/index.js.map +1 -1
  76. package/lib/cjs/core/handlers/createViewport/index.js +43 -20
  77. package/lib/cjs/core/handlers/createViewport/index.js.map +1 -1
  78. package/lib/cjs/core/index.js +12 -8
  79. package/lib/cjs/core/index.js.map +1 -1
  80. package/lib/cjs/global/initVevet.js +2 -1
  81. package/lib/cjs/global/initVevet.js.map +1 -1
  82. package/lib/cjs/index.js +2 -1
  83. package/lib/cjs/index.js.map +1 -1
  84. package/lib/cjs/internal/cn.js +19 -0
  85. package/lib/cjs/internal/cn.js.map +1 -0
  86. package/lib/cjs/internal/env.js +8 -0
  87. package/lib/cjs/internal/env.js.map +1 -0
  88. package/lib/cjs/internal/isNumber.js +7 -0
  89. package/lib/cjs/internal/isNumber.js.map +1 -0
  90. package/lib/cjs/internal/isString.js +7 -0
  91. package/lib/cjs/internal/isString.js.map +1 -0
  92. package/lib/cjs/internal/isUndefined.js +7 -0
  93. package/lib/cjs/internal/isUndefined.js.map +1 -0
  94. package/lib/cjs/internal/noopIfDestroyed.js +20 -0
  95. package/lib/cjs/internal/noopIfDestroyed.js.map +1 -0
  96. package/lib/cjs/internal/textDirection.js +7 -0
  97. package/lib/cjs/internal/textDirection.js.map +1 -0
  98. package/lib/cjs/manifest.json +1 -1
  99. package/lib/cjs/utils/common/toPixels.js +4 -3
  100. package/lib/cjs/utils/common/toPixels.js.map +1 -1
  101. package/lib/esm/base/Callbacks/index.js +30 -3
  102. package/lib/esm/base/Callbacks/index.js.map +1 -1
  103. package/lib/esm/base/Module/index.js +37 -9
  104. package/lib/esm/base/Module/index.js.map +1 -1
  105. package/lib/esm/base/Responsive/index.js +10 -3
  106. package/lib/esm/base/Responsive/index.js.map +1 -1
  107. package/lib/esm/components/Canvas/index.js +19 -4
  108. package/lib/esm/components/Canvas/index.js.map +1 -1
  109. package/lib/esm/components/CanvasMedia/index.js +15 -2
  110. package/lib/esm/components/CanvasMedia/index.js.map +1 -1
  111. package/lib/esm/components/Cursor/index.js +54 -29
  112. package/lib/esm/components/Cursor/index.js.map +1 -1
  113. package/lib/esm/components/Cursor/styles.js +7 -2
  114. package/lib/esm/components/Cursor/styles.js.map +1 -1
  115. package/lib/esm/components/InView/index.js +17 -3
  116. package/lib/esm/components/InView/index.js.map +1 -1
  117. package/lib/esm/components/Marquee/index.js +47 -29
  118. package/lib/esm/components/Marquee/index.js.map +1 -1
  119. package/lib/esm/components/Pointers/index.js +4 -4
  120. package/lib/esm/components/Pointers/index.js.map +1 -1
  121. package/lib/esm/components/Pointers/styles.js +2 -1
  122. package/lib/esm/components/Pointers/styles.js.map +1 -1
  123. package/lib/esm/components/Preloader/index.js +16 -5
  124. package/lib/esm/components/Preloader/index.js.map +1 -1
  125. package/lib/esm/components/ProgressPreloader/index.js +23 -14
  126. package/lib/esm/components/ProgressPreloader/index.js.map +1 -1
  127. package/lib/esm/components/Raf/index.js +16 -3
  128. package/lib/esm/components/Raf/index.js.map +1 -1
  129. package/lib/esm/components/ScrollProgress/index.js +12 -2
  130. package/lib/esm/components/ScrollProgress/index.js.map +1 -1
  131. package/lib/esm/components/Scrollbar/index.js +45 -25
  132. package/lib/esm/components/Scrollbar/index.js.map +1 -1
  133. package/lib/esm/components/Scrollbar/styles.js +3 -2
  134. package/lib/esm/components/Scrollbar/styles.js.map +1 -1
  135. package/lib/esm/components/Snap/Slide/index.js +18 -1
  136. package/lib/esm/components/Snap/Slide/index.js.map +1 -1
  137. package/lib/esm/components/Snap/SlideParallax/constants.js +95 -0
  138. package/lib/esm/components/Snap/SlideParallax/constants.js.map +1 -0
  139. package/lib/esm/components/Snap/SlideParallax/globals.js +2 -0
  140. package/lib/esm/components/Snap/SlideParallax/globals.js.map +1 -0
  141. package/lib/esm/components/Snap/SlideParallax/index.js +122 -0
  142. package/lib/esm/components/Snap/SlideParallax/index.js.map +1 -0
  143. package/lib/esm/components/Snap/SlideParallax/types.js +2 -0
  144. package/lib/esm/components/Snap/SlideParallax/types.js.map +1 -0
  145. package/lib/esm/components/Snap/Swipe/index.js +6 -4
  146. package/lib/esm/components/Snap/Swipe/index.js.map +1 -1
  147. package/lib/esm/components/Snap/Track/index.js +31 -6
  148. package/lib/esm/components/Snap/Track/index.js.map +1 -1
  149. package/lib/esm/components/Snap/Wheel/index.js +2 -1
  150. package/lib/esm/components/Snap/Wheel/index.js.map +1 -1
  151. package/lib/esm/components/Snap/index.js +30 -16
  152. package/lib/esm/components/Snap/index.js.map +1 -1
  153. package/lib/esm/components/SplitText/index.js +20 -6
  154. package/lib/esm/components/SplitText/index.js.map +1 -1
  155. package/lib/esm/components/SplitText/utils/isIgnored.js +2 -1
  156. package/lib/esm/components/SplitText/utils/isIgnored.js.map +1 -1
  157. package/lib/esm/components/SplitText/utils/saveInitialNodes.js +2 -1
  158. package/lib/esm/components/SplitText/utils/saveInitialNodes.js.map +1 -1
  159. package/lib/esm/components/SplitText/utils/splitBase.js +16 -8
  160. package/lib/esm/components/SplitText/utils/splitBase.js.map +1 -1
  161. package/lib/esm/components/SplitText/utils/wrapLetters.js +5 -3
  162. package/lib/esm/components/SplitText/utils/wrapLetters.js.map +1 -1
  163. package/lib/esm/components/SplitText/utils/wrapLines.js +7 -5
  164. package/lib/esm/components/SplitText/utils/wrapLines.js.map +1 -1
  165. package/lib/esm/components/SplitText/utils/wrapWords.js +13 -10
  166. package/lib/esm/components/SplitText/utils/wrapWords.js.map +1 -1
  167. package/lib/esm/components/Swipe/index.js +22 -13
  168. package/lib/esm/components/Swipe/index.js.map +1 -1
  169. package/lib/esm/components/Swipe/styles.js +2 -1
  170. package/lib/esm/components/Swipe/styles.js.map +1 -1
  171. package/lib/esm/components/Timeline/index.js +25 -11
  172. package/lib/esm/components/Timeline/index.js.map +1 -1
  173. package/lib/esm/core/handlers/createPageLoad/index.js +6 -5
  174. package/lib/esm/core/handlers/createPageLoad/index.js.map +1 -1
  175. package/lib/esm/core/handlers/createViewport/index.js +43 -20
  176. package/lib/esm/core/handlers/createViewport/index.js.map +1 -1
  177. package/lib/esm/core/index.js +16 -8
  178. package/lib/esm/core/index.js.map +1 -1
  179. package/lib/esm/global/initVevet.js +2 -1
  180. package/lib/esm/global/initVevet.js.map +1 -1
  181. package/lib/esm/index.js +2 -1
  182. package/lib/esm/index.js.map +1 -1
  183. package/lib/esm/internal/cn.js +13 -0
  184. package/lib/esm/internal/cn.js.map +1 -0
  185. package/lib/esm/internal/env.js +5 -0
  186. package/lib/esm/internal/env.js.map +1 -0
  187. package/lib/esm/internal/isNumber.js +4 -0
  188. package/lib/esm/internal/isNumber.js.map +1 -0
  189. package/lib/esm/internal/isString.js +4 -0
  190. package/lib/esm/internal/isString.js.map +1 -0
  191. package/lib/esm/internal/isUndefined.js +4 -0
  192. package/lib/esm/internal/isUndefined.js.map +1 -0
  193. package/lib/esm/internal/noopIfDestroyed.js +13 -0
  194. package/lib/esm/internal/noopIfDestroyed.js.map +1 -0
  195. package/lib/esm/internal/textDirection.js +4 -0
  196. package/lib/esm/internal/textDirection.js.map +1 -0
  197. package/lib/esm/manifest.json +1 -1
  198. package/lib/esm/utils/common/toPixels.js +3 -2
  199. package/lib/esm/utils/common/toPixels.js.map +1 -1
  200. package/lib/types/base/Callbacks/index.d.ts +9 -5
  201. package/lib/types/base/Callbacks/index.d.ts.map +1 -1
  202. package/lib/types/base/Callbacks/types.d.ts +9 -5
  203. package/lib/types/base/Callbacks/types.d.ts.map +1 -1
  204. package/lib/types/base/Module/index.d.ts +5 -5
  205. package/lib/types/base/Module/index.d.ts.map +1 -1
  206. package/lib/types/base/Module/types.d.ts +4 -1
  207. package/lib/types/base/Module/types.d.ts.map +1 -1
  208. package/lib/types/base/Responsive/index.d.ts.map +1 -1
  209. package/lib/types/base/Responsive/types.d.ts +2 -2
  210. package/lib/types/base/Responsive/types.d.ts.map +1 -1
  211. package/lib/types/components/Canvas/index.d.ts +5 -5
  212. package/lib/types/components/Canvas/index.d.ts.map +1 -1
  213. package/lib/types/components/CanvasMedia/index.d.ts +5 -4
  214. package/lib/types/components/CanvasMedia/index.d.ts.map +1 -1
  215. package/lib/types/components/Cursor/index.d.ts +5 -5
  216. package/lib/types/components/Cursor/index.d.ts.map +1 -1
  217. package/lib/types/components/Cursor/styles.d.ts.map +1 -1
  218. package/lib/types/components/InView/index.d.ts +5 -5
  219. package/lib/types/components/InView/index.d.ts.map +1 -1
  220. package/lib/types/components/InView/types.d.ts.map +1 -1
  221. package/lib/types/components/Marquee/index.d.ts +5 -5
  222. package/lib/types/components/Marquee/index.d.ts.map +1 -1
  223. package/lib/types/components/Pointers/index.d.ts +5 -5
  224. package/lib/types/components/Pointers/index.d.ts.map +1 -1
  225. package/lib/types/components/Pointers/styles.d.ts.map +1 -1
  226. package/lib/types/components/Preloader/index.d.ts +5 -5
  227. package/lib/types/components/Preloader/index.d.ts.map +1 -1
  228. package/lib/types/components/ProgressPreloader/index.d.ts +5 -4
  229. package/lib/types/components/ProgressPreloader/index.d.ts.map +1 -1
  230. package/lib/types/components/Raf/index.d.ts +5 -5
  231. package/lib/types/components/Raf/index.d.ts.map +1 -1
  232. package/lib/types/components/ScrollProgress/index.d.ts +5 -5
  233. package/lib/types/components/ScrollProgress/index.d.ts.map +1 -1
  234. package/lib/types/components/Scrollbar/index.d.ts +7 -5
  235. package/lib/types/components/Scrollbar/index.d.ts.map +1 -1
  236. package/lib/types/components/Scrollbar/styles.d.ts.map +1 -1
  237. package/lib/types/components/Snap/Slide/index.d.ts +5 -0
  238. package/lib/types/components/Snap/Slide/index.d.ts.map +1 -1
  239. package/lib/types/components/Snap/SlideParallax/constants.d.ts +7 -0
  240. package/lib/types/components/Snap/SlideParallax/constants.d.ts.map +1 -0
  241. package/lib/types/components/Snap/SlideParallax/globals.d.ts +2 -0
  242. package/lib/types/components/Snap/SlideParallax/globals.d.ts.map +1 -0
  243. package/lib/types/components/Snap/SlideParallax/index.d.ts +25 -0
  244. package/lib/types/components/Snap/SlideParallax/index.d.ts.map +1 -0
  245. package/lib/types/components/Snap/SlideParallax/types.d.ts +22 -0
  246. package/lib/types/components/Snap/SlideParallax/types.d.ts.map +1 -0
  247. package/lib/types/components/Snap/Swipe/index.d.ts.map +1 -1
  248. package/lib/types/components/Snap/Swipe/types.d.ts +1 -6
  249. package/lib/types/components/Snap/Swipe/types.d.ts.map +1 -1
  250. package/lib/types/components/Snap/Track/index.d.ts +10 -1
  251. package/lib/types/components/Snap/Track/index.d.ts.map +1 -1
  252. package/lib/types/components/Snap/Wheel/index.d.ts.map +1 -1
  253. package/lib/types/components/Snap/index.d.ts +5 -5
  254. package/lib/types/components/Snap/index.d.ts.map +1 -1
  255. package/lib/types/components/Snap/types.d.ts +1 -1
  256. package/lib/types/components/SplitText/index.d.ts +5 -5
  257. package/lib/types/components/SplitText/index.d.ts.map +1 -1
  258. package/lib/types/components/SplitText/types.d.ts +27 -0
  259. package/lib/types/components/SplitText/types.d.ts.map +1 -1
  260. package/lib/types/components/SplitText/utils/isIgnored.d.ts.map +1 -1
  261. package/lib/types/components/SplitText/utils/saveInitialNodes.d.ts.map +1 -1
  262. package/lib/types/components/SplitText/utils/splitBase.d.ts +3 -3
  263. package/lib/types/components/SplitText/utils/splitBase.d.ts.map +1 -1
  264. package/lib/types/components/SplitText/utils/wrapLetters.d.ts.map +1 -1
  265. package/lib/types/components/SplitText/utils/wrapLines.d.ts.map +1 -1
  266. package/lib/types/components/SplitText/utils/wrapWords.d.ts +3 -3
  267. package/lib/types/components/SplitText/utils/wrapWords.d.ts.map +1 -1
  268. package/lib/types/components/Swipe/index.d.ts +5 -5
  269. package/lib/types/components/Swipe/index.d.ts.map +1 -1
  270. package/lib/types/components/Swipe/styles.d.ts.map +1 -1
  271. package/lib/types/components/Swipe/types.d.ts +10 -0
  272. package/lib/types/components/Swipe/types.d.ts.map +1 -1
  273. package/lib/types/components/Timeline/index.d.ts +5 -5
  274. package/lib/types/components/Timeline/index.d.ts.map +1 -1
  275. package/lib/types/core/global.d.ts +4 -0
  276. package/lib/types/core/global.d.ts.map +1 -1
  277. package/lib/types/core/handlers/createPageLoad/index.d.ts.map +1 -1
  278. package/lib/types/core/handlers/createViewport/index.d.ts +2 -1
  279. package/lib/types/core/handlers/createViewport/index.d.ts.map +1 -1
  280. package/lib/types/core/index.d.ts.map +1 -1
  281. package/lib/types/global/initVevet.d.ts.map +1 -1
  282. package/lib/types/index.d.ts.map +1 -1
  283. package/lib/types/internal/cn.d.ts +5 -0
  284. package/lib/types/internal/cn.d.ts.map +1 -0
  285. package/lib/types/internal/env.d.ts +5 -0
  286. package/lib/types/internal/env.d.ts.map +1 -0
  287. package/lib/types/internal/isNumber.d.ts +2 -0
  288. package/lib/types/internal/isNumber.d.ts.map +1 -0
  289. package/lib/types/internal/isString.d.ts +2 -0
  290. package/lib/types/internal/isString.d.ts.map +1 -0
  291. package/lib/types/internal/isUndefined.d.ts +2 -0
  292. package/lib/types/internal/isUndefined.d.ts.map +1 -0
  293. package/lib/types/internal/noopIfDestroyed.d.ts +2 -0
  294. package/lib/types/internal/noopIfDestroyed.d.ts.map +1 -0
  295. package/lib/types/internal/textDirection.d.ts +2 -0
  296. package/lib/types/internal/textDirection.d.ts.map +1 -0
  297. package/lib/types/utils/common/toPixels.d.ts.map +1 -1
  298. package/package.json +2 -1
  299. package/src/base/Callbacks/index.ts +26 -7
  300. package/src/base/Callbacks/types.ts +12 -7
  301. package/src/base/Module/index.ts +44 -12
  302. package/src/base/Module/types.ts +5 -1
  303. package/src/base/Responsive/index.ts +2 -4
  304. package/src/base/Responsive/types.ts +4 -5
  305. package/src/components/Canvas/index.ts +21 -13
  306. package/src/components/CanvasMedia/index.ts +17 -10
  307. package/src/components/Cursor/index.ts +56 -38
  308. package/src/components/Cursor/styles.ts +8 -2
  309. package/src/components/InView/index.ts +19 -12
  310. package/src/components/InView/types.ts +2 -6
  311. package/src/components/Marquee/index.ts +50 -39
  312. package/src/components/Pointers/index.ts +16 -13
  313. package/src/components/Pointers/styles.ts +3 -2
  314. package/src/components/Preloader/index.ts +31 -14
  315. package/src/components/ProgressPreloader/index.ts +25 -27
  316. package/src/components/Raf/index.ts +20 -14
  317. package/src/components/ScrollProgress/index.ts +16 -13
  318. package/src/components/Scrollbar/index.ts +52 -36
  319. package/src/components/Scrollbar/styles.ts +4 -2
  320. package/src/components/Snap/Slide/index.ts +26 -0
  321. package/src/components/Snap/SlideParallax/constants.ts +100 -0
  322. package/src/components/Snap/SlideParallax/globals.ts +1 -0
  323. package/src/components/Snap/SlideParallax/index.ts +184 -0
  324. package/src/components/Snap/SlideParallax/types.ts +24 -0
  325. package/src/components/Snap/Swipe/index.ts +8 -4
  326. package/src/components/Snap/Swipe/types.ts +1 -7
  327. package/src/components/Snap/Track/index.ts +45 -6
  328. package/src/components/Snap/Wheel/index.ts +2 -1
  329. package/src/components/Snap/index.ts +31 -32
  330. package/src/components/Snap/types.ts +1 -1
  331. package/src/components/SplitText/index.ts +36 -15
  332. package/src/components/SplitText/types.ts +30 -0
  333. package/src/components/SplitText/utils/isIgnored.ts +2 -1
  334. package/src/components/SplitText/utils/saveInitialNodes.ts +3 -1
  335. package/src/components/SplitText/utils/splitBase.ts +10 -3
  336. package/src/components/SplitText/utils/wrapLetters.ts +5 -3
  337. package/src/components/SplitText/utils/wrapLines.ts +7 -5
  338. package/src/components/SplitText/utils/wrapWords.ts +29 -13
  339. package/src/components/Swipe/index.ts +35 -20
  340. package/src/components/Swipe/styles.ts +3 -2
  341. package/src/components/Swipe/types.ts +12 -0
  342. package/src/components/Timeline/index.ts +23 -22
  343. package/src/core/global.ts +5 -0
  344. package/src/core/handlers/createPageLoad/index.ts +6 -5
  345. package/src/core/handlers/createViewport/index.ts +44 -21
  346. package/src/core/index.ts +17 -11
  347. package/src/global/initVevet.ts +2 -1
  348. package/src/index.ts +2 -3
  349. package/src/internal/cn.ts +15 -0
  350. package/src/internal/env.ts +7 -0
  351. package/src/internal/isNumber.ts +3 -0
  352. package/src/internal/isString.ts +3 -0
  353. package/src/internal/isUndefined.ts +3 -0
  354. package/src/internal/noopIfDestroyed.ts +19 -0
  355. package/src/internal/textDirection.ts +3 -0
  356. package/src/manifest.json +1 -1
  357. package/src/utils/common/toPixels.ts +3 -3
@@ -1,23 +1,37 @@
1
+ import { cnAdd } from '@/internal/cn';
1
2
  import { ISplitTextStaticProps, ISplitTextWordMeta } from '../types';
2
3
  import { isIgnored } from './isIgnored';
4
+ import { doc } from '@/internal/env';
3
5
 
4
- interface IProps {
6
+ type TBaseProps = Pick<
7
+ ISplitTextStaticProps,
8
+ 'ignore' | 'prepareText' | 'wordDelimiter' | 'wordDelimiterOutput'
9
+ >;
10
+
11
+ interface IProps extends TBaseProps {
5
12
  container: ChildNode;
6
13
  classname: string;
7
14
  tagName: keyof HTMLElementTagNameMap;
8
- ignore: ISplitTextStaticProps['ignore'];
9
15
  }
10
16
 
11
17
  /**
12
18
  * Wraps each word inside the container in an HTML element with the specified tag and class.
13
19
  */
14
- export function wrapWords({ container, classname, tagName, ignore }: IProps) {
15
- const whitespace = String.fromCharCode(32); // ASCII for space
16
-
17
- const baseElement = document.createElement(tagName);
20
+ export function wrapWords({
21
+ container,
22
+ classname,
23
+ tagName,
24
+ ignore,
25
+ prepareText,
26
+ wordDelimiter = ' ',
27
+ wordDelimiterOutput: wordDelimiterOutputProp,
28
+ }: IProps) {
29
+ const wordDelimiterOutput = wordDelimiterOutputProp || wordDelimiter;
30
+
31
+ const baseElement = doc.createElement(tagName);
18
32
  baseElement.style.display = 'inline-block';
19
33
  baseElement.setAttribute('aria-hidden', 'true');
20
- baseElement.classList.add(classname);
34
+ cnAdd(baseElement, classname);
21
35
 
22
36
  const wordsMeta: ISplitTextWordMeta[] = [];
23
37
  let prevNonBreakingWord: HTMLElement | null = null;
@@ -54,23 +68,25 @@ export function wrapWords({ container, classname, tagName, ignore }: IProps) {
54
68
  // If the node is a text node, split it into words
55
69
  if (node.nodeType === 3) {
56
70
  const parent = node.parentElement ?? container;
57
- const text = node.nodeValue ?? '';
71
+ let text = node.nodeValue ?? '';
58
72
 
59
73
  // Handle case where node contains only whitespace
60
- if (text === whitespace) {
74
+ if (text === wordDelimiter) {
61
75
  prevNonBreakingWord = null;
62
- parent?.insertBefore(document.createTextNode(whitespace), node);
76
+ parent?.insertBefore(doc.createTextNode(wordDelimiterOutput), node);
63
77
  node.remove();
64
78
 
65
79
  return;
66
80
  }
67
81
 
68
82
  // Wrap each word in an element and insert it into the DOM
69
- const splitWords = text.split(whitespace);
83
+ text = prepareText ? prepareText(text) : text;
84
+ const splitWords = text.split(wordDelimiter);
85
+
70
86
  splitWords.forEach((wordContents, index) => {
71
87
  if (wordContents) {
72
88
  const element = baseElement.cloneNode(false) as HTMLElement;
73
- element.appendChild(document.createTextNode(wordContents));
89
+ element.appendChild(doc.createTextNode(wordContents));
74
90
  prevNonBreakingWord = element;
75
91
 
76
92
  wordsMeta.push({ element, letters: [] });
@@ -80,7 +96,7 @@ export function wrapWords({ container, classname, tagName, ignore }: IProps) {
80
96
 
81
97
  // Add a whitespace between words, except after the last word
82
98
  if (index < splitWords.length - 1) {
83
- parent?.insertBefore(document.createTextNode(whitespace), node);
99
+ parent?.insertBefore(doc.createTextNode(wordDelimiterOutput), node);
84
100
  }
85
101
  });
86
102
 
@@ -1,4 +1,4 @@
1
- import { Module } from '@/base';
1
+ import { Module, TModuleOnCallbacksProps } from '@/base';
2
2
  import { TRequiredProps } from '@/internal/requiredProps';
3
3
  import {
4
4
  ISwipeCallbacksMap,
@@ -14,6 +14,7 @@ import { addEventListener, clamp, EaseOutCubic } from '@/utils';
14
14
  import { initVevet } from '@/global/initVevet';
15
15
  import { Timeline } from '../Timeline';
16
16
  import { cursorStyles } from './styles';
17
+ import { body } from '@/internal/env';
17
18
 
18
19
  export * from './types';
19
20
 
@@ -34,31 +35,33 @@ const VELOCITIES_COUNT = 4;
34
35
  * @group Components
35
36
  */
36
37
  export class Swipe<
37
- CallbacksMap extends ISwipeCallbacksMap = ISwipeCallbacksMap,
38
- StaticProps extends ISwipeStaticProps = ISwipeStaticProps,
39
- MutableProps extends ISwipeMutableProps = ISwipeMutableProps,
40
- > extends Module<CallbacksMap, StaticProps, MutableProps> {
38
+ C extends ISwipeCallbacksMap = ISwipeCallbacksMap,
39
+ S extends ISwipeStaticProps = ISwipeStaticProps,
40
+ M extends ISwipeMutableProps = ISwipeMutableProps,
41
+ > extends Module<C, S, M> {
41
42
  /**
42
43
  * Returns default static properties.
43
44
  */
44
- public _getStatic(): TRequiredProps<StaticProps> {
45
+ public _getStatic(): TRequiredProps<S> {
45
46
  return {
46
47
  ...super._getStatic(),
48
+ thumb: null,
47
49
  buttons: [0],
48
50
  pointers: 1,
49
51
  disableUserSelect: true,
50
- } as TRequiredProps<StaticProps>;
52
+ } as TRequiredProps<S>;
51
53
  }
52
54
 
53
55
  /**
54
56
  * Returns default mutable properties.
55
57
  */
56
- public _getMutable(): TRequiredProps<MutableProps> {
58
+ public _getMutable(): TRequiredProps<M> {
57
59
  return {
58
60
  ...super._getMutable(),
59
61
  enabled: true,
60
62
  relative: false,
61
63
  axis: null,
64
+ ratio: 1,
62
65
  grabCursor: false,
63
66
  willAbort: () => false,
64
67
  threshold: 5,
@@ -75,7 +78,7 @@ export class Swipe<
75
78
  distanceModifier: false,
76
79
  inertiaRatio: 1,
77
80
  inertiaDistanceThreshold: 50,
78
- } as TRequiredProps<MutableProps>;
81
+ } as TRequiredProps<M>;
79
82
  }
80
83
 
81
84
  /** Pointer event manager */
@@ -125,10 +128,13 @@ export class Swipe<
125
128
  /** Cursor styles */
126
129
  protected _cursorStyles: HTMLStyleElement;
127
130
 
128
- constructor(props?: StaticProps & MutableProps) {
129
- super(props);
131
+ constructor(
132
+ props?: S & M,
133
+ onCallbacks?: TModuleOnCallbacksProps<C, Swipe<C, S, M>>,
134
+ ) {
135
+ super(props, onCallbacks as any);
130
136
 
131
- const { container, buttons, pointers } = this.props;
137
+ const { container, thumb, buttons, pointers } = this.props;
132
138
 
133
139
  // set default data
134
140
  this._coords = {
@@ -147,7 +153,7 @@ export class Swipe<
147
153
 
148
154
  // create pointers
149
155
  this._pointers = new Pointers({
150
- container,
156
+ container: thumb || container,
151
157
  buttons,
152
158
  minPointers: pointers,
153
159
  maxPointers: pointers,
@@ -185,6 +191,7 @@ export class Swipe<
185
191
  /** Applies touch-action and cursor styles */
186
192
  protected _setInlineStyles() {
187
193
  const { container, axis } = this.props;
194
+ const { style } = container;
188
195
 
189
196
  const cursor = this.props.grabCursor ? 'grab' : '';
190
197
 
@@ -195,8 +202,8 @@ export class Swipe<
195
202
  touchAction = 'pan-x';
196
203
  }
197
204
 
198
- container.style.cursor = cursor;
199
- container.style.touchAction = touchAction;
205
+ style.cursor = cursor;
206
+ style.touchAction = touchAction;
200
207
  }
201
208
 
202
209
  /** Handles `touchstart` events */
@@ -287,6 +294,7 @@ export class Swipe<
287
294
  /** Parses pointer coordinates relative to the container */
288
295
  protected _decodeCoords(event: MouseEvent | TouchEvent): ISwipeMatrix {
289
296
  const { props } = this;
297
+ const { container, ratio } = props;
290
298
 
291
299
  const clientX =
292
300
  'touches' in event ? event.touches[0].clientX : event.clientX;
@@ -300,7 +308,7 @@ export class Swipe<
300
308
  let centerY = initVevet().height / 2;
301
309
 
302
310
  if (props.relative) {
303
- const bounding = props.container.getBoundingClientRect();
311
+ const bounding = container.getBoundingClientRect();
304
312
 
305
313
  x = clientX - bounding.left;
306
314
  y = clientY - bounding.top;
@@ -311,7 +319,11 @@ export class Swipe<
311
319
  const angleRad = Math.atan2(clientY - centerY, clientX - centerX);
312
320
  const angle = (angleRad * 180) / Math.PI;
313
321
 
314
- return { x, y, angle };
322
+ return {
323
+ x: x * ratio,
324
+ y: y * ratio,
325
+ angle,
326
+ };
315
327
  }
316
328
 
317
329
  /** Handles move events */
@@ -332,14 +344,17 @@ export class Swipe<
332
344
 
333
345
  // check if can start
334
346
  if (!this._isSwiping) {
335
- const { threshold, minTime, axis, willAbort } = this.props;
347
+ const { threshold, ratio, minTime, axis, willAbort } = this.props;
348
+ const speed = Math.abs(ratio);
349
+
336
350
  const diff = {
337
351
  x: matrix.x - this._startCoord.x,
338
352
  y: matrix.y - this._startCoord.y,
339
353
  };
340
354
 
341
355
  // check threshold
342
- if (Math.sqrt(diff.x ** 2 + diff.y ** 2) < threshold) {
356
+ const dist = Math.sqrt((diff.x / speed) ** 2 + (diff.y / speed) ** 2);
357
+ if (dist < threshold) {
343
358
  return;
344
359
  }
345
360
 
@@ -396,7 +411,7 @@ export class Swipe<
396
411
 
397
412
  // apply cursor
398
413
  if (this.props.grabCursor && this._cursorStyles) {
399
- initVevet().body.append(this._cursorStyles);
414
+ body.append(this._cursorStyles);
400
415
  }
401
416
  }
402
417
 
@@ -1,5 +1,6 @@
1
- export const cursorStyles =
2
- typeof window !== 'undefined' ? document.createElement('style') : null;
1
+ import { doc, isBrowser } from '@/internal/env';
2
+
3
+ export const cursorStyles = isBrowser ? doc.createElement('style') : null;
3
4
 
4
5
  if (cursorStyles) {
5
6
  cursorStyles.innerHTML = '* { cursor: grabbing !important; }';
@@ -9,6 +9,12 @@ export interface ISwipeStaticProps extends IModuleStaticProps {
9
9
  /** Event listener container. */
10
10
  container: HTMLElement | SVGElement;
11
11
 
12
+ /**
13
+ * An element that triggers the swipe start.
14
+ * Calculations remain relative to the container regardless of this element.
15
+ */
16
+ thumb?: HTMLElement | SVGElement | null;
17
+
12
18
  /**
13
19
  * Determines which mouse buttons trigger events.
14
20
  * - 0: Main button pressed, usually the left button or the un-initialized state
@@ -55,6 +61,12 @@ export interface ISwipeMutableProps extends IModuleMutableProps {
55
61
  */
56
62
  axis?: null | 'x' | 'y';
57
63
 
64
+ /**
65
+ * Swipe move ratio (multiplier).
66
+ * @default 1
67
+ */
68
+ ratio?: number;
69
+
58
70
  /**
59
71
  * Shows "grab" and "grabbing" cursors during interaction.
60
72
  * @default false
@@ -1,5 +1,5 @@
1
1
  import { TRequiredProps } from '@/internal/requiredProps';
2
- import { Module } from '@/base/Module';
2
+ import { Module, TModuleOnCallbacksProps } from '@/base/Module';
3
3
  import { clamp, easing } from '@/utils/math';
4
4
  import {
5
5
  ITimelineCallbacksMap,
@@ -7,6 +7,8 @@ import {
7
7
  ITimelineStaticProps,
8
8
  } from './types';
9
9
  import { initVevet } from '@/global/initVevet';
10
+ import { noopIfDestroyed } from '@/internal/noopIfDestroyed';
11
+ import { isUndefined } from '@/internal/isUndefined';
10
12
 
11
13
  export * from './types';
12
14
 
@@ -19,22 +21,22 @@ export * from './types';
19
21
  * @group Components
20
22
  */
21
23
  export class Timeline<
22
- CallbacksMap extends ITimelineCallbacksMap = ITimelineCallbacksMap,
23
- StaticProps extends ITimelineStaticProps = ITimelineStaticProps,
24
- MutableProps extends ITimelineMutableProps = ITimelineMutableProps,
25
- > extends Module<CallbacksMap, StaticProps, MutableProps> {
24
+ C extends ITimelineCallbacksMap = ITimelineCallbacksMap,
25
+ S extends ITimelineStaticProps = ITimelineStaticProps,
26
+ M extends ITimelineMutableProps = ITimelineMutableProps,
27
+ > extends Module<C, S, M> {
26
28
  /** Get default static properties. */
27
- public _getStatic(): TRequiredProps<StaticProps> {
28
- return { ...super._getStatic() } as TRequiredProps<StaticProps>;
29
+ public _getStatic(): TRequiredProps<S> {
30
+ return { ...super._getStatic() } as TRequiredProps<S>;
29
31
  }
30
32
 
31
33
  /** Get default mutable properties. */
32
- public _getMutable(): TRequiredProps<MutableProps> {
34
+ public _getMutable(): TRequiredProps<M> {
33
35
  return {
34
36
  ...super._getMutable(),
35
37
  easing: initVevet().props.easing,
36
38
  duration: 1000,
37
- } as TRequiredProps<MutableProps>;
39
+ } as TRequiredProps<M>;
38
40
  }
39
41
 
40
42
  /** Current linear progress of the timeline (0 to 1). */
@@ -74,7 +76,7 @@ export class Timeline<
74
76
  * Whether the timeline is currently playing.
75
77
  */
76
78
  get isPlaying() {
77
- return typeof this._raf !== 'undefined';
79
+ return !isUndefined(this._raf);
78
80
  }
79
81
 
80
82
  /** Indicates whether the timeline is currently reversed. */
@@ -110,8 +112,11 @@ export class Timeline<
110
112
  return this.props.duration;
111
113
  }
112
114
 
113
- constructor(props?: StaticProps & MutableProps) {
114
- super(props);
115
+ constructor(
116
+ props?: S & M,
117
+ onCallbacks?: TModuleOnCallbacksProps<C, Timeline<C, S, M>>,
118
+ ) {
119
+ super(props, onCallbacks as any);
115
120
 
116
121
  // Initialize default values
117
122
  this._progress = 0;
@@ -126,8 +131,9 @@ export class Timeline<
126
131
  * Play the timeline, advancing progress toward completion.
127
132
  * Does nothing if the timeline is destroyed or already completed.
128
133
  */
134
+ @noopIfDestroyed
129
135
  public play() {
130
- if (this.isDestroyed || this.progress === 1) {
136
+ if (this.progress === 1) {
131
137
  return;
132
138
  }
133
139
 
@@ -144,8 +150,9 @@ export class Timeline<
144
150
  * Reverse the timeline, moving progress toward the start.
145
151
  * Does nothing if the timeline is destroyed or already at the start.
146
152
  */
153
+ @noopIfDestroyed
147
154
  public reverse() {
148
- if (this.isDestroyed || this.progress === 0) {
155
+ if (this.progress === 0) {
149
156
  return;
150
157
  }
151
158
 
@@ -161,11 +168,8 @@ export class Timeline<
161
168
  /**
162
169
  * Pause the timeline, halting progress without resetting it.
163
170
  */
171
+ @noopIfDestroyed
164
172
  public pause() {
165
- if (this.isDestroyed) {
166
- return;
167
- }
168
-
169
173
  this._isPaused = true;
170
174
 
171
175
  if (this._raf) {
@@ -178,11 +182,8 @@ export class Timeline<
178
182
  /**
179
183
  * Reset the timeline to the beginning (progress = 0).
180
184
  */
185
+ @noopIfDestroyed
181
186
  public reset() {
182
- if (this.isDestroyed) {
183
- return;
184
- }
185
-
186
187
  this.pause();
187
188
  this.progress = 0;
188
189
  }
@@ -51,6 +51,11 @@ export interface ICore extends IViewport {
51
51
  */
52
52
  browserName: string;
53
53
 
54
+ /**
55
+ * Detects In-App Browser and returns its name, otherwise - `false`.
56
+ */
57
+ inAppBrowser: false | string;
58
+
54
59
  /** Document */
55
60
  doc: Document;
56
61
 
@@ -1,6 +1,8 @@
1
1
  import { Callbacks } from '@/base/Callbacks';
2
2
  import { IPageLoadCallbacksMap } from './types';
3
3
  import { addEventListener } from '@/utils/listeners';
4
+ import { cnAdd, cnRemove } from '@/internal/cn';
5
+ import { doc, html } from '@/internal/env';
4
6
 
5
7
  interface IProps {
6
8
  prefix: string;
@@ -12,7 +14,7 @@ export function createPageLoad({ prefix, applyClassNames }: IProps) {
12
14
 
13
15
  let isLoaded = false;
14
16
 
15
- if (document.readyState === 'complete') {
17
+ if (doc.readyState === 'complete') {
16
18
  setTimeout(() => handleLoaded(), 0);
17
19
  } else {
18
20
  addEventListener(window, 'load', () => handleLoaded());
@@ -20,16 +22,15 @@ export function createPageLoad({ prefix, applyClassNames }: IProps) {
20
22
 
21
23
  /** Callback on page loaded */
22
24
  function handleLoaded() {
23
- const html = document.documentElement;
24
25
  const { body } = document;
25
26
 
26
27
  isLoaded = true;
27
28
 
28
29
  if (applyClassNames) {
29
- html.classList.remove(`${prefix}loading`);
30
- body.classList.remove(`${prefix}loading`);
30
+ cnRemove(html, `${prefix}loading`);
31
+ cnRemove(body, `${prefix}loading`);
31
32
 
32
- html.classList.add(`${prefix}loaded`);
33
+ cnAdd(html, `${prefix}loaded`);
33
34
  }
34
35
 
35
36
  callbacks.emit('loaded', undefined);
@@ -1,24 +1,38 @@
1
1
  import { IViewport, TViewportCallbacks } from './types';
2
2
  import { Callbacks } from '@/base/Callbacks';
3
3
  import { ICoreProps } from '@/core/types';
4
+ import { cnToggle } from '@/internal/cn';
5
+ import { body, doc, html } from '@/internal/env';
4
6
  import { addEventListener } from '@/utils/listeners';
5
7
 
6
8
  interface IProps {
7
9
  prefix: string;
8
10
  props: ICoreProps;
9
11
  isMobile: boolean;
12
+ isInApp: boolean;
10
13
  }
11
14
 
12
- export function createViewport({ prefix, props, isMobile }: IProps) {
13
- const html = document.documentElement;
14
-
15
- let styles = document.getElementById('vevet_css_preset');
15
+ export function createViewport({ prefix, props, isMobile, isInApp }: IProps) {
16
+ // create styles
17
+ let styles = doc.getElementById('vevet_css_preset');
16
18
  if (!styles) {
17
- styles = document.createElement('style');
19
+ styles = doc.createElement('style');
18
20
  styles.id = 'vevet_css_preset';
19
- document.body.appendChild(styles);
21
+ body.appendChild(styles);
20
22
  }
21
23
 
24
+ // create svh helper
25
+ const svhHelper = doc.createElement('div');
26
+ const { style } = svhHelper;
27
+ svhHelper.id = 'vevet_svh_helper';
28
+ style.position = 'fixed';
29
+ style.top = '-100svh';
30
+ style.left = '-100px';
31
+ style.width = '1px';
32
+ style.height = '100svh';
33
+ body.appendChild(svhHelper);
34
+
35
+ // media queries
22
36
  const mqDesktop = window.matchMedia(`(min-width: ${props.md + 0.001}px)`);
23
37
  const mqTablet = window.matchMedia(
24
38
  `(min-width: ${props.sm + 0.001}px) and (max-width: ${props.md}px)`,
@@ -72,8 +86,8 @@ export function createViewport({ prefix, props, isMobile }: IProps) {
72
86
  addEventListener(window, 'resize', () => debounceResize());
73
87
 
74
88
  const observer = new ResizeObserver(() => debounceResize());
75
- observer.observe(document.documentElement);
76
- observer.observe(document.body);
89
+ observer.observe(html);
90
+ observer.observe(body);
77
91
 
78
92
  /** Event on window resize */
79
93
  function onResize() {
@@ -116,12 +130,11 @@ export function createViewport({ prefix, props, isMobile }: IProps) {
116
130
  function updateValues() {
117
131
  const { width: prevWidth } = data;
118
132
 
119
- const root = document.documentElement;
120
- const rootStyles = getComputedStyle(root);
133
+ const rootStyles = getComputedStyle(html);
121
134
 
122
135
  data.width = window.innerWidth;
123
136
  data.height = window.innerHeight;
124
- data.scrollbarWidth = window.innerWidth - root.clientWidth;
137
+ data.scrollbarWidth = window.innerWidth - html.clientWidth;
125
138
  data.vw = data.width / 100;
126
139
  data.vh = data.height / 100;
127
140
  data.rem = parseFloat(rootStyles.fontSize);
@@ -141,11 +154,21 @@ export function createViewport({ prefix, props, isMobile }: IProps) {
141
154
  data.lg = true;
142
155
  }
143
156
 
144
- // update sHeight && svh only when the width changes
145
- // or for desktop
146
- if (prevWidth !== data.width || !data.sHeight || !isMobile) {
147
- data.sHeight = root.clientHeight;
148
- data.svh = data.sHeight / 100;
157
+ // for in-app browser, update svh only if width changed
158
+ if (isMobile && isInApp) {
159
+ const rootHeight = html.clientHeight;
160
+
161
+ if (prevWidth !== data.width || !data.sHeight) {
162
+ data.sHeight = rootHeight;
163
+ data.svh = data.sHeight / 100;
164
+ } else if (prevWidth === data.width && rootHeight < data.sHeight) {
165
+ data.sHeight = rootHeight;
166
+ data.svh = data.sHeight / 100;
167
+ }
168
+ } else {
169
+ // when other browser, update svh directly
170
+ data.svh = svhHelper.clientHeight / 100 || html.clientHeight / 100;
171
+ data.sHeight = data.svh * 100;
149
172
  }
150
173
  }
151
174
 
@@ -155,12 +178,12 @@ export function createViewport({ prefix, props, isMobile }: IProps) {
155
178
  return;
156
179
  }
157
180
 
158
- html.classList.toggle(`${prefix}lg`, data.lg);
159
- html.classList.toggle(`${prefix}md`, data.md);
160
- html.classList.toggle(`${prefix}sm`, data.sm);
181
+ cnToggle(html, `${prefix}lg`, data.lg);
182
+ cnToggle(html, `${prefix}md`, data.md);
183
+ cnToggle(html, `${prefix}sm`, data.sm);
161
184
 
162
- html.classList.toggle(`${prefix}landscape`, data.landscape);
163
- html.classList.toggle(`${prefix}portrait`, data.portrait);
185
+ cnToggle(html, `${prefix}landscape`, data.landscape);
186
+ cnToggle(html, `${prefix}portrait`, data.portrait);
164
187
  }
165
188
 
166
189
  /** Update CSS variables */
package/src/core/index.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import { detect } from 'detect-browser';
2
2
  import isMobileJs from 'ismobilejs';
3
+ import InAppSpy from 'inapp-spy';
3
4
  import manifest from '../manifest.json';
4
5
  import { createPageLoad } from './handlers/createPageLoad';
5
6
  import { ICoreProps } from './types';
6
7
  import { createViewport } from './handlers/createViewport';
7
8
  import { ICore } from './global';
9
+ import { cnAdd, cnToggle } from '@/internal/cn';
10
+ import { body, doc, html } from '@/internal/env';
8
11
 
9
12
  export function Core(input: Partial<ICoreProps>): ICore {
10
13
  // set default properties
@@ -31,13 +34,17 @@ export function Core(input: Partial<ICoreProps>): ICore {
31
34
 
32
35
  const isMobile = device.phone || device.tablet;
33
36
 
37
+ const { isInApp, appName } = InAppSpy();
38
+ const inAppBrowser = isInApp ? (appName || 'unknown').toLowerCase() : false;
39
+
34
40
  // events
35
41
 
36
42
  const pageLoad = createPageLoad({
37
43
  prefix,
38
44
  applyClassNames: props.applyClassNames,
39
45
  });
40
- const viewport = createViewport({ prefix, props, isMobile });
46
+
47
+ const viewport = createViewport({ prefix, props, isMobile, isInApp });
41
48
 
42
49
  // output
43
50
 
@@ -52,9 +59,10 @@ export function Core(input: Partial<ICoreProps>): ICore {
52
59
  mobile: isMobile,
53
60
  osName,
54
61
  browserName,
55
- doc: document,
56
- html: document.documentElement,
57
- body: document.body,
62
+ inAppBrowser,
63
+ doc,
64
+ html,
65
+ body,
58
66
  loaded: false,
59
67
  onLoad: pageLoad.onLoad,
60
68
  onResize: (...params) => viewport.callbacks.on(...params),
@@ -87,17 +95,15 @@ export function Core(input: Partial<ICoreProps>): ICore {
87
95
  return;
88
96
  }
89
97
 
90
- const { html } = output;
91
-
92
- html.classList.add(`${prefix}os-${osName}`);
98
+ cnAdd(html, `${prefix}os-${osName}`);
93
99
 
94
- html.classList.add(`${prefix}browser-${browserName}`);
100
+ cnAdd(html, `${prefix}browser-${browserName}`);
95
101
 
96
- html.classList.toggle(`${prefix}phone`, output.phone);
102
+ cnToggle(html, `${prefix}phone`, output.phone);
97
103
 
98
- html.classList.toggle(`${prefix}tablet`, output.tablet);
104
+ cnToggle(html, `${prefix}tablet`, output.tablet);
99
105
 
100
- html.classList.toggle(`${prefix}mobile`, output.mobile);
106
+ cnToggle(html, `${prefix}mobile`, output.mobile);
101
107
  })();
102
108
 
103
109
  return output;
@@ -1,6 +1,7 @@
1
1
  import { Core } from '@/core';
2
2
  import { ICore } from '@/core/global';
3
3
  import { ICoreProps } from '@/core/types';
4
+ import { isBrowser } from '@/internal/env';
4
5
 
5
6
  declare global {
6
7
  interface Window {
@@ -26,6 +27,6 @@ export function initVevet() {
26
27
  }
27
28
 
28
29
  // auto initialize
29
- if (typeof window !== 'undefined') {
30
+ if (isBrowser) {
30
31
  window.vevet5 = initVevet();
31
32
  }
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ICore } from './core/global';
2
2
  import { initVevet } from './global/initVevet';
3
+ import { isBrowser } from './internal/env';
3
4
 
4
5
  export { initVevet };
5
6
 
@@ -8,9 +9,7 @@ export { initVevet };
8
9
  *
9
10
  * @group Core
10
11
  */
11
- export const vevet = (
12
- typeof window !== 'undefined' ? initVevet() : undefined
13
- ) as Readonly<ICore>;
12
+ export const vevet = (isBrowser ? initVevet() : undefined) as Readonly<ICore>;
14
13
 
15
14
  export const app = vevet;
16
15