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

@financial-times/o-viewport

Package Overview
Dependencies
Maintainers
18
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@financial-times/o-viewport - npm Package Compare versions

Comparing version 4.0.5 to 5.0.0-0

.eslintignore

7

origami.json
{
"description": "Utility for attaching debounced listeners to resize, scroll, orientation and visibility events on window",
"keywords": [ "debounce", "listen", "event" ],
"origamiType": "module",
"origamiCategory": "utilities",
"origamiVersion": 1,
"origamiType": "component",
"origamiVersion": "2.0",
"support": "https://github.com/Financial-Times/o-viewport/issues",

@@ -8,0 +5,0 @@ "supportContact": {

{
"browser": "browser.js",
"files": [
"svg/",
"dist/",
"browser.js",
"src/",
"!src/**/*.js",
"main.scss",
"img",
"*.json",
"*.js",
"!main.js",
"scss",
"!bower.json",
"!.bower.json"
],
"eslintIgnore": [
"browser.js",
"dist/"
],
"name": "@financial-times/o-viewport",
"version": "5.0.0-0",
"description": "Utility for attaching debounced listeners to resize, scroll, orientation and visibility events on window",
"keywords": [
"origami",
"component",
"ft"
"debounce",
"listen",
"event"
],
"name": "@financial-times/o-viewport",
"version": "4.0.5",
"description": "Utility for moderating listeners for browser events on window",
"dependencies": {
"@financial-times/o-utils": "^1.0.0"
"homepage": "https://registry.origami.ft.com/components/o-viewport",
"bugs": {
"url": "https://registry.origami.ft.com/components/o-viewport"
},
"component": "o-viewport",
"scripts": {},
"license": "MIT",
"type": "module",
"browser": "main.js",
"scripts": {
"start": "npx serve ./demos/local",
"build": "npm_config_yes=true npx \"origami-build-tools@prerelease\" install && npm_config_yes=true npx \"origami-build-tools@prerelease\" demo"
},
"devDependencies": {
"eslint": "^7.8.1",
"eslint-config-origami-component": "^2.1.0",
"origami-ci-tools": "^2.0.2",
"eslint": "^7.24.0",
"eslint-config-origami-component": "^2.1.1",
"remark": "^13.0.0",
"remark-lint": "^7.0.1",
"remark-preset-lint-origami-component": "prerelease",
"stylelint": "^13.12.0",
"stylelint-config-origami-component": "^1.0.4"
},
"peerDependencies": {
"@financial-times/o-utils": "prerelease"
},
"engines": {
"npm": "^7"
},
"volta": {
"node": "14.16.1",
"npm": "7.10.0"
}
}

@@ -9,3 +9,3 @@ # o-viewport [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](#licence)

*Note: within the component's API and in the documentation below `orientation` and `visibility` are used instead of `orientationchange` or `visibilitychange`, but the actual browser event listened to is `orientationchange` or `visibilitychange`*
_Note: within the component's API and in the documentation below `orientation` and `visibility` are used instead of `orientationchange` or `visibilitychange`, but the actual browser event listened to is `orientationchange` or `visibilitychange`_

@@ -15,8 +15,8 @@ ## Methods

### `o-viewport#listenTo(eventType)`
Attaches a debounced/throttled (as appropriate) listener to events on window [`resize`, `scroll`, `orientation`, `visibility` or `all`] which in turn fires events within the `oViewport` namespace (see **Events** below).
Attaches a debounced/throttled (as appropriate) listener to events on window \[`resize`, `scroll`, `orientation`, `visibility` or `all`\] which in turn fires events within the `oViewport` namespace (see **Events** below).
*Note: all will enable all o-viewport events.*
_Note: all will enable all o-viewport events._
```js
import oViewport from './../main.js';
import oViewport from '@financial-times/o-viewport';

@@ -38,5 +38,5 @@ // Fire for orientation events.

### `o-viewport#stopListeningTo(eventType)`
Remove the attached listener from the window for the named event [`resize`, `scroll`, `orientation`, `visibility` or `all`].
Remove the attached listener from the window for the named event \[`resize`, `scroll`, `orientation`, `visibility` or `all`\].
*Note: all will disable all o-viewport events.*
_Note: all will disable all o-viewport events._

@@ -79,4 +79,4 @@ ```js

### `o-viewport#setThrottleInterval(eventType, interval)` *Product use only*
Sets the debounce/throttle interval for a given event [`scroll`, `resize` or `orientation`].
### `o-viewport#setThrottleInterval(eventType, interval)` _Product use only_
Sets the debounce/throttle interval for a given event \[`scroll`, `resize` or `orientation`\].
As a shorthand, calling `setThrottleInterval` with 1 - 3 numbers will set the intervals for `scroll`, `resize` and `orientation` in that order e.g. `setThrottleInterval(100, undefined, 300)` is equivalent to:

@@ -100,3 +100,3 @@

```js
import oViewport from './../main.js';
import oViewport from '@financial-times/o-viewport';

@@ -118,23 +118,23 @@ // Fire for all viewport events.

- No additional properties.
- No additional properties.
### `oViewport.orientation`
- data.orientation: 'portrait' or 'landscape'
- data.orientation: 'portrait' or 'landscape'
### `oViewport.visibility`
- data.hidden: true or false
- data.hidden: true or false
### `oViewport.scroll`
- data.scrollLeft: unitless px value of scroll position
- data.scrollTop: unitless px value of scroll position
- data.scrollHeight: unitless px value of scroll height
- data.scrollWidth: unitless px value of scroll width
- data.scrollLeft: unitless px value of scroll position
- data.scrollTop: unitless px value of scroll position
- data.scrollHeight: unitless px value of scroll height
- data.scrollWidth: unitless px value of scroll width
## Throttling
* `oViewport.resize`, `oViewport.orientation` and `oViewport.visibility` are debounced i.e. if the native event fires several times in quick succession the custom event will fire only once `n` milliseconds after the last event, where `n` is the throttle interval
* `oViewport.scroll` is throttled i.e. if the native `scroll` event fires several times in quick succession the custom event will fire at most once every `n` milliseconds, where `n` is the throttle interval
- `oViewport.resize`, `oViewport.orientation` and `oViewport.visibility` are debounced i.e. if the native event fires several times in quick succession the custom event will fire only once `n` milliseconds after the last event, where `n` is the throttle interval
- `oViewport.scroll` is throttled i.e. if the native `scroll` event fires several times in quick succession the custom event will fire at most once every `n` milliseconds, where `n` is the throttle interval

@@ -152,5 +152,5 @@ Use the [setThrottleInterval](#o-viewportsetthrottleintervaleventtype-interval-product-use-only) method to customise throttling.

----
***
## License
## Licence

@@ -157,0 +157,0 @@ Copyright (c) 2016 Financial Times Ltd. All rights reserved.

@@ -1,2 +0,2 @@

import * as Utils from 'o-utils';
import * as Utils from '@financial-times/o-utils';

@@ -3,0 +3,0 @@ let debug;

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