
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
mobile-viewport-control
Advanced tools
On mobile browsers, Apple set a non-standardized precedent of controlling the viewport with one or more meta tags:
<meta name="viewport" content="name=value,name=value,...">
The goal of this project is to see if we can use these tags to dynamically modify the viewport at runtime. Specifically, we want to freeze the viewport at some zoom level, then restore the viewport later.
Generally, a user should be able to pinch-zoom a page. But for things like popup modals, the user experience is better if the viewport is preset like a native app.
npm install mobile-viewport-control
const viewport = require('mobile-viewport-control');
// ... or use `window.mobileViewportControl` if not used with package manager
// Freeze the viewport at a desired scale.
viewport.freeze(1.0, () => console.log('notified when frozen!'));
// Restore the viewport to what it was before freezing.
viewport.thaw(() => console.log('notified when thawed!'));
Additionally, to freeze the scroll area to a given element, you can pass an
element ID as the second argument. We do this by temporarily hiding everything
else on the page. Just make sure your element is a direct child of
document.body
.
viewport.freeze(1.0, 'myElementID');
Test on arbitrary web pages with the following bookmarklet. It will freeze the viewport scale, show a custom isolated element, and allow you to press a button to restore the view.
javascript:(function(){document.body.appendChild(document.createElement('script')).src='https://cdn.rawgit.com/shaunstripe/mobile-viewport-control/master/index.js?'+Math.random();document.body.appendChild(document.createElement('script')).src='https://cdn.rawgit.com/shaunstripe/mobile-viewport-control/master/test/bookmarklet.js?'+Math.random();}())
Compatibility is measured with a combination of automatic/manual testing:
Mobile Browser | Measure Test* | Freeze Test | Thaw Test |
---|---|---|---|
iOS Safari | Y | Y | Y |
iOS UIWebView | Y | Fails if user pinch-zooms before freezing** | Y if freeze succeeds. |
iOS WKWebView | Y | Y | Y |
iOS SFSafariViewController | Y | Y | Y |
iOS Chrome | Y | Y | Y |
iOS Firefox | Y | Y | Y |
iOS Opera Mini | Y | Fails if user pinch-zooms before freezing** | Y if freeze succeeds. |
Android Browser (Stock) | ? | ? | ? |
Android Chrome | Y | Y | Y |
Android WebView | Y | Y | Y |
Android Chrome Custom Tabs | Y | Y | Y |
Android Firefox | Y | Fails | Fails |
Android Opera Mini | Fails | Fails | Fails |
* This test fails in the iOS Simulator because initial-scale
is ignored
there for wide pages for some reason.
** Pinch-zooming causes the page's scale to change from its specified
initial-scale
. This custom zoom level is maintained across refreshes. When
opening in a new tab, the initial-scale
is resumed.
We currently do not test all variables, but the test outcomes depend on the following:
test.css
)FAQs
Dynamically control the mobile viewport
The npm package mobile-viewport-control receives a total of 19 weekly downloads. As such, mobile-viewport-control popularity was classified as not popular.
We found that mobile-viewport-control demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.