Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

desktop-viewport

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

desktop-viewport

Hastily makes desktop browsers respect the viewport setting

  • 1.2.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

desktop-viewport

Hastily makes desktop browsers respect the viewport setting so they'll scale up and down everything to a given window size

Usage (browser)

Grab the latest release and drop it in as a script tag.

Just add it to your page, wrap everything on a div id'd #container and have a viewport tag on <head>. Check test/index.html for an example!!

Usage (webpack+babel)

Grab the code from here or npm

npm install desktop-viewport --save

#or#

git checkout git@github.com:walaura/desktop-viewport.git
npm install

& then

import desktopViewport from 'desktop-viewport';
desktopViewport();

Usage

desktop-viewport will attach itself on load, you don't have to do anything. However there's extra work for you if you are checking the scroll position via javascript or having dynamically sized elements.

  • If you are checking the scroll position per element you must multiply it by desktopViewport.scaleMultiplier to get the real scroll position
  • If your page height changes you must call desktopViewport.rescale() for the container to resize itself

API

window.desktopViewport (or the object returned by the webpack module) has several useful properties such as

desktopViewport.scaleMultiplier
number containing the scale of the current page

desktopViewport.rescale()
rescale the viewport and calculate the height again.
you can pass in a parameter with a new viewport width

desktopViewport.init()
if you aren't autoloading you
must call this for anything to happen

Options

You can pass options to desktopViewport either on the function initializer (webpack) or by creating a window.desktopViewportSettings object before loading desktop-viewport.min.js (browser)

window.desktopViewportSettings = {
    container: '#container',
    /*css selector for the container element*/
    viewport: 'viewport',
    /*viewport width. number or 'viewport' to autodetect it*/
    autoLoad: true
    /*automatically bind it on pageload*/
}

Keywords

FAQs

Package last updated on 06 Mar 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc