Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
vue-lazy-background-images
Advanced tools
A simple Vue component for lazy loading background components.
This component is only for background images and does not support anything other than that.
npm install --save-dev vue-lazy-background-images
Import the component
import VueLazyBackgroundImages from 'vue-lazy-background-images'
Register the component
Vue.component('lazy-background', VueLazyBackgroundImages)
And put into your DOM
<lazy-background
:image-source="backgroundImage"
loading-image="/img/loading.svg"
error-image="/img/error.png"
image-class="cam-viewport"
background-size="cover"
:image-success-callback="successCallback"
:image-error-callback="errorCallback">
</lazy-background>
And get this out
<div data-width="640" data-height="360" data-state="loaded" class="cam-viewport loaded" style="background-image: url("http://my-site.com/test-image.png"); background-size: cover"></div>
You can see the image-source in the above example is a computed property, although it doesn't have to be.
The callbacks in the above example are bound to data()
Width and height are for the image not the containing div.
cover
)The component attaches its state as a class, as well as a data- attribute
called state
There are 3 states, loading, loaded, and error
There are no events that get emitted, you can access either the classlist or the dataset to see what state your image is in.
There will be 2x data- attributes on your rendered - width
and height
which
is the dimensions of the actual image (not the rendered div)
This is cover
by default although it can be overridden.
You can pass in events to trigger on success and failure. These are completely optional and are not required for this to work.
Contributions welcome, as long as they are related to background images. Enjoy the component
FAQs
Lazy background images. Only background images.
We found that vue-lazy-background-images 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.