Giter Site home page Giter Site logo

scooch's Introduction

Scooch

A mobile-first content and image carousel.

NPM Code Climate Bower version

Demo

You can find a simple demo on the Documentation page. More demos can be found inside the examples folder in the repo. Run grunt examples to see them in Chrome (mobile device emulation is recommended).

Requirements

Zepto Support

Scooch supports Zepto up until v0.6.1 but is not actively developed for it. You should be able to use Scooch directly with Zepto. While we don't actively support Zepto for Scooch, we welcome any and all issues and PRs to help us make it work.

Installation

Scooch can be installed using NPM:

npm install scooch

Usage

<!-- include scooch.css -->
<link rel="stylesheet" href="scooch.css">
<link rel="stylesheet" href="scooch-style.css">

<!-- the viewport -->
<div class="m-scooch m-fluid m-scooch-photos">
  <!-- the slider -->
  <div class="m-scooch-inner">
    <!-- the items -->
    <div class="m-item m-active">
      <img src="image1.jpg">
    </div>
    <div class="m-item">
      <img src="image2.jpg">
    </div>
    <div class="m-item">
      <img src="image3.jpg">
    </div>
  </div>
  <!-- the controls -->
  <div class="m-scooch-controls m-scooch-bulleted">
    <a href="#" data-m-slide="prev">Previous</a>
    <a href="#" data-m-slide="1" class="m-active">1</a>
    <a href="#" data-m-slide="2">2</a>
    <a href="#" data-m-slide="3">3</a>
    <a href="#" data-m-slide="next">Next</a>
  </div>
</div>

<!-- include jquery.js -->
<script src="jquery.js"></script>
<!-- include scooch.js -->
<script src="scooch.js"></script>
<!-- construct the carousel -->
<script>$('.m-scooch').scooch()</script>

Classes

By default, items are center aligned and their width is determined by their content width and/or any styling that restricts their width.

To change the styling of the items, add the following classes to the viewport:

Class Description
.m-fluid Causes the width of items to resize to match the viewport width.
.m-center Causes the items to be center aligned, not left aligned (the default).

Methods

.scooch(options)

Constructs the carousel with specific options. Defaults are shown here.

$('.m-scooch').scooch({
      dragRadius: 10,
      moveRadius: 20,
      animate: true,
      autoHideArrows: false,
      rightToLeft: false,
      infinite: false,
      autoplay: false,
      classPrefix: "m-",
      classNames: {
        outer: "scooch",
        inner: "scooch-inner",
        item: "item",
        center: "center",
        touch: "has-touch",
        dragging: "dragging",
        active: "active",
        inactive: "inactive",
        fluid: "fluid"
    }
});

Options

The options object passed to Scooch during construction can configure its behaviour in the following ways:

Option Behaviour
dragRadius The size of the 'deadspace' when dragging before Scooch begins following cursor/finger
moveRadius The size of the 'deadspace' that must be exceeded before Scooch will move between items
animate Whether or not Scooch should animate the move between items
autoHideArrows Whether or not Scooch should apply the inactive class to its previous and next controls (indicated by [data-m-slide=prev] and [data-m-slide=next]) when at its "bounds"
rightToLeft Whether or not Scooch should treat "next" as left and "previous" as right
infinite Whether or not Scooch should loop on itself
autoplay: {interval: Number, cancelOnInteraction: Boolean} Autoplay through the Scooch, advancing items every interval milliseconds. cancelOnInteraction sets whether or not the autoplay terminates once a user interacts with it. Autoplaying Scooches will always appear to loop as if they are infinite until user interaction, at which point they resume the behaviour specified by their options
classPrefix What all Scooch's classes will be prefixed by
classNames What Scooch should reference as its class names

.scooch('next')

Moves the carousel one item to the right (or left if rightToLeft option is enabled).

$('.m-scooch').scooch('next');

.scooch('prev')

Moves the carousel one item to the left (or right if rightToLeft option is enabled).

$('.m-scooch').scooch('prev');

.scooch('move', x)

Moves the carousel to a index x (1-based).

$('.m-scooch').scooch('move', 1);

.scooch('unbind')

Removes event handlers bound on the carousel.

$('.m-scooch').scooch('unbind');

.scooch('bind')

Binds the event handlers on the carousel.

$('.m-scooch').scooch('bind');

.scooch('refresh')

Re-initialize carousel after new slides were added or removed

$('.m-scooch').scooch('refresh');

.scooch('destroy')

Removes the carousel and its event handlers from the DOM.

$('.m-scooch').scooch('destroy');

Events

The viewport emits the following events:

Name Arguments Description
beforeSlide previousIndex, newIndex Fired before the carousel moves.
afterSlide previousIndex, newIndex Fired after the carousel begins moving.

Browser Compatibility

Mobile Browsers

The following mobile browsers are fully supported:

Browser Version
Mobile Safari 3.1.3+
Android Browser 2.1+
Android Chrome 1.0+
Android Firefox 1.0+

The following mobile browsers have degraded support:

Browser Version
Windows Phone 7.5

Desktop Browsers

The follow desktop browsers are fully supported:

Browser Version
Safari 4.0+
Firefox 4.0+
Chrome 12.0+
Opera 12.0+
Internet Explorer 10.0+

The following desktop browsers have degraded support:

Browser Version
Internet Explorer 8.0,9.0
Firefox 3.5,3.6

Building a distribution

Requirements

Steps

  1. npm install
  2. grunt build

The build directory will be populated with minified versions of the css and javascript files and a .zip of the original source files (for distribution and use with whatever build system you might use).

License

MIT License. Scooch is Copyright © 2016 Mobify. It is free software and may be redistributed under the terms specified in the LICENSE file.

scooch's People

Contributors

cdegit avatar donnielrt avatar haroldtreen avatar highruned avatar jansepar avatar kpeatt avatar noahadams avatar scalvert avatar tedtate avatar uri 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

scooch's Issues

Does not work on iOS8

On request of Jansepar,

Neither doesn't Scooch carousel work on iPhone 6 models. Tried on https://mobify.github.io/scooch/ with Chrome and Safari and the javascript gets stuck after viewing 2nd slide.

FYI below my old report.

  • Petro

"Hello,

Just purchased iPhone 6 Plus and tested carousel on my website and and with your examples. You can only slide to the next slide once and then the slider will get absolutely stuck - cannot slide anywhere after that. Tested on latest Safari and latest Google Chrome. Obviously it works on other devices just perfect.

If there is any way to pull out some javascript debug reports or anything out of the phone please let me know and I will gladly help you out.

Best regards,
Petro Mäntylä"

**Bug Report** Flash Object in Slide doesnt receive Events

Hi,

nice Plugin!
We are using it and had an issue with an FlashPlayer in a Slide (Livestrem, HLS, JWPlayer) not getting any Events passed trough.

The start Function checks for touch devices and if not it prevents the Default.
Chrome and IE 11 (lower no testet) will also prevent passing the Event to the SWF Object (Firefox does)
so we added a check if the event target is a flash object and if so, dont prevent default.

~ Line 429
if (!has.touch && !("application/x-shockwave-flash" === e.target.type)) {
e.preventDefault();
}

Works like a charm.

Best Regards,
Simon

Prev/Next links should be disabled when appropriate

When the user is looking at the first item, we should disable the "Previous" link.

When the user is looking at the last item, we should disable the "Next" link.

We've been doing this programmatically, but it should really be built in.

Make Scooch compatible with stealjs

Feature Request

Make scooch compatible with stealjs in a donejs application.

Summary

I had to do a little shenanigans to get this to work with stealjs in a donejs application. It would be nice if this control worked out of the box in that environment. The CSS files will have to be included manually for instance.

Circular Loop

Is there a way to make it loop, so that after last item, first item is there

High-quality carousel images

The example images are less than good, since they're 300x300 images scaled up to 557x557 (at least in a desktop window). The source images are pretty cameraphone quality too, poor lighting and highly compressed.

Suggest using high-quality (professional) photography, and ensuring there are enough pixels for desktop sizes.

Disable carousel drag & opacity fade instead of horizontal movement/animation

Hey, I love how small and lightweight this is, but as I've been building out other sections of my site using Scooch, I've discovered my needs have expanded. I'm hoping some of this is possible using Scooch.

Is there a way to disable carousel dragging, so the carousel only fires via pager controls?

Is there a way to make the transition an opacity fade between m-items, instead of horizontal movement/animation?

Thanks in advance!

How to call event.

Hello ,

Can you please describe how can we call events(beforeSlide,afterSlide) in this plugin.

I used standard way to call these events but fails and also unable to found any help with other sources.

-Naitik

Vertical direction

Feature Request

Think a option to change direction of slider. Option for vertical. 👍

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.