
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
source-media-query-loader
Advanced tools
Load image according to media queries and source nodes
npm i source-media-query-loader
Create instance with the callback
The callback receive an object with 8 properties
| Argument | Value |
|---|---|
| src | the image source |
| width | the image naturalWidth |
| height | the image naturalHeight |
| media | the media query |
| img | the image node |
| x | the x focus point ratio, default to .5 |
| y | the y focus point ratio, default to .5 |
| attributes | an object with the original attributes values |
var ql = QueryLoader(function(data) {
// {src:"image.jpg", width:320, height:240, media:"(max-width: 700px)", img:img, x:.5, y:.5, attributes:object}
console.log(data)
})
ql.start()
Add a source to the QueryLoader
Argument data can be a dom node or a javascript object
| Format | Value |
|---|---|
| node | <source src="image.jpg" media="(width <= 700px)"/> |
| object | {src:"image.jpg", media:"(width <= 700px)"} |
The properties src and media are required
Add all <source> child of node
<div id="ref">
<source src="small.jpg" x="0.663774403" y="0.375375375" hd="small-hd.jpg" media="(width <= 700px)"/>
<source src="medium.jpg" x=".363" y=".484257871" media="(900px >= width > 700px)" />
<source src="large.jpg" media="(width > 900px)" />
</div>
ql.find(document.querySelector('#ref'))
Start the instance
If node is defined, starts the lazy loading mode. The image will be loaded if node will enter the viewport
The argument offset is only used in lazy mode. The argument is optional, default to 200
Stop the instance. The callback will no more be invoked
Kill the instance. Listeners and memory are cleared
MIT
FAQs
Load image according to media queries and source nodes
The npm package source-media-query-loader receives a total of 3 weekly downloads. As such, source-media-query-loader popularity was classified as not popular.
We found that source-media-query-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.