A very simple image slider that will responsively work with images of any size or shape

Overview

Square1

A very simple image slider that will responsively work with images of any size or shape. requires jQuery

Demo

Installation

  1. Link to jQuery

     <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
    
  2. Link to the Square1 JS and CSS

     <link rel="Stylesheet" href="square1/square1.min.css" type="text/css" />
     <script src="square1/square1.min.js"></script>
    
  3. Turn your images into a slideshow

    HTML:

    You can create a slideshow from a list of images:

     <div class="slideshow">
     	<img src="image1.png" alt="Caption 1">
     	<img data-src="image2.png" alt="Caption 2">
     	<img data-src="image3.png" alt="Caption 3">
     </div>
    

    Note: Appending data- to the 'src' and 'srcset' attributes will enable async loading (eg. data-src="image1.png").

    OR, you can include slides as HTML content elements. The img tag inside the slide will be used as the slide's background:

     <div class="slideshow">
     	<div>
     		<img src="image1.png" alt="Caption 1">
     		<h3>Slide Title</h3>
     	</div>
     	<div>
     		<img src="image2.png" alt="Caption 2">
     		<h3>Slide Title</h3>
     	</div>
     	<div>
     		<img src="image3.png" alt="Caption 3">
     		<h3>Slide Title</h3>
     	</div>
     </div>
    

    Additionally, if you are using the default "cover" fill mode to scale your images, you can set the point from which the image should scale from by adding the 'scale-from' attribute to your images. You can use any values that work with the CSS background-position property.

     <img src="image1.png" alt="Caption 1" scale-from="right top">
     <img data-src="image2.png" alt="Caption 2" scale-from="center bottom">
     <img data-src="image3.png" alt="Caption 3" scale-from="left bottom">
    

    JS:

     $(function() {
     	$('.slideshow').square1();
     });
    

Slideshow Options

All modifications to how the slideshow runs are optional. To change the default behavior, simply add the options you want to change to the square1() function like so:

$('.slideshow').square1({
	slide_duration: 8000,
	dots_nav: 'hover'
});

Here are all of the options with their default values:

width: 			$(_this).width(), 	// options: any CSS measurement. Blank values will default to whatever is set in CSS, or 'auto' if no CSS is set.
height: 		$(_this).height(),  	// options: any CSS measurement. Blank values will default to whatever is set in CSS, or the height of the first image if no CSS is set.
animation: 		'fade', 		// Transition animation style. Values: 'fade' or 'slide'
fill_mode: 		'cover', 		// Determines how images fill slideshow. Values: 'contain', 'cover', or pixel/percent value
scale_from: 		'center', 		// Values: all values that work for CSS background-position property (eg. 'right bottom', '100px 300px', etc.). Default set to 'center center' in CSS
background:		'none',			// Set slideshow background color. Values: any CSS color or valid CSS background value
auto_start: 		true,			// Set whether slideshow autoplays or not. Values: true/false
start_delay: 		0, 			// If auto_start is true, set how long to wait before slideshow starts. Values: ms
slide_duration: 	4000, 			// Amount of time each slide is shown before progressing to next. Values: ms
transition_time: 	500, 			// Amount of time it takes to transition from one slie to next. Values: ms
pause_on_hover: 	true,			// Pause autoplay if user hovers mouse over slideshow. Values: true/valse
keyboard: 		true,			// Allow users to control slideshow with arrow keys. Will automatically add slideshows into keyboard tab order. Values: true/valse
gestures: 		true,			// Allow users to control slideshow with touch gestures (swipe left/right). Values: true/valse
lazy_load: 		false,			// Enabling this will load images as they are needed instead of on page load
theme:			'dark',			// Set color palette of slideshow UI elements. Values: 'dark', 'light'
prev_next_nav: 		'inside', 		// How to display (or not) the arrow nav buttons. Values: 'inside', 'outside', 'hover', 'none'
dots_nav: 		'inside', 		// How to display (or not) the dot nav buttons. Values: 'inside', 'outside', 'hover', 'none'
caption: 		'outside', 		// How to display (or not) image captions. Values: 'inside', 'outside', 'hover', 'none'

// Callback functions
onLoad: 		function() {},		// Triggered when slideshow has completed loading
onPlay: 		function() {},		// Triggered when slideshow starts playing
onStop: 		function() {},		// Triggered when slideshow stops playing
onChange: 		function() {}		// Triggered after slide has changed

Slideshow Remote Control Functions

You can also control any Square1 slideshow remotely via JS:

// Start slideshow
$('.slideshow').square1('play');

// Stop slideshow
$('.slideshow').square1('stop');

// Go to next slide
$('.slideshow').square1('next');

// Go to previous slide
$('.slideshow').square1('prev');

// Jump to slide N (or any integer);
$('.slideshow').square1(5);

Other Settings

If you are using the default "cover" fill mode to scale your images, you can set the point from which the image should scale from (ie. which corner of the image will be pinned in place if parts of the image need to be scaled and cropped). You can use any values that work with the CSS background-position property.

And you can set this on an image-by-image basis by adding the 'scale-from' attribute to your images (resize your browser to see the result):

<img src="image1.png" alt="Caption 1" scale-from="top left" scale-from-mobile="bottom center">

Thanks

Thanks to http://isorepublic.com/ for the images

You might also like...

A Very Good Documentation Site created by the Very Good Ventures Team 🦄

A Very Good Documentation Site created by the Very Good Ventures Team 🦄

Very Good Docs Site Developed with 💙 by Very Good Ventures 🦄 A Very Good Docs Site created by the Very Good Ventures Team. Generated by the Very Goo

Nov 2, 2022

FortBlog adds a nice UI where you can manage a publication of any size with posts, pages, tags, and authors

FortBlog adds a nice UI where you can manage a publication of any size with posts, pages, tags, and authors

FortBlog adds a nice UI where you can manage a publication of any size with posts, pages, tags, and authors. You can add photos, code blocks, featured images, social media & SEO attributes, embedded HTML (YouTube Videos, Embedded Podcasts Episodes, Tweets, ...), and markdown! Dark & Light modes available so everyone is happy

Jan 2, 2023

A JavaScript Library To Make Your Work Work Easier/Faster

Functionalty.js (beta) About ✍️ This Is A JavaScript Library To Make Your Work Easier/Faster, You Can See Functionalty.js Website From Here Project Cr

Aug 30, 2022

A JavaScript Library To Make Your Work Work Easier/Faster

Functionality.js (beta) About ✍️ This Is A JavaScript Library To Make Your Work Easier/Faster, You Can See Functionalty.js Website From Here Project C

May 25, 2022

A JavaScript Library To Make Your Work Work Easier/Faster

A JavaScript Library To Make Your Work Work Easier/Faster

Functionality.js About ✍️ This Is A JavaScript Library To Make Your Work Easier/Faster, You Can See Functionalty.js Website From Here Project Created

Jun 23, 2022

Simple jQuery plugin that will allow users to zoom in your images, perfect for product images and galleries.

Simple jQuery plugin that will allow users to zoom in your images, perfect for product images and galleries.

Image Zoom (jQuery) Plugin Simple jQuery plugin that will allow users to zoom in your images, perfect for product images and galleries that is less th

Aug 3, 2022

The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.

The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.

Install | Documentation | Releases | Contributing Foundation is the most advanced responsive front-end framework in the world. Quickly go from prototy

Jan 4, 2023

A task board is considered to be one of the most successful tools for teamwork. Whether it's for work, a side project or even the next family vacation, we helps your team stay organized.We've got the flexibility and featuresto fit any team's style.

TaskBoard !Important! The project is in its initial stage. In the near future I'll be adding new features and upgrading the old ones to be more optima

Oct 11, 2022
Comments
  • lack of responsive (i.e. auto-scaling) <div> sizing resulting in Zero height container <div>

    lack of responsive (i.e. auto-scaling)

    I notice you expect a fixed div size to fit the images into (either height or width) - side effect being when you have a more responsive application (i.e. scaling to fit aspect ration), there is no size set on the enclosing

    . When the images is used as a background, the
    ends up with no height: property, hence ends up height: 0.

    I'll probably edit the code to check for this situation, and use aspect ratio info from the image (scaled to fit whichever maxwidth/maxheight may be set). Obviously, unless the user wants to allow for huge images, some sort of max setting is needed (even if by %). I can fork and create a pull request, if you're interested in the solution, else I'll just keep it on my own.

    opened by LeadDreamer 7
  • If you passed a string number it will redefine the slider

    If you passed a string number it will redefine the slider

    $('.slideshow').square1('2'); // cause recreation the slider

    can you add an exception for converting to number like parseInt() or just add notice that in your documentation must be a number

    opened by Tarek-Adra 2
  • Question about SRCSET

    Question about SRCSET

    Could you explain this line on the main page:

    Note: Appending data- to the 'src' and 'srcset' attributes will enable async loading (eg. data-src="image1.png").

    What is the srcset?

    Is adding data-src sufficent to get lazy loading to work?

    question 
    opened by jimgit 1
  • Images with different sizes

    Images with different sizes

    Hi, if loading images with different sizes, e.g. portrait and landscape the second is cut. The sizes should be the real ones, limited by width-max. Regards, EaBw

    opened by EaBw 1
Owner
Thom
Thom
Tooltip using only CSS and very low build size.

css-only-tooltip A very lightweight tooltip utitlity library, made using only CSS with dynamic light and dark themes. Insatallation Using npm $ npm in

Rajiv 4 Dec 11, 2022
A vscode extension to quickly print variable, variable type, tensor shape etc by using shortcuts

Quick Python Print This repo is inspired by "Python Quick Print". "Python Quick Print" can quickly print out variables on the console by using shortcu

weida wang 5 Oct 28, 2022
Full dynamic tool kit that is capable of deobfuscating and producing a javascript representation of Shape's Virtual Machine obfuscation

Shape Security Decompiler Tool-Kit This tool kit is capable of dynamically deobfuscating all versions of shape security's virtual machine interpreter

null 25 Dec 15, 2022
This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

Jquery-SingleImagePopup This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way

Rajan Karmaker 1 Aug 22, 2022
Easiest 1-click way to install and use Stable Diffusion on your own computer. Provides a browser UI for generating images from text prompts and images. Just enter your text prompt, and see the generated image.

Stable Diffusion UI Easiest way to install and use Stable Diffusion on your own computer. No dependencies or technical knowledge required. 1-click ins

null 3.5k Dec 30, 2022
MidJourney is an AI text-to-image service that generates images based on textual prompts. It is often used to create artistic or imaginative images, and is available on Discord and through a web interface here.

Midjourney MidJourney is an AI text-to-image service that generates images based on textual prompts. It is often used to create artistic or imaginativ

Andrew Tsegaye 8 May 1, 2023
Piccloud is a full-stack (Angular & Spring Boot) online image clipboard that lets you share images over the internet by generating a unique URL. Others can access the image via this URL.

Piccloud Piccloud is a full-stack application built with Angular & Spring Boot. It is an online image clipboard that lets you share images over the in

Olayinka Atobiloye 3 Dec 15, 2022
optimize image & upload file to cloud as image bed with tiny image automic.

Rush! 图片压缩 & 直传图床工具 这是一个兴趣使然的项目, 希望 Rush! 能让这个世界的网络资源浪费减少一点点 下载 Downloads 获取最新发行版 功能 Features 拖拽批量压缩图片, 支持格式 jpg/png/gif Drop to optimize, jpg/png/gif

{ Chao } 3 Nov 12, 2022
Reduce image size of 1000s of photos as a batch.

downsizer A tiny tool to reduce size of images in bulk. Helps you to bulk reduce size of images in a folder or individual images. Install Install Node

Vajahath Ahmed 2 Sep 15, 2022
An exercise in building a very minimal (and very stupid) in-memory SQL-like database for educational purposes.

Stupid Database This is an exercise in building a very minimal (and very stupid) in-memory SQL-like database for educational purposes. None of this co

Fabio Akita 196 Dec 20, 2022