Coder Social home page Coder Social logo

baslider's Introduction

Before and After Slider

This is my attempt at creating a before after slider that is both responsive and mobile-friendly.

Instructions

  1. Include 'baslider.js' on your page.

  2. Include 'baslider.css' on your page. You can also put this in your stylesheets if you fancy.

  3. Use the following format to create a slider:

    <div class="ba-slider">
    	<img src="img/slider-1a.jpg" alt="" />
    	<img src="img/slider-1b.jpg" alt="" />
    </div>
    
  4. Initialize BASlider on the windows load event:

     window.onload = function () {
     	$('.ba-slider').beforeAfter();
     }
    
  5. Celebrate!

Styling

Everything is CSS-driven. Pull up your inspector to tweak things to your liking.

Important classes:

  • '.ba-control-bar' - This is the line that splits your two images.
  • '.ba-control-handle' - This is a rectangular handle that is centered on the bar.
  • '.ba-left-arrow' & '.ba-right-arrow' - Arrows!

Note: The arrows are positioned absolute so if you change their dimensions you will have to change the margins that help center them.

baslider's People

Contributors

vincegonzalez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

baslider's Issues

consider 'use strict mode'

hello! I tried to install your plugin. and there was a problem with undefined variables (afterImageH, afterImageW, html) in 'use strict' mode. adding var before them helped to avoid errors. guess it would be nice to add this to your code

some optional settings, please?

it would be nice to be able to set starting point of the handler, for example, add or remove inertia and change behavior on click.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.