Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container" data-ng-app="app">
  <div class="card" data-ng-controller="MainCtrl">
    <div class="card__header">
      <h3 class="card__heading">Angular Slider Directive</h3>
      <h4 class="card__heading--secondary">A Responsive Multi Item - Single Click Angular Slider</h3>
        </div>
    <div class="card__content">
      <mmb-slider 
        dots="true" 
        infinite="false" 
        speed=300 
        slides-to-show=5 
        touch-move="false" 
        slides-to-scroll=1
        list="items"
        class="slider one-time slick-slider">
      </mmb-slider>
    </div>
  </div>
</div>

              
            
!

CSS

              
                @import "compass"
@import "bourbon"
@import url(//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css)
@import url(https://fonts.googleapis.com/css?family=Open+Sans|Roboto:400,100,300,700,900|RobotoDraft:400,100,300,700,900|Old+Standard+TT|Raleway|Lobster)

// Units
// ================================================================================
$width__common             : 728px
$height__card              : 252px
$base__padding--size       : 20
$base__margin--size        : 20

// Colors
// ================================================================================
$color__primary            : #333333
$color__secondary          : #ABABAB
$color__accent             : #F6B94E
$color__foreground         : #F5F5F5
$color__background         : #FFFFFF

$color__border             : shade($color__foreground, 10%)

// Typography
// ================================================================================
$font__default             : 'Lobster', Helvetica, Arial, sans-serif !default
$font__weight--thin        : 100
$font__weight--light       : 300
$font__weight--normal      : 400
$font__weight--semibold    : 700
$font__weight--bold        : 900

// Helpers
// ================================================================================
%box-sizing
  -webkit-box-sizing: border-box
  -moz-box-sizing: border-box
  box-sizing: border-box
  
// Mixins
// ================================================================================
=prefixer($property, $value, $prefixes: webkit moz ms o)

  @each $prefix in $prefixes
    #{'-' + $prefix + '-' + $property}: $value

  #{$property}: $value

=radius($size)
  +prefixer(border-radius, $size)

=circle($size)
  +radius($size / 2)

=opacity($opacity)
  filter: unquote("progid:DXImageTransform.Microsoft.Alpha(Opacity=#{round($opacity * 100)})")
  opacity: $opacity

  //Hack IE6
  &.lt-ie7
    filter : alpha(opacity=#{round($opacity * 100)})
    zoom: 1

=position($position: 'rel')

  @if $position == 'abs'
    position: absolute

  @else if $position == 'rel'
    position: relative

  @else if $position == 'fix'
    position: fixed

=middle-center($position: 'abs')
  +position($position)
  top: 50%
  left: 50%
  -webkit-transform: translate(-50%, -50%)
  -moz-transform: translate(-50%, -50%)
  -ms-transform: translate(-50%, -50%)
  -o-transform: translate(-50%, -50%)
  transform: translate(-50%, -50%)

// Resets
// ================================================================================
button
  color: inherit
  font: inherit
  margin: 0
  verflow: visible
  text-transform: none
  -webkit-appearance: button
  cursor: pointer
  border: none
  
  &::-moz-focus-inner
    border: 0
    padding: 0
  
// Base Styles
// ================================================================================
html,
body,
h1,h2,h3,h4,h5,h6,p
  font-family: $font__default
  font-weight: $font__weight--thin
  color: $color__primary
  
.container
  @extend %box-sizing
  max-width: $width__common
  padding: 0
  margin: 0 auto
  
// Cards
// ================================================================================
.card
  width: auto
  height: auto
  padding: $base__padding--size + px
  background-color: $color__foreground
  
  &__header
    padding-bottom: $base__padding--size + 10 + px
    border-bottom: solid 1px $color__border
    
  &__heading
    font-size: 18px
    font-weight: $font__weight--normal
    line-height: 36px
    
  &__heading--secondary
    font-family: 'Raleway'
    font-size: 12px
    font-weight: $font__weight--light
    color: $color__secondary
    
  &__content
    padding: 30px 20px
    
// Slider Defaults
// ================================================================================

.slick-slider
  position: relative
  display: block
  box-sizing: border-box
  -webkit-touch-callout: none
  -webkit-user-select: none
  -khtml-user-select: none
  -moz-user-select: none
  -ms-user-select: none
  user-select: none
  -ms-touch-action: pan-y
  touch-action: pan-y
  -webkit-tap-highlight-color: transparent

.slick-list
  position: relative
  overflow: hidden
  display: block
  margin: 0
  padding: 0

  &:focus
    outline: none
    
  &.dragging
    cursor: pointer
    cursor: hand
    
.slick-slider .slick-track,
.slick-slider .slick-list
  -webkit-transform: translate3d(0, 0, 0)
  -moz-transform: translate3d(0, 0, 0)
  -ms-transform: translate3d(0, 0, 0)
  -o-transform: translate3d(0, 0, 0)
  transform: translate3d(0, 0, 0)

.slick-track
  position: relative
  left: 0
  top: 0
  display: block

  &:before,
  &:after
    content: ""
    display: table

  &:after
    clear: both

  .slick-loading &
    visibility: hidden
    
.slick-slide
  position: relative
  float: left
  height: 100%
  min-height: 1px
  
  [dir="rtl"] &
    float: right

  img
    display: block

  &.slick-loading img
    display: none

  display: none

  &.dragging img
    pointer-events: none
    
  .slick-initialized &
    display: block

  .slick-loading &
    visibility: hidden

  .slick-vertical &
    display: block
    height: auto
    border: 1px solid transparent
    
.slick-arrow.slick-hidden
  display: none

.slick-slide .badge
  +circle(80px)
  width: 80px
  height: 80px
  display: block
  position: relative
  margin: 0 auto
  text-align: center
  background-color: tint($color__accent, 30%)
  
.slick-slide .badge:before
  +middle-center
  font-size: 2em
  color: $color__foreground
  
// Slider Theme
// ================================================================================

$slider__arrow--prev            : "\f053" !default
$slider__arrow--next            : "\f054" !default

$slider__dot                    : "\f10c" !default
$slider__dot--active            : "\f111" !default
$slider__dot--size              : 10px !default

$state__opacity--default        : 0.5 !default
$state__opacity--hover          : 1 !default
$state__opacity--inactive       : 0.25 !default

.slick-prev,
.slick-next 
  position: absolute
  display: block
  height: 20px
  width: 20px
  line-height: 0px
  font-size: 0px
  cursor: pointer
  background: transparent
  color: transparent
  top: 50%
  -webkit-transform: translate(0, -50%)
  -ms-transform: translate(0, -50%)
  transform: translate(0, -50%)
  padding: 0
  border: none
  outline: none

  &:hover, &:focus 
    outline: none
    background: transparent
    color: transparent

    &:before 
      opacity: $state__opacity--default

  &.slick-disabled:before 
    color: $color__secondary
    
  &:before 
    font-family: 'FontAwesome'
    font-size: 20px
    line-height: 1
    color: $color__accent
    -webkit-font-smoothing: antialiased
    -moz-osx-font-smoothing: grayscale
    
.slick-prev 
  left: -25px
  [dir="rtl"] & 
    left: auto
    right: -25px

  &:before 
    content: $slider__arrow--prev
    [dir="rtl"] & 
      content: $slider__arrow--next
        
.slick-next 
  right: -25px
  [dir="rtl"] & 
    left: -25px
    right: auto

  &:before 
    content: $slider__arrow--next
    [dir="rtl"] & 
      content: $slider__arrow--prev
        
/* Dots */
.slick-dotted.slick-slider 
  margin-bottom: 30px

.slick-dots 
  position: absolute
  bottom: -25px
  list-style: none
  display: block
  text-align: center
  padding: 0
  margin: 0
  width: 100%
  
  li 
    position: relative
    display: inline-block
    height: 20px
    width: 20px
    margin: 0 5px
    padding: 0
    cursor: pointer
    
    button 
      border: 0
      background: transparent
      display: block
      height: 20px
      width: 20px
      outline: none
      line-height: 0px
      font-size: 0px
      color: transparent
      padding: 5px
      cursor: pointer
      
      &:hover, 
      &:focus 
        outline: none
        &:before 
          opacity: $state__opacity--hover

      &:before 
        position: absolute
        top: 0
        left: 0
        content: $slider__dot
        width: 20px
        height: 20px
        font-family: 'FontAwesome'
        font-size: $slider__dot--size
        line-height: 20px
        text-align: center
        color: #000000
        opacity: $state__opacity--inactive
        -webkit-font-smoothing: antialiased
        -moz-osx-font-smoothing: grayscale
            
        
    &.slick-active button:before
      content: $slider__dot--active
      color: #000000
      opacity: $state__opacity--default

  
              
            
!

JS

              
                (function() {
  
  /* Define the Apps Module*/
  angular
    .module('app', [])
    .directive('mmbSlider', Slider)
    .controller('SliderCtrl', SliderCtrl)
    .controller('MainCtrl', MainCtrl)
    .factory('dataservice', dataservice);

  
  function dataservice() {
    
    var service = {
      getItems: getItems
    };

    return service;

    //////////////////////////////////////////////////

    function getItems() {
      return [
        {"badge": "fa fa-codepen"}, 
        {"badge": "fa fa-dropbox"},
        {"badge": "fa fa-apple"},
        {"badge": "fa fa-github"},
        {"badge": "fa fa-css3"},
        {"badge": "fa fa-html5"},
        {"badge": "fa fa-slack"},
        {"badge": "fa fa-soundcloud"}
      ];
    }
  }

  ///////////////////////////////////////////////////////////////////
  
  
  Slider.$inject = ['$timeout'];
  
  /* Create Carousel Directive */
  function Slider($timeout) {

      var directive = {
        restrict: 'E',              // invokes the directive as an element 
        replace: true,
        template: getTemplate(),    // call template fn below
        scope: {
          list: '=',
          initOnload: '@',
          data: '=',
          currentIndex: '=',
          accessibility: '@',
          adaptiveHeight: '@',
          arrows: '@',
          asNavFor: '@',
          appendArrows: '@',
          appendDots: '@',
          autoplay: '@',
          autoplaySpeed: '@',
          centerMode: '@',
          centerPadding: '@',
          cssEase: '@',
          customPaging: '&',
          dots: '@',
          draggable: '@',
          easing: '@',
          fade: '@',
          focusOnSelect: '@',
          infinite: '@',
          initialSlide: '@',
          lazyLoad: '@',
          onBeforeChange: '&',
          onAfterChange: '&',
          onInit: '&',
          onReInit: '&',
          onSetPosition: '&',
          pauseOnHover: '@',
          pauseOnDotsHover: '@',
          responsive: '=',
          rtl: '@',
          slide: '@',
          slidesToShow: '@',
          slidesToScroll: '@',
          speed: '@',
          swipe: '@',
          swipeToSlide: '@',
          touchMove: '@',
          touchThreshold: '@',
          useCSS: '@',
          variableWidth: '@',
          vertical: '@',
          prevArrow: '@',
          nextArrow: '@'
        },
        link: linkFunc,
        controller: SliderCtrl
      };

      return directive;
  
      ///////////////////////////////////////////////////////////////////

      function linkFunc(scope, element, attrs, ctrl) {
      
        var destroySlick, 
            initializeSlick, 
            isInitialized;
        
        destroySlick = function () {
          return $timeout(function () {
            var slider;
            slider = $(element);
            slider.slick('unslick');
            slider.find('.slick-list').remove();
            return slider;
          });
        };
        initializeSlick = function () {
          return $timeout(function () {
            var currentIndex, 
                customPaging, 
                slider;
            slider = $(element);
            console.log('Slider:' + slider);
            if (scope.currentIndex != null) {
              currentIndex = scope.currentIndex;
              console.log('Scope is:' + scope);
            }
            customPaging = function (slick, index) {
              return scope.customPaging({
                slick: slick,
                index: index
              });
            };
            slider.slick({
              accessibility: scope.accessibility !== 'false',
              adaptiveHeight: scope.adaptiveHeight === 'true',
              arrows: scope.arrows !== 'false',
              asNavFor: scope.asNavFor ? scope.asNavFor : void 0,
              appendArrows: scope.appendArrows ? $(scope.appendArrows) : $(element),
              appendDots: scope.appendDots ? $(scope.appendDots) : $(element),
              autoplay: scope.autoplay === 'true',
              autoplaySpeed: scope.autoplaySpeed != null ? parseInt(scope.autoplaySpeed, 10) : 3000,
              centerMode: scope.centerMode === 'true',
              centerPadding: scope.centerPadding || '50px',
              cssEase: scope.cssEase || 'ease',
              customPaging: attrs.customPaging ? customPaging : void 0,
              dots: scope.dots === 'true',
              draggable: scope.draggable !== 'false',
              easing: scope.easing || 'linear',
              fade: scope.fade === 'true',
              focusOnSelect: scope.focusOnSelect === 'true',
              infinite: scope.infinite !== 'false',
              initialSlide: scope.initialSlide || 0,
              lazyLoad: scope.lazyLoad || 'ondemand',
              beforeChange: attrs.onBeforeChange ? scope.onBeforeChange : void 0,
              onReInit: attrs.onReInit ? scope.onReInit : void 0,
              onSetPosition: attrs.onSetPosition ? scope.onSetPosition : void 0,
              pauseOnHover: scope.pauseOnHover !== 'false',
              responsive: scope.responsive || void 0,
              rtl: scope.rtl === 'true',
              slide: scope.slide || 'li',
              slidesToShow: scope.slidesToShow != null ? parseInt(scope.slidesToShow, 10) : 1,
              slidesToScroll: scope.slidesToScroll != null ? parseInt(scope.slidesToScroll, 10) : 1,
              speed: scope.speed != null ? parseInt(scope.speed, 10) : 300,
              swipe: scope.swipe !== 'false',
              swipeToSlide: scope.swipeToSlide === 'true',
              touchMove: scope.touchMove !== 'false',
              touchThreshold: scope.touchThreshold ? parseInt(scope.touchThreshold, 10) : 5,
              useCSS: scope.useCSS !== 'false',
              variableWidth: scope.variableWidth === 'true',
              vertical: scope.vertical === 'true',
              prevArrow: scope.prevArrow ? $(scope.prevArrow) : void 0,
              nextArrow: scope.nextArrow ? $(scope.nextArrow) : void 0
            });
            slider.on('init', function (sl) {
              if (attrs.onInit) {
                scope.onInit();
              }
              if (currentIndex != null) {
                return sl.slideHandler(currentIndex);
              }
            });
            slider.on('afterChange', function (event, slick, currentSlide, nextSlide) {
              if (scope.onAfterChange) {
                scope.onAfterChange();
              }
              if (currentIndex != null) {
                return scope.$apply(function () {
                  currentIndex = currentSlide;
                  return scope.currentIndex = currentSlide;
                });
              }
            });
            return scope.$watch('currentIndex', function (newVal, oldVal) {
              if (currentIndex != null && newVal != null && newVal !== currentIndex) {
                return slider.slick('slickGoTo', newVal);
              }
            });
          });
        };
        if (scope.initOnload) {
          isInitialized = false;
          return scope.$watch('data', function (newVal, oldVal) {
            if (newVal != null) {
              if (isInitialized) {
                destroySlick();
              }
              initializeSlick();
              return isInitialized = true;
            }
          });
        } else {
          return initializeSlick();
        }
        
      }
      
      function getTemplate() {
        
        return [
          
          '<ul>',
            '<li class="slick-slide" data-ng-repeat="item in list">',
              '<i class="{{item.badge}} badge"></i>',
            '</li>',
          '</ul>'
          
        ].join('');
        
      }
      
    }// end Carousel
  
    ///////////////////////////////////////////////////////////////////
  
    /* Build our controllers */
    MainCtrl.$inject = ['$scope', 'dataservice'];

    function MainCtrl($scope, dataservice) {
      var vm = $scope;
      vm.items = dataservice.getItems();
      console.log(vm.items);
    }
  
  
  SliderCtrl.$inject = ['$scope'];

  function SliderCtrl($scope) {
    
  }
  
})();
              
            
!
999px

Console