@vkontakte/mvk-mini-apps-scroll-helper
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,1 +0,24 @@ | ||
"use strict";var mvkScrollHelper=function(e){if(e&&"string"==typeof e){var o=new URLSearchParams(window.location.search);if((~window.navigator.userAgent.indexOf("iPhone")||~window.navigator.userAgent.indexOf("iPad"))&&o.has("vk_platform")&&"mobile_web"===o.get("vk_platform")){var r=document.getElementById(e);r&&(r.style.overflowY="scroll",r.style.webkitOverflowScrolling="touch")}}};module.exports=mvkScrollHelper; | ||
'use strict'; | ||
var PLATFORM_PARAM = 'vk_platform'; | ||
var MOBILE_WEB = 'mobile_web'; | ||
/** | ||
* @param {HTMLElement|null} appContainerNode | ||
*/ | ||
var mvkScrollHelper = function mvkScrollHelper(appContainerNode) { | ||
if (appContainerNode == null) { | ||
return; | ||
} | ||
var searchParams = new URLSearchParams(location.search); | ||
var _navigator = navigator, | ||
userAgent = _navigator.userAgent; | ||
if ((userAgent.includes('iPhone') || userAgent.includes('iPad')) && searchParams.get(PLATFORM_PARAM) === MOBILE_WEB) { | ||
appContainerNode.style.overflowY = 'scroll'; | ||
appContainerNode.style.webkitOverflowScrolling = 'touch'; | ||
} | ||
}; | ||
module.exports = mvkScrollHelper; |
@@ -1,1 +0,30 @@ | ||
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e=e||self).mVKMiniAppsScrollHelper=o()}(this,function(){"use strict";return e=>{if(e&&"string"==typeof e){const o=new URLSearchParams(window.location.search);if((~window.navigator.userAgent.indexOf("iPhone")||~window.navigator.userAgent.indexOf("iPad"))&&o.has("vk_platform")&&"mobile_web"===o.get("vk_platform")){const o=document.getElementById(e);o&&(o.style.overflowY="scroll",o.style.webkitOverflowScrolling="touch")}}}}); | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = global || self, global.mVKMiniAppsScrollHelper = factory()); | ||
}(this, function () { 'use strict'; | ||
var PLATFORM_PARAM = 'vk_platform'; | ||
var MOBILE_WEB = 'mobile_web'; | ||
/** | ||
* @param {HTMLElement|null} appContainerNode | ||
*/ | ||
var mvkScrollHelper = function mvkScrollHelper(appContainerNode) { | ||
if (appContainerNode == null) { | ||
return; | ||
} | ||
var searchParams = new URLSearchParams(location.search); | ||
var _navigator = navigator, | ||
userAgent = _navigator.userAgent; | ||
if ((userAgent.includes('iPhone') || userAgent.includes('iPad')) && searchParams.get(PLATFORM_PARAM) === MOBILE_WEB) { | ||
appContainerNode.style.overflowY = 'scroll'; | ||
appContainerNode.style.webkitOverflowScrolling = 'touch'; | ||
} | ||
}; | ||
return mvkScrollHelper; | ||
})); |
{ | ||
"name": "@vkontakte/mvk-mini-apps-scroll-helper", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "dist/mvk-mini-apps-scroll-helper.cjs.js", | ||
"module": "dist/mvk-mini-apps-scroll-helper.esm.js", | ||
"browser": "dist/mvk-mini-apps-scroll-helper.umd.js", | ||
@@ -7,0 +6,0 @@ "umdName": "mVKMiniAppsScrollHelper", |
@@ -8,4 +8,4 @@ <div align="center"> | ||
[![npm][npm]][npm-url] | ||
[![deps][deps]][deps-url] | ||
[![npm][npm]][npm-url] | ||
[![deps][deps]][deps-url] | ||
@@ -17,4 +17,7 @@ </div> | ||
Хелпер настройки скролла для [VK Mini Apps](https://vk.com/services) на платформе m.vk.com | ||
## Подключение | ||
Добавьте в зависимости пакет: | ||
```bash | ||
@@ -24,3 +27,3 @@ npm i @vkontakte/mvk-mini-apps-scroll-helper | ||
Перед рендером React-приложения вызовите хелпер: | ||
Перед рендером приложения вызовите хелпер: | ||
@@ -30,6 +33,10 @@ ```js | ||
// Вызываем хелпер, передавая в аргумент id ноды-контейнера React-приложения | ||
mVKMiniAppsScrollHelper('root'); | ||
// Корневой элемент приложения | ||
const root = document.getElementById('root'); | ||
ReactDOM.render(<App />, document.getElementById('root')); | ||
// Вызываем хелпер, передавая в аргумент корневой элемент приложения | ||
mVKMiniAppsScrollHelper(root); | ||
// Рендер приложения | ||
ReactDOM.render(<App />, root); | ||
``` | ||
@@ -39,3 +46,2 @@ | ||
[npm-url]: https://npmjs.com/package/@vkontakte/mvk-mini-apps-scroll-helper | ||
[deps]: https://img.shields.io/david/vkcom/mvk-mini-apps-scroll-helper.svg | ||
@@ -42,0 +48,0 @@ [deps-url]: https://david-dm.org/vkcom/mvk-mini-apps-scroll-helper |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
5859
48
48
0