• This repository has been archived on 06/May/2021
  • Stars
    star
    1,581
  • Rank 29,599 (Top 0.6 %)
  • Language
    JavaScript
  • License
    GNU General Publi...
  • Created about 10 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Quite simply the ideal Image Slider in vanilla JS.

Ideal Image Slider

The aim behind the Ideal Image Slider is to create a slider which has just the right amount of features, with no bloat and be easy to extend so that more features can be added as "extensions". Here are the ideals and core features I wanted to include:

  • HTML5 (SEO optimised)
  • CSS3 transitions (a few simple transitions like slide/fade)
  • Left/Right navigation (including touch/swipe support)
  • Responsive
  • HiDPI (retina) support
  • ARIA support
  • Extremely simple to setup (no dependencies)
  • Very extensible
  • Uses progressive enhancement
  • Open source (goes without saying)

And, as an example, here are some features that should not be in the core and could be optional extensions:

  • Themes or skins
  • More transitions
  • Bullet navigation
  • Thumbnail navigation
  • Full screen slider
  • Video/Audio support
  • etc...

Read the original blog post β†’

Demos

Extensions

Requirements

  • None

Ideal Image Slider is written in vanilla JS and has no dependancies.

Getting Started

To install the slider you can either manually download this repository or you can use Bower and run the following command:

bower install ideal-image-slider --save

Next you need to include the CSS file in the <head> section of your HTML and you need to include the script before the </body> tag in your HTML. Note you can optionally include a theme CSS file in the <head> too.

<html>
<head>
	...
	<link rel="stylesheet" href="/path/to/ideal-image-slider.css">
	<link rel="stylesheet" href="/path/to/themes/default/default.css">
	...
</head>
<body>
	...
	<script src="/path/to/ideal-image-slider.js"></script>
</body>
</html>

Next you need to set up your slider HTML where you want it to appear in your page. It should look something like this:

<div id="slider">
	<img src="img/1.jpg" alt="Minimum required attributes">
	<img data-src="img/2.jpg" src="" alt="Use data-src for on-demand loading">
	<img data-src="img/3.jpg" data-src-2x="img/[email protected]" src="" alt="Use data-src-2x for HiDPI devices">
	<a href="http://example.com"><img data-src="img/4.jpg" src="" alt="Links work too"></a>
	...
</div>

There a few things to note about the structure of the images in your slider:

  • This is an image slider, so only images are supported. Any other content will be removed.
  • You can use the data-src attribute to load your images "on-demand" (i.e. images are not loaded until they are required).
  • The first image should not use data-src so it is loaded if no JS is detected.
  • If you specify a data-src-2x image, it will be used on devices that support HiDPI (such as Apple's retina devices).

Finally you can create your slider by using the following Javascript:

new IdealImageSlider.Slider('#slider');

If you want to tweak the settings or use the slider API it would look more like:

var slider = new IdealImageSlider.Slider({
	selector: '#slider',
	height: 400, // Required but can be set by CSS
	interval: 4000
});
slider.start();

Note: If you don't pass a height to the Javascript constructor you must set it in your CSS.

Settings

Setting Default Value Description
selector '' CSS selector for the slider
height 'auto' Height of the slider. Can be 'auto' (height changes depending on the height of the slide), a fixed px value (e.g. 400) or an aspect ratio (e.g. '16:9')
initialHeight 400 If height is 'auto' or an aspect ratio this is the height of the slider while the first image is loading
maxHeight null If height is 'auto' or an aspect ratio this is an optional max height in px for the slider (e.g. 800)
interval 4000 Time (in ms) to wait before changing to the next slide
transitionDuration 700 Duration (in ms) of animated transition
effect 'slide' Transition effect (slide/fade by default)
disableNav false Toggle the previous/next navigation (also disables touch and keyboard navigation)
keyboardNav true Toggle keyboard navigation
previousNavSelector '' Selector for custom previous nav element
nextNavSelector '' Selector for custom next nav element
classes {...} List of classes to be used by slider. Probably shouldn't be changed

Events

Event callback functions can be passed in with the settings. For example:

new IdealImageSlider.Slider({
	selector: '#slider',
	onStart: function(){
		console.log('onStart');
	}
});
Event Description
onInit Callback that fires when slider and first image have loaded
onStart Callback that fires when slider has started playing
onStop Callback that fires when slider has stopped playing
onDestroy Callback that fires when slider is destroyed
beforeChange Callback that fires before a slide has changed
afterChange Callback that fires after a slide has changed

API

To use the API methods you must store the slider object. For example:

var slider = new IdealImageSlider.Slider('#slider');
slider.start();
Method Description
start() Start the slider. Note the slider will automatically be stopped when navigation is used
stop() Stop the slider
previousSlide() Change to the previous slide
nextSlide() Change to the next slide
gotoSlide(index) Change to a specific slide (1 indexed)
destroy() Destroy the slider
get(attribute) Get an attribute value (attributes are mostly used internally)
set(attribute, value) Set an attribute. Can be useful for storing custom data

Browsers

Ideal Image Slider has been tested on:

  • Chrome
  • Firefox
  • Safari (Desktop + Mobile)
  • Opera
  • IE9+

Contribute

So you want to help out? That's awesome. Here is how you can do it:

If you are submitting a pull request please adhere to the existing coding standards used throughout the code and only submit 1 feature/fix per pull request. Pull requests containing multiple changes will be rejected.

Note that if you submit a pull request you are aware that you are contributing to both the free (open source) version and the proprietary (commercial) version of the codebase and that your work may make money for Dev7studios.

Credits

Ideal Image Slider was created by Gilbert Pellegrom from Dev7studios. Released under the GPL license.

Other Projects

Check-out other stuff that we are working on :

More Repositories

1

Nivo-Slider-jQuery

Nivo Slider - The Most Awesome jQuery Image Slider
JavaScript
1,248
star
2

carouFredSel-jQuery

A circular, responsive carousel plugin built using the jQuery.
JavaScript
321
star
3

neve

A fast, lightweight, AMP ready WordPress theme built with speed and usability in mind.
PHP
262
star
4

wp-maintenance-mode

Adds a splash page to your site that lets visitors know your site is down for maintenance. Full access to the back- & front-end is optional.
PHP
159
star
5

Nivo-Lightbox-jQuery

A simple, flexible, responsive, retina-ready jQuery lightbox plugin.
JavaScript
157
star
6

otter-blocks

Create beautiful and attracting posts, pages, and landing pages with Gutenberg Blocks and Template Library by Otter.
PHP
135
star
7

visualizer

WordPress Visualizer plugin is a simple, easy to use and quite powerful tool to create, manage and embed interactive charts into your WordPress posts and pages.
PHP
97
star
8

wp-menu-icons

Easily add icons to your nav menu items.
PHP
76
star
9

themeisle-icons

A free icon font from ThemeIsle
CSS
73
star
10

logo-maker

Another Logo Maker app made for fun and profit.
TypeScript
70
star
11

feedzy-rss-feeds

FEEDZY RSS Feeds is an easy-to-use plugin giving you RSS aggregator and autoblogging functionality. Bring the best RSS feeds to your site.
PHP
60
star
12

flat

For issues/contribution please check the main repo here:
CSS
58
star
13

zerif-lite

[RETIRED] Don't update the theme on wp.org from here or from themeisle!
PHP
54
star
14

gutenberg-blocks

Magic dust that powers thousands of Gutenberg sites on the world-wide-web. Merged with the otter-blocks repository.
JavaScript
48
star
15

Parallax-One

🚩 [RETIRED] DEPLOYMENT is disabled, if you need to make a release, contact Marius.
PHP
40
star
16

optimole-wp

PHP
30
star
17

FlatX

CSS
27
star
18

wp-product-review

Easily turn your basic posts into in-depth reviews with ratings, pros and cons and affiliate links .
PHP
25
star
19

templates-patterns-collection

JavaScript
21
star
20

jadrowp

WordPress FSE Theme
PHP
21
star
21

media-manager-plus

Upgrade the WordPress Media Manager and add support for Flickr, Instagram, 500px, Facebook etc.
PHP
15
star
22

themeisle-companion

Orbit Fox Companion
PHP
12
star
23

customizer-controls

A collection of cool customizer controls.
JavaScript
12
star
24

oria

PHP
11
star
25

zillah

🚩 [RETIRED]Zillah free theme
PHP
11
star
26

action-wordpress-theme-deploy

Deploy your theme to the WordPress.org repository using GitHub Actions
Shell
10
star
27

gutenberg-animation

A composer package for CSS Animations for Gutenberg Blocks. Merged with the otter-blocks repository.
JavaScript
10
star
28

themeisle-sdk

ThemeIsle SDK library
PHP
8
star
29

hestia

Updated Changelog: https://bit.ly/2T73vWG
8
star
30

blocks-animation

Awesome CSS animations for Gutenberg Blocks. Merged with the otter-blocks repository.
PHP
8
star
31

oblique

🚩 [RETIRED]grunt version::patch for version increase
PHP
7
star
32

logo-maker-pwa

Logo Maker as PWA
TypeScript
7
star
33

neve-fse

The theme you already love, built for Full-Site Editing
PHP
6
star
34

tweet-old-post

Plugin to tweet about your old posts to get more hits for them and keep them alive.
JavaScript
6
star
35

blocks-export-import

Blocks Export Import allows to Export and Import blocks as JSON in Gutenberg Block Editor. Merged with the otter-blocks repository.
JavaScript
6
star
36

navmenu-addon-for-elementor

PHP
5
star
37

islemag

🚩 [RETIRED]
PHP
5
star
38

nivo-slider-lite

The official WordPress plugin for the Nivo Slider (Lite)
PHP
5
star
39

flymag

🚩 [RETIRED]
PHP
5
star
40

woocommerce-product-addon

PPOM for WooCommerce
PHP
4
star
41

blocks-css

CSS Editor for Gutenberg Blocks. Merged with the otter-blocks repository.
PHP
4
star
42

optimole-php-sdk

PHP
4
star
43

gutenberg-css

A composer package for CSS Editor for Gutenberg Blocks. Merged with the otter-blocks repository.
JavaScript
4
star
44

intergeo-maps

PHP
3
star
45

optimole-laravel

PHP
3
star
46

gutenberg-templates

A repository to serve assets for Gutenberg Templates.
3
star
47

elementor-templater

PHP
3
star
48

icon-picker

Issues should be opened on https://github.com/Codeinwp/wp-menu-icons
PHP
3
star
49

raft

Issues should be created in https://github.com/Codeinwp/otter-blocks
PHP
3
star
50

pirate-forms

grunt version::patch ( for versioning )
PHP
3
star
51

llorix-one-lite

🚩 [RETIRED] DEPLOYMENT is disabled, if you need to make a release, contact Marius.
PHP
3
star
52

reviewgine-affiliate

Reviewgine Affiliate is a free WordPress theme built for the next generation of affiliate marketing websites. With a great SEO, cutting-edge design, integrated widgets, advanced theme options and an advanced review system is all you need for starting making money online.
CSS
3
star
53

ti-starter-sites

TI Starter Sites library resources
2
star
54

imagga

PHP
2
star
55

roda

🚩 [RETIRED]
PHP
2
star
56

grunt-theme-fleet

Npm module for grunt default tasks used in themeisle themes
JavaScript
2
star
57

hooks-assistant

Plugin for using products hooks and filters
PHP
2
star
58

riverbank

PHP
2
star
59

azera-shop

🚩 [RETIRED]
PHP
2
star
60

elementor-extra-widgets

Issues should be created on https://github.com/Codeinwp/themeisle-companion
PHP
2
star
61

wp-privacy-extended

PHP
2
star
62

themeisle-content-forms

Issues should be opened here https://github.com/Codeinwp/themeisle-companion
PHP
2
star
63

custom-css

The Custom CSS plugin allows you to customize the appearance of your theme without the need to create a child theme or worry about theme updates overwriting your customizations.
JavaScript
2
star
64

gha-pr-check-helper

Allows you to run a job that will check if all checklist items from a PR are solved and label the PR accordingly.
JavaScript
1
star
65

templates-directory

Any issue should be created on https://github.com/Codeinwp/themeisle-companion
PHP
1
star
66

front-end-internship-api

Front-end internship test API.
1
star
67

front-end-internship-test

ThemeIsle front-end internship test.
1
star
68

handbook-of-money

Tips & Trick - resources for you in which you can learn to lose your hard worked money
1
star
69

neve-child

Basic Neve Child Theme. Issues should be opened on https://github.com/Codeinwp/neve
PHP
1
star
70

tiny-hestia

Hestia Child Theme with minimal load
PHP
1
star
71

pirate-switch

Plugin for style/demos switching on demo
PHP
1
star
72

themeisle-onboarding

PHP
1
star
73

vertimagazine

🚩 [RETIRED]
PHP
1
star
74

wp-thememods-api

Helper plugin which allows setting up theme mods via REST API.
PHP
1
star
75

elementor-addon-widgets

PHP
1
star
76

Email-Sync

Sync your WordPress user's email addresses with your favorite newsletter software (e.g. MailChimp)
PHP
1
star
77

fork

PHP
1
star
78

load-fa

Force the loading of FontAwesome 5 and the compatibility with FontAwesome 4
PHP
1
star
79

responsive-boat

PHP
1
star
80

site

PHP
1
star
81

domainwheel-theme

PHP
1
star
82

typewriter

Typewriter replaces the Visual Editor with a simple Markdown editor for your posts and pages.
PHP
1
star
83

Snippet-Library

Issues should be opened on https://github.com/Codeinwp/wp-maintenance-mode
PHP
1
star
84

ZBlackbeard

🚩 [RETIRED]
CSS
1
star
85

jaxon

PHP
1
star
86

llorix-one-companion

🚩 [RETIRED] Plugin to replace the Our Team, Our Services, and Testimonial sections from Llorix One
PHP
1
star
87

obfx-templates

1
star
88

minimagazine

🚩 [RETIRED]
JavaScript
1
star
89

cwp-youit

🚩 [RETIRED]
PHP
1
star
90

WooCommerce-Compare-List

PHP
1
star
91

orfeo

CSS
1
star
92

pirate-parrot

Pirate parrot is a plugin for Themeisle that allow customers to give access to their wordpress instances in order for the developers to fix the issues that they are encountering.
PHP
1
star
93

gutenberg-menu-icons

Just like before, but block-based. Merged with the otter-blocks repository.
JavaScript
1
star
94

adblock-notify-by-bweb

PHP
1
star