Giter VIP home page Giter VIP logo

owlcarousel2's Introduction

YEAH SO THIS IS PRETTY MUCH DEAD, DO YOURSELF A FAVOR AND SWITCH TO tiny-slider




Owl Carousel 2

Touch enabled jQuery plugin that lets you create a beautiful, responsive carousel slider. To get started, check out https://owlcarousel2.github.io/OwlCarousel2/.

Notice: The old Owl Carousel site (owlgraphic [dot] com) is no longer in use. Please delete all references to this in bookmarks and your own products' documentation as it's being used for malicious purposes.

Quick start

Install

This package can be installed with:

  • npm: npm install --save owl.carousel or yarn add owl.carousel jquery
  • bower: bower install --save owl.carousel

Or download the latest release.

Load

Webpack

Add jQuery via the "webpack.ProvidePlugin" to your webpack configuration:

const webpack = require('webpack');

//...
plugins: [
    new webpack.ProvidePlugin({
      $: 'jquery',
      jQuery: 'jquery',
      'window.jQuery': 'jquery'
    }),
],
//...

Load the required stylesheet and JS:

import 'owl.carousel/dist/assets/owl.carousel.css';
import 'owl.carousel';

Static HTML

Put the required stylesheet at the top of your markup:

<link rel="stylesheet" href="/node_modules/owl.carousel/dist/assets/owl.carousel.min.css" />
<link rel="stylesheet" href="/bower_components/owl.carousel/dist/assets/owl.carousel.min.css" />

NOTE: If you want to use the default navigation styles, you will also need to include owl.theme.default.css.

Put the script at the bottom of your markup right after jQuery:

<script src="/node_modules/jquery/dist/jquery.js"></script>
<script src="/node_modules/owl.carousel/dist/owl.carousel.min.js"></script>
<script src="/bower_components/jquery/dist/jquery.js"></script>
<script src="/bower_components/owl.carousel/dist/owl.carousel.min.js"></script>

Usage

Wrap your items (div, a, img, span, li etc.) with a container element (div, ul etc.). Only the class owl-carousel is mandatory to apply proper styles:

<div class="owl-carousel owl-theme">
  <div> Your Content </div>
  <div> Your Content </div>
  <div> Your Content </div>
  <div> Your Content </div>
  <div> Your Content </div>
  <div> Your Content </div>
  <div> Your Content </div>
</div>

NOTE: The owl-theme class is optional, but without it, you will need to style navigation features on your own.

Call the plugin function and your carousel is ready.

$(document).ready(function(){
  $('.owl-carousel').owlCarousel();
});

Documentation

The documentation, included in this repo in the root directory, is built with Assemble and publicly available at https://owlcarousel2.github.io/OwlCarousel2/. The documentation may also be run locally.

Building

This package comes with Grunt and Bower. The following tasks are available:

  • default compiles the CSS and JS into /dist and builds the doc.
  • dist compiles the CSS and JS into /dist only.
  • watch watches source files and builds them automatically whenever you save.
  • test runs JSHint and QUnit tests headlessly in PhantomJS.

To define which plugins are build into the distribution just edit /_config.json to fit your needs.

Contributing

Please read CONTRIBUTING.md.

Roadmap

Please make sure to check out our Roadmap Discussion.

License

The code and the documentation are released under the MIT License.

owlcarousel2's People

Contributors

bnorus avatar daviddeutsch avatar gabehayes avatar graingert avatar greg5green avatar hellobart avatar iandonovan avatar joeyjoejoejr avatar keefyhub avatar keeganbrown avatar mtraynham avatar nervo avatar neysimoes avatar ngengs avatar nsams avatar owlcarousel2 avatar pajasevi avatar pascalporedda avatar patrickk avatar paulshen avatar peter-mouland avatar prayagverma avatar reubenbrown avatar rodrigoaguilera avatar rosemarystanley avatar shur avatar spitza avatar spyesx avatar tdecaluwe avatar tomjn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

owlcarousel2's Issues

jquery 1.71

FYI, I had an error using jQuery 1.71 - undefined property 'data' - I upgraded to 1.8 and everything works perfectly. Great plugin

Zepto.data issues?

Hello! I've read in the TODO list (index.html) there are some issues with the $.data object. What's exactly the issue?

From [http://zeptojs.com/#data]

Zepto's basic implementation of data() only stores strings. To store arbitrary objects, include the optional "data" module in your custom build of Zepto.

Have you tried using the data module?

CSS Transitions

Hi,
great, great work.

Question:
are you going to abandon the css transitions with "transitionStyle" ...?

preventClick remove method fail on destroy carousel

Hi, i have a carousel that must be a normal carousel under 768 but over it return at it's normal grid.
i have create a method that on windows resize it destroy and generate the carousel the carousel.

     $(window).on("resize", function(event){
            if( $(window).width() < 768 && widthController!="mobile"){
                  $carouselres.owlCarousel({
                ........
                 });
             });
    });


           $carouselres.on('onResponsiveAfter',function(){
             if( $(window).width() > 768 ){
                      $carouselres.data('owlCarousel').destroy();
              }
            });

it is destroyed corrcetly but after the precent Click funtion is not unbind on all the image(at random can be bind on 1 or 2 randomly on 3 element) that i have in the carousel and give me this error
carousel_error

the this value is null and it enter in the function even if the carousel not exist anymore

Someone have a solution or have similar behavior?

autoWidth + lazyLoad

OwlCarousel seems to have to load all images before being able to calculate widths while autoWidth is set to true. Maybe I'm just doing it wrong.
My setup basically looks like this:

<div class="owl-carousel">
    <div style="width: 500px;">
        <span class="caption">Caption A</span>
        <img class="owl-lazy" width="500" height="200" data-src="large-image.a.jpg" alt="">
    </div>

    <div style="width: 700px;">
        <span class="caption">Caption B</span>
        <img class="owl-lazy" width="700" height="200" data-src="large-image.b.jpg" alt="">
    </div>

    <div style="width: 1200px;">
        <span class="caption">Caption C</span>
        <img class="owl-lazy" width="1200" height="200" data-src="large-image.c.jpg" alt="">
    </div>

    <div style="width: 300px;">
        <span class="caption">Caption D</span>
        <img class="owl-lazy" width="300" height="200" data-src="large-image.d.jpg" alt="">
    </div>
</div>

The thing is that I already know how big my images are and don't have to wait for images to load. Also, I'm resizing images as the browser's window is resized, but that is working like it's supposed to do once the slider is initialised.
Is there a way to tell it to rely on widths I already provide?

Destroy method?

Hello,

is there a way to destroy the carousel once initialized?

Add more information on onChangeState Event

Hello,

First of thanks a lot for your effort on this amazing plugin. I am using the latest beta and everything works a charm. I am trying to create a theme with CSS3 transitions. Here is a working demo: http://ipanelthemes.com/owl2.demo/ Right now, the look and feel is only consistent when only 3 items are displayed.

As you can see I am using the onChangeState event to add a class to currently active slide so that it reverts back before actually going away from the screen. But I think I can make the animations better if the onChangeState event had more information in it, likely

  1. If the element has gone right or left.
  2. If it is fastrewind
  3. If it is fastforward.

I hope you can help me with that. Also I shall be glad to hear more ideas from you on how to make this a standard theme for which the look and feel will be consistent for any number of slides. If you need the files, then it is downloadable from this link: http://ipanelthemes.com/owl2.demo/download-3d-owl.zip

Once again, thanks for this amazing plugin.

Blank space before and after carousel

Hiya,
I've got this working nicely for what I need and it's great, thank you. There is blank spacing before and after my carousel, how can I can rid of this so that the carousel stops when the last photo is reached? see:

http://www.roweena.co.uk/projects/christina/archive-home.html

I am instantiating with:

$('#owl-demo-1').owlCarousel({
center: true,
items:3,
loop:false,
startPosition: 1,
margin:10,
navigation: true,
navText: ['<','>'],
naviSpeed: 450
});

Thank you :-)

Navigation not working

I know that it is just a beta, but it's the only carousel which feeds my needs so I want to use it right now. I'm using Firefox 28 and the navigation is not working. Neither the pagination nor the prev/next navigation.

In the first element of the carousel, does not set the class "owl-item.center".

If you have define 3 elements in the carolusel, but it only have 2, when you move it to the second element and return to the first one, the class "owl-item.center" is not set again.

The carousel configuration is:

center: true,
items: 3,
loop: true,
callbacks:true

One solution that i've found, was changing in the file "owl.corrusel.js" the next lines:
This are the original:

// if speed is 0 the set inMotion to false
if(this.speed.current !== 0 && this.pos.currentAbs !== this.pos.min){
    this.fireCallback('onTransitionStart');
    this.state.inMotion = true;
}

This are the lines modified:

// if speed is 0 the set inMotion to false
if(this.speed.current !== 0) {
    this.state.inMotion = true;
    if(this.pos.currentAbs !== this.pos.min){
        this.fireCallback('onTransitionStart');
    }
}

I'm working with the version 2.0.0-beta.1.8, and I want to know if this solution is correct and if this fix would have some impact in another place?.

Namespace events

Currently there are events like onChange – this is confusing because change already is a native DOM event (for form elements), and the on prefix is also confusing because it is used in various methods to handle events (eg DOM v1 input.onchange = handlerFn, jQuery $( input ).on( 'change', handlerFn )).

How about namespacing these events to owlCarousel in the style of the jQuery convention?

This way onChange would become change.owlCarousel.

Slides removed too early

I'm trying to do something similar to the BBC homepage carousel (http://www.bbc.co.uk/). The design requires that the prev/next slides are always in view (but obscured). At the moment, the beta will often remove the next slide from the DOM (i.e. if you trigger a move on the carousel then stop).

Is it possible to ensure that there's always at least three slides in the DOM (one either side of the current slide)?

Selecting pagination and navigation containers

Hi there, plugin works great for me, i wonder if there is possibility to set up containers where navigation and pagination would be created?
That would be awesome to set it up as a option while creating slider 👍

f.e.

<div id="slider">
<div class="slide>...</div>
<div class="slide>...</div>
<div class="slide>...</div>
</div>
<div id="pagination_slider">
</div>
<div id="navi_slider">
</div>

Resize Manipulation

Hi Bartosz,

First off, you've created an amazing product, thank you!

Is there a manipulation event I can use to manually fire the resize function that OwlCarousel uses for its responsiveness? I'm developing a site on which the carousels width dynamically changes without the browser-window being resized. So the browser stays the same size while the carousel itself is enlarged or reduced by clicking on a trigger. I've tried using the jQuery .resize(); function but doesn't seem to do the trick.

I've found that you've developed plugin manipulation functionality like owl.data('owlCarousel').updatePosition(); . Is there also an event for triggering the resize function?

Best Regards,
Max

Having the dots above the carousel (enhancement)

The other day I received a design of a page where the pagination dots of the carousel are located above the carousel itself (not below). For my surprise OwlCarousel doesn't have an option to do it through configuration (Or at least I didn't find anything).

The way I temporarily did it is the following, but it would be great if that option is included in a future :)

Just adding an option called something like "dotsAbove" (I'm not good naming variables):

var defaults = {
...
dotsAbove: false
}

And then add the conditional in the dots creator in order to append or prepend depending on the configuration:

 /**
 * Controls
 * @desc Calls controls container, navigation and dots creator
 * @since 2.0.0
 */
  Owl.prototype.controls = function(){
    var cc = document.createElement('div');
    cc.className = this.options.controlsClass;
   if (this.options.dotsAbove)
         this.dom.$el.prepend(cc);
   else
  this.dom.$el.append(cc);
    this.dom.$cc = $(cc);
};

We get something like:

image

Thats all of my humble opinion,
I love the new version!
Cheers!

Lazyload retina image not working?

Hi,

Using beta.1.8 and lazyLoad:true on the images in my carousel

<img class="owl-lazy" data-src-retina="http://placehold.it/552x720" data-src="http://placehold.it/276x360" class="thumbnail">

Images are being loaded correctly, but no retina versions on an iPhone and iPad I've tested on.

Is this working in the beta, or am I doing something wrong?

Thanks

UL LI Support

I have a widget that outputs ul li's. Will this new version support this markup?

SlideBy property not found

Hi, I tried using the SlideBy property, therefore specifying a number as a string 'page', but I have been unable to make it work. What can I be doing wrong?

Thanks!

responsive sortOptions

keys.sort(), to perform a numeric sort, you must pass a function as an argument when calling the sort method, now are sorted alphabetically, "960" comes before "1200"

Remove Auto Play

Hi!
Your plugin is really great but my client want to stop autoplay function.
I have two slides. Instead of an "automatic" transition he just want a "clicked" one. Just after the mouse click the slide 2 takes the place of the slide 1.

How can I change the code just to obtain this result?
Thanx

Image flicker on iPad when lazyContent is enabled

Using an iPad with the latest beta of the OwlCarousel2 (version 2.0.0-beta.1.8), am seeing a brief flicker after the image slide transition. Just for a fraction of a second, it will flash the image of the previous slide. I've set up two test pages, removing almost all html and markup to isolate the issue. If I switch lazyContent to false, it will not flicker. I don't see the flicker on other computers or devices (including iPhones). Only the iPad.

Here is the test page that flickers:
http://nopiece.com/javascripts/libs/owl-carousel/lazyContent-true.html

Here is the same page, with the lazyContent disabled:
http://nopiece.com/javascripts/libs/owl-carousel/lazyContent-false.html

Reproduce steps:

1: load the lazyContent-true.html test page
2: swipe to right

If it doesn't flicker, swipe back and forth a few times. Not every slide transition will flicker, but if you go through the slides, you should see it about half the time.

iPad info:
Model MD328LL/A (3rd Generation)
System version 7.1.1 (11D2010)
Safari "Mozilla/5.0 (iPad; CPU OS 7_1_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D201 Safari/9537.53"

Thanks, and I really appreciate the work you are doing on the slider. This early beta is already great!

Lazy Load Queue

Could you make it so there's an option to queue up the next slide with lazy load? I don't want to load every slide and bog down the website but I also don't want the user to have to wait if they do decide to click next.

Thanks. Great work.

responsive

on browser resize(1200 to 480) layout disturbs at "678".....
alternatively (480 to 1200) it goes right.

How add my own thumbnail to video

Hello, I want add my own thumbnail to video, I add class .owl-video with href on youtube, and add tag img to this url, but this is make error,
Tell please how add my own thumbnail to video?
Thank you!

Examinable plugin state object

owlCarousel v1 returned a plugin object (which could also be retrieved from jQuery .data( 'owlCarousel' ) which exposed internal state properties like visibleItems etc, which was very useful for writing plugins that incorporated owlCarousel into more complex UIs. I notice with owlCarousel v2 that the internal state Owl object looks very different, but it doesn't appear to be accessible either – the only exposed data appears to be the owlItem instances accessible from `$( 'owl-item' ).data( 'owlItem' ).

Are there any plans to expose internal state? For example, in my UI I could bind the following function to the old afterAction callback, and this would allow me to reflect the state of owlCarousel in other parts of the UI:

if( this.visibleItems.slice( -1 )[ 0 ] === this.itemsAmount - 1 ){
    $next.addClass( 'disabled' );
}
else {
    $next.removeClass( 'disabled' );
}

if( this.visibleItems[ 0 ] === 0 ){
    $prev.addClass( 'disabled' );
}
else {
    $prev.removeClass( 'disabled' );
}

More information about beforeMove/afterMove, new function "afterManualMove"

Hey,

it would be great if you could add some more information to the beforeMove/afterMove function or add a new function called afterManualMove or so. Because sometimes its good to know if the move was triggered by autoplay or by hand.

For example: i would like to stop the autoplay after the user did a manual move

In this case i could do something like that:

afterManualMove: function {
//stop the autoplay
}

Manual move means pushed on a owl-button or did the mouse/touch drag.

If it's allready build in, please let me know how to do that, i didn't figger it out how to :(

Thank you,
Pomm0

Videos in carousel

At the moment, if a video is playing (so it's been loaded) and the stopVideo function is called, then the video is stopped, but the iframe is also removed from the DOM completely. This means that the video position gets lost, and if it's played again has to be reloaded.

Once a video is loaded, there could be a pauseVideo function to just pause, rather than fully remove the video.

Specify containers for next/prev buttons and dot navigation

First off - this is a great plugin!

Some page layouts may require the carousel controls to be outside the container for the carousel itself. It would be great if you added this as an option, something like:

{
navContainer: 'some-class' // or even $('some-class'),
dotsContainer: 'another-class' // or $('another-class')
}

I recognize this may be an edge-case for most - but thought I'd put it out there anyway. I have a version working locally if you're interested (though it's rough for now)

lazyLoad bug

When using lazyLoad swipe image will be flashes.

iOS7 safari.

Navigation & dots not working (IE 11)

Hello, this is a grat carousel, I really like it and started using it for a project, but I found a problem testing it on IE 11.

The navigation and the dots pagination doesn't work. The two of them are correctly visible, but when clicked they didn't work.

The mouse drag works fine.I didn't have this problem in Firefox and Chrome.
I'm using win 7.

Another question, not related whit this problem: is there any way to change the easing of the transition? I wold like a linear transition instead of the actual swing, but couldn't find the way of changing it.

`stopVideo` called too often

Related to #22. When a video is playing, and the carousel moves (even if the video stays in view, or the carousel doesn't actually change slides) then the stopVideo function is called. Is there a way to ensure that the video is only paused/stopped when it is moved from view?

Reference to carousel in callback functions

In the previous version, you could reference this.owl in a callback. This meant you could access the baseElement to work out which carousel fired the event and manipulate the DOM around it.

Unless I'm missing it (likely), this information is no longer exposed anywhere, so with the callbacks (specifically info) it's impossible to know which carousel on the page triggered the event.

Some suggestions

Can you consider adding?

  • vertical scroll
  • Multi Image delay load

"mouseDrag:false" causes selection of all text

When setting option "mouseDrag:false", user selection goes weird, it selects entire text on the screen. I think the problem is with "user-select: all" in owl.carousel.css

I changed it as "user-select: auto". This worked for me.

mouseDrag: false, unable to select text

Hello!

I've noticed this is an old bug, which affects OwlCarousel(1) too. I hope in v.2 will be fixed :)

The issue is really simple: even if you set mouseDrag to false, you're not able to select the text within the owl elements. I think you should be able to, if the option is turned off.

infinite loop not working with 5 items ?

Hello
I'm not able to make carousel work in infinite loop with 5 items visibles (on total of 5 items).

This is my code :
$('#round').owlCarousel({
items:5,
loop:true,
merge:true,
center:true,
responsiveClass:true,
mouseDrag:true,
touchDrag:true,
pullDrag:true,
freeDrag:false,
//margin:5,
callbacks:true,
navigation:true,
URLhashListener:true,
dots:false,
//autoplayHoverPause:true,
startPosition: 'URLHash'
});
I use owl2 beta 1.5
I precise that one previous version of this plugin (beta 1.0) worked great with 5 items but did a fast rewind when last item + 1 is active.

An other pb is : next / previous buttons not working under IE11
Thanks =)

PS : great job ! owl carousel is one of my favorite jaquery plugin !

External elements with fixed background blank when transitioning

Hello!

This happened before in OwlCarousel (1) and I sorted it out, the problem is: I don't remember how :P

What's wrong? I've got a series of sections with background-attachment: fixed. When I start the animation though the next sections's background will temporarily disappear. You can see the odd behavior following this link (resize the screen so that multiple carousel pages are available, then scroll a little bit to see the next section and click on the prev/next buttons).

Adding disabled navigation

I have suggestion adding disabled navigation if total items = visible items
In function:

Owl.prototype.updateNavigation

add:

if (this.pos.current === this.pos.max) {
     this.dom.$navNext.addClass('disabled');
}

and add css style for .disabled

opacity: 0.5;
cursor: default;

Horizontal Center Items When Less Than 'Full'

Hi there, amazing plugin.

I'm trying to figure out how to center all the items within a carousel if there's not enough items to fill it up. I'm using Owl Carousel to house the thumbnails for a video playlist.

For example, if my carousel has enough width to contain 8 thumbnails, but there's only 4 items in any given playlist, is there a way to have those 4 thumbnails center within the carousel?

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.