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

img-comparison-slider

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

img-comparison-slider

Stencil Component Starter

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
decreased by-4.64%
Maintainers
1
Weekly downloads
 
Created
Source

img-comparison-slider

Browsers support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari
Samsung
Samsung
IE11 (limited), Edgelast 2 versionslast 2 versionslast 2 versionslast 2 versionslast 2 versions

Features

  • 📱 Looks great on mobile devices
  • ⌨️ Keyboard support
  • ☁️ Easy to install
  • 🧩 Web component. Works with HTML, React, Angular, or Vue

Installation

HTML

<script src="https://unpkg.com/img-comparison-slider@^1/dist/img-comparison-slider.js"></script>

<img-comparison-slider>
  <img slot="before" src="before.jpg">
  <img slot="after" src="after.jpg">
</img-comparison-slider>

React

yarn add img-comparison-slider
// index.js
import { defineCustomElements as defineImgComparisonSlider } from 'img-comparison-slider/loader';

defineImgComparisonSlider(window);
render() {
    return (
      <img-comparison-slider>
        <img slot="before" src="before.jpg">
        <img slot="after" src="after.jpg>
      </img-comparison-slider>
    )
}

Angular

npm install --save img-comparison-slider

CUSTOM_ELEMENTS_SCHEMA should be added into the AppModule and in every other modules that uses img-comparison-slider:

import { BrowserModule } from '@angular/platform-browser';
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, FormsModule],
  bootstrap: [AppComponent],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}

Define slider in main.ts:

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

// Note: loader import location set using "esmLoaderPath" within the output target confg
import { defineCustomElements as defineImgComponentSlider } from 'img-comparison-slider/loader';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.log(err));
defineImgComponentSlider(window);

Vue

npm install --save img-comparison-slider

Steps to reproduce

import Vue from 'vue';
import App from './App.vue';

import { applyPolyfills, defineCustomElements } from 'img-comparison-slider/loader';

Vue.config.productionTip = false;

// Tell Vue to ignore all components defined in the test-components
// package. The regex assumes all components names are prefixed
// 'test'
Vue.config.ignoredElements = [/test-\w*/];

// Bind the custom elements to the window object
applyPolyfills().then(() => {
  defineCustomElements(window);
});

new Vue({
  render: h => h(App)
}).$mount('#app');

FAQs

Package last updated on 10 Aug 2019

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